I setup a script that checks my doors to see their states. As it currently is, it either reports “All doors are secure” if all states of the entities are off. If one of the entities is On it goes through the list. Door is Off, Porch is Off, Garage is OPEN, Slider is Off…
I would like it to ONLY report back which entities are On, instead of Alexa rambling all of the states. But also report back with a custom ____ is Open instead of ____ is On.
i.e. " Door is Open" not “Door is On”
door_check:
alias: Door Check all Doors TTS Living
sequence:
service: media_player.alexa_tts
data_template:
entity_id: media_player.living_room
message: ’
{%- if is_state(“binary_sensor.door_window_sensor_158d000208e248”, “off”) and
is_state(“binary_sensor.door_window_sensor_158d0002228713”, “off”)and
is_state(“binary_sensor.door_window_sensor_158d000245b2c7”, “off”)and
is_state(“binary_sensor.door_window_sensor_158d000245b38a”, “off”) -%}
All doors are secure
{%- else -%}
The Front door is {{ states(“binary_sensor.door_window_sensor_158d000208e248”) }}
The Front Porch door is {{ states(“binary_sensor.door_window_sensor_158d0002228713”) }}
The Slider Door is {{ states(“binary_sensor.door_window_sensor_158d000245b2c7”) }}
The Garage Door is {{ states(“binary_sensor.door_window_sensor_158d000245b38a”) }}
{% endif %} ’
Forget about this post, its not working. If there is just one window/door open it will show:
, Livingroom left open
or
and Livingroom right open
without any other text around it.
Old Post:
This is what I need. It shows me all the open sensors:
{%- for entity_id in states.group.doorsensors.attributes.entity_id -%}
{% set parts = entity_id.split('.') -%}
{%- if states(entity_id) == 'on' %}
{%- if loop.first %}Warning! The following sensors are OPEN: {% elif loop.last %} and {% else %}, {% endif -%}{{ states[parts[0]][parts[1]].name }}{% endif -%}
{%- endfor %}