Hi - I want to monitor a window and notify all family members at home to close it.
I did write an automation for one person (s. below) but it seems clunky to repeat that four times (number of people here). Especially since there are likely more applications with a similar problem.
Is there maybe some way to create a dynamic list of persons who satisfy certain conditions?
Thanks.
- id: "1645375982893"
alias: Klofenster lange offen
description: ""
trigger:
- type: opened
platform: device
device_id: 0cf51fc7a89c5c2cfefa1180544adf30
entity_id: binary_sensor.klofenster
domain: binary_sensor
for:
hours: 0
minutes: 5
seconds: 0
condition:
- condition: state
entity_id: person.markus
state: home
action:
- service: notify.mobile_app_hyrule
data:
message: Bitte Klofenster schliessen!
mode: single
It is possible to use templating to create a dynamic list of persons who meet a condition and then use notifier groups as Joaquin linked. However, the number of necessary notifiers grows exponentially with each additional person and becomes way more effort than necessary if you have more than 2 people.
Instead, use a series of indendent Choose actions. You can make it more universal/reusable by turning it into a script and having your automations pass the desired variables.
Hi,
thanks for the answers and sorry for the late reply.
Iâve tried @Didgeridrew solution but it works only halfway. The automation calls the script but the script does not send the notifier.
It works only if I explicitly put the state and the message into the script like this:
family_notifier:
alias: Family Notifier
description: "Send a notification to every family member who is in a specific state"
fields:
state:
description: "The state person entities should be in to receive the notification"
example: "home"
message:
description: "The notification's message"
example: "Markus is leaving work"
sequence:
- choose:
- conditions:
- condition: state
entity_id: person.markus
state: "home"
sequence:
- service: notify.mobile_app_hyrule
data:
message: "blabla"
Somehow the parameters are not transferred to the script.
Itâs not because the variables arenât being passed, itâs because Iâm an idiot⌠I forgot that you canât template a state condition like that, but you can do it as a template condition. I have updated my earlier post with the fix.
Sorry, Iâm a bit lost. I checked all indentations and quotations but couldnât find a wrong one.
This is a screenshot of what it looks like in VSCode in HA (sorry, canât paste the error message):