I am looking for an option to send an alert every x minutes when a window & door are open at the same time. But I only want to send the notification to the people who are home. And if nobody is home it should be sent to a specific notifier. But as far as I can see there is no way to support that without creating a new alert configuration based on an extra binary_sensor This is my config so far. at that is working for 1 device.
room_bathroom_door_and_window_open_alert:
name: Bathroom Door & Window are both open
message: Bathroom door & window are still open. Close them
entity_id: binary_sensor.room_bathroom_door_and_window_open
repeat:
- 2
- 15
skip_first: true
notifiers:
- koen
I would like something like this:
room_bathroom_door_and_window_open_alert:
name: Bathroom Door & Window are both open
message: Bathroom door & window are still open. Close them
entity_id: binary_sensor.room_bathroom_door_and_window_open
repeat:
- 2
- 15
skip_first: true
notifiers:
- {% if (is_state('person.koen', 'home')) and (is_state('person.laure', 'home')) %}
everyone
{% elif is_state('person.koen', 'home') %}
koen
{% elif is_state('person.laure', 'home') %}
laure
{% endif %}
@tom_l why did you change it to configuration? I first asked on discord if this was possible. And they said I had to create a new feature request. And not it again marked as configuration. This is currently not supported by the alert integration.
trigger:
- platform: state
entity_id: binary_sensor.your_window
to: 'on'
- platform: state
entity_id: binary_sensor.your_door
to: 'on'
conditions:
- condition: state
entity_id: binary_sensor.your_window
state: 'on'
- condition: state
entity_id: binary_sensor.your_door
state: 'on'
action:
- while: "{{ is_state('binary_sensor.your_window', 'on') and is_state('binary_sensor.your_door', 'on') }}"
sequence:
- service: >
{% if is_state('person.koen', 'home') and is_state('person.laure', 'home') %}
notify.everyone
{% elif is_state('person.koen', 'home') %}
notify.koen
{% elif is_state('person.laure', 'home') %}
notify.laure
{% else %}
notify.specific_notifier_when_nobody_is_home_that_you_did_not_specify
{% endif %}
data:
message: "The door and window are open."
- delay:
minutes: "{% 2 if repeat.index % 2 == 0 else 15 %}"
The trigger/condition combination only runs the actions if both the door and window are open.
The while template repeats until one or both of them is closed.
The delay is 2 minutes for even loop counts and 15 minutes for odd loop counts.
Now I don’t know if the repeat index is incremented at the beginning or end of the loop. If you find that the first delay is 15 minutes instead of 2, change the minutes template to: "{% 2 if repeat.index % 2 == 1 else 15 %}"
This also assumes you have set up the notification services/groups: