God, I’m lost
I’ve been trying to get an automation check my binary sensors for my doors and windows at 10pm if they’re open or close and announce via notify.alexa_media which ones are open (or give it a ‘all clear’ if they’re closed).
I’ve obviously missing something, but I can’t get an ‘open’ notification.
Here’s the code:
alias: Check Doors and Windows at 10 PM
trigger:
- platform: time
at: "22:00:00"
condition: []
action:
- variables:
open_entities: >
{%- set entities = [
'binary_sensor.back_door',
'binary_sensor.front_door',
'binary_sensor.kitchen_door',
'binary_sensor.living_room_patio_door',
'binary_sensor.kitchen_window',
'binary_sensor.study_window',
'binary_sensor.utility_room_window',
'binary_sensor.wc_window'
] -%}
{%- set open_entities = entities | selectattr('state', 'eq', 'on') | list -%}
{{ open_entities }}
- choose:
- conditions: "{{ open_entities | length > 0 }}"
sequence:
- service: notify.alexa_media
data:
target:
- media_player.alexa_kitchen_2
- media_player.bedroom
message: >
The following entities are open:
{{ open_entities | join(', ', attribute='entity_id') }}
- conditions: "{{ open_entities | length == 0 or not open_entities }}"
sequence:
- service: notify.alexa_media
data:
target:
- media_player.alexa_kitchen_2
- media_player.bedroom
message: "All windows and doors are closed"
Please help, why are the open sensors not changing the open_entities with the ones that are “on” status? It always return a value of 0
1 post - 1 participant