Working on an automation that will alert me if a window opens for > 30sec.
It’s binary sensor group that consists of 3 levels of binary sensor groups (room > upstairs/downstairs> all).
It currently shows me which window open (via expand()) in the notification which is great but I’d like to know which condition was met using the friendly, renamed name.
Just to clarify - not looking for help on the conditions themselves, just how to access the ‘met’ condition so that I can include it in the notification.
I only have the one condition worked out right now but in the action message where it has ‘xyz’ I want it to say “Outdoor Temp Is Below 50” (the alias), if that is the condition met.
I don’t have any attempted code in there since I don’t know where to begin to grab the condition data
alias: Window Opened
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.all_windows
to: "on"
for:
hours: 0
minutes: 0
seconds: 30
condition:
- condition: numeric_state
entity_id: sensor.weather_home_outside_temperature
below: 50
alias: Outdoor Temp Is Below 50
action:
- repeat:
while:
- condition: state
entity_id: binary_sensor.all_windows
state: "on"
sequence:
- service: notify.mobile_app_scotts_phone
data:
title: A window is open
message: >-
These windows need closed because xyz: {{
expand('binary_sensor.all_windows')
| selectattr('state', 'eq', 'on')
| map(attribute='name')
| list
| join (', ')
}}
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
mode: single
If the single condition is not met, no actions will be executed.
If you have multiple conditions logically ANDed then all must be met in order to execute the actions.
If you have multiple conditions logically ORed then at least one of them must be met in order to execute the actions. Which one was met is not communicated to the automation’s action.
If it’s a single condition then there’s no reason to communicate it to the action. You know the condition is ‘Outdoor Temp Is Below 50’ so just enter that in message (i.e. hard-code it).
If it’s multiple ORed conditions and you want to know which one then you need to restructure the automation. I can explain what I mean but it would be helpful if you provided an example of the conditions you intend to use.
If my suggestion has solved the original problem, please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions.
For more information about the Solution tag, refer to guideline 21 in the FAQ.