Hi,
I am a beginner with automations and I am looking to create something like this :
- once my alarm is activated (ringing), monitor rooms where motion detectors turn ‘on’ and add those rooms into a list without duplicate (if 2 detectors are in the same room, do not add the room twice).
- every 10 seconds, or whenever a new room is added to the list, i run a TTS on all my speakers with the list of rooms
- once the alarm is stopped, I reset the list of rooms.
I thought about using 3 automations for that :
Automation 1) : trigger once a detector state change to ‘on’, with a condition that alarm_ringing is ‘on’. I would then need to create and store the list of rooms in order to pass it to Automation 2). I thought about using an ‘input_text’ to store this list, but maybe there are better solutions.
Automation 2) : trigger every 10 seconds or when the list of rooms is changed (state of input_text), with condition that alarm_ringing is ‘on’. The action is then to run a TTS with the list of rooms on all speakers.
Automation 3) : trigger once alarm_ringing is ‘off’. Reset the list of rooms to an empty list.
I struggle with the creation of the room list in Automation 1), I have tried this but it does not work :
- service: input_text.set_value
data_template:
entity_id: input_text.room_list_text
value: >
{% if is_state('input_text.room_list_text', '') %}
{% set room_list = [] %}
{% else %}
{% set room_list = state('input_text.room_list_text').split(',') %}
{% endif %}
{% if 'Kitchen' not in room_list and (is_state('binary_sensor.detector_kitchen1', 'on') or is_state('binary_sensor.detector_kitchen2', 'on')) %}
{{ room_list.append('Kitchen') }}
{% endif %}
{% if 'Bedroom' not in room_list and is_state('binary_sensor.detector_bedroom', 'on') %}
{{ room_list.append('Bedroom') }}
{% endif %}
{{ room_list | join(',') }}
Unfortunately the .append function does not seem to work with home assistant.
Do you have any suggestion on how to achieve this functionality ?
Thank you very much in advance.