Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Config Support]: Added Filter Based on Day of week #300

Open
albertlt opened this issue Oct 25, 2024 · 2 comments
Open

[Config Support]: Added Filter Based on Day of week #300

albertlt opened this issue Oct 25, 2024 · 2 comments

Comments

@albertlt
Copy link

Describe the problem you are having or the outcome you are trying to achieve.

Hello. First of all, thank you for the great blueprint. I added filter to run the automation based on certain days (Monday, Tuesday, ...). So far it worked correctly but I am not sure if my approach is right. I will explain the changes below and please let me know if the implementation is correct.

By the way, I also need to check state from multiple entity in the state filter but I don't know how to do that. Can you please add that functionality to next release?

Something like: run the automation if input_boolean.HomeAlarm is ON AND input_boolean.MasterSwitch is ON.
Basically, I need all entities evaluation to be true before executing the notification.

Anyway, back to topic, here is my modification:

STEP 1 - REGISTER NEW VARIABLE
Add :

input_day_filter: !input day_filter
day_filter: '{{ input_day_filter | list }}'

To :

variables:
input_camera: !input camera
camera: '{{ input_camera | regex_replace(''^camera.'', '''') }}'

STEP 2 - CREATE NEW INPUT SECTION
Add :

day_filter:
name: Day Filter (Optional)
description: Select days to receive notifications
default: []
selector:
select:
options:
- label: Monday
value: "0"
- label: Tuesday
value: "1"
- label: Wednesday
value: "2"
- label: Thursday
value: "3"
- label: Friday
value: "4"
- label: Saturday
value: "5"
- label: Sunday
value: "6"
multiple: true
custom_value: false

To :

filters:
name: '# Filters

    '
  description: These are Filter Options
  icon: mdi:filter
  collapsed: true
  input:
    zone_filter:
    …

STEP 3 – EVALUATE CONDITION
Add :

  • condition: template
    value_template: >
    {{ day_filter | length == 0 or now().weekday() | string in day_filter }}

To :

  • alias: Frigate Event
    conditions:
    • condition: trigger
      id: frigate-event
    • '{{ is_state(this.entity_id, ''on'') }}'
      ….

Attached is full modified yaml file renamed to txt extension so I can upload it here. Please kindly have a look. Thank you.

Stable - 0.12.0.4e - Added Day Filter.yaml.txt

Version

0.12.0.4e

Automation config

none

Frigate Config

No response

Any other information that may be helpful

No response

@albertlt
Copy link
Author

Btw, the editor automatically converted - to bullet points :( Maybe better to just refer to attached yaml file :)

@SgtBatten
Copy link
Owner

Seems like a working filter. It would be great if you could add it as a pull request to the beta blueprint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants