I have a bunch of water leak sensors and want to get notified when one is triggered. Is there anyway to do a trigger with a wildcard name? Or do I need to add all of them manually and update as I add more?
Create a group and trigger on group change.
If you need to notify specific devic you can do that as part of action
Be aware that if you do use a group, if more than one member of the group detects a water leak (within a short period of time), the automation will only trigger for the first member that reports the leak but not for any others while the first one is still reporting a leak.
To be clear, this is a drawback only if you’re concerned that the flooding can be so extensive that it sets off multiple detectors (but you’ll be informed only of the first one).
FWIW, I simply list them manually in the automation’s State Trigger. It ensures the automation is triggered by any detector even while another is still reporting a leak.
For example, this sends a notification (via SMS) indicating which area has a water leak.
alias: Monitor Water Leaks
triggers:
- trigger: state
entity_id:
- binary_sensor.floor_drain_water_leak
- binary_sensor.kitchen_sink_water_leak
- binary_sensor.bathroom_sink_water_leak
- binary_sensor.washer_machine_water_leak
- ... etc ...
to: 'on'
conditions: []
actions:
- action: notify.sms_all
data:
title: 'Emergency Alert: Water Leak'
message: 'Water leak detected in {{ area_name(trigger.entity_id) }}.'
EDIT
Modification. Removed from: 'off'
for the reason described in tmjpugh’s post below.
I don’t use “from: off”
I worry sensor becomes unavailable then wakes up as ON. See any drawback for this use.
So it’s unavailable
during a water leak then, when it re-establishes communications with Home Assistant, it reports on
(because it detected a leak).
I agree; given that situation it would be better to detect any state-change to on
(not just from off
).
Not really an issue because part of the automation is shutting off the water
How do you send a SMS message?
I’d suggest having the HA mobile app on your phone and use action:
Notifications: Send a notification via mobile_app_xxxx
or
Ah, I thought you’re using a piece of hardware with Sim card.
Thnx
Then you should be fine using a group.
I use an email-to-SMS service provided by my phone operator.
Home Assistant sends an email to the operator (using the SMTP integration), addressed to my phone number, and they forward it to me as an SMS message. It’s fast, easy, and free.
FWIW, when outside my home, my phone is rarely connected to my Home Assistant server (I use Tailscale, for remote access, and enable it only when needed).
That choice makes it infeasible, for me, to use the native notification service available in the Companion App (which requires a full-time connection in order receive a notification at any time). However, SMS is always enabled on my phone and is widely available (unless, on the rare occasion, I’m in an area with no cell service).
Great, thnx for explaining. I’m in the same boat so SMS would be nice, also looking at ntfy.
FYI. Email to text may be going away for some carriers soon. At&T ends this month, Verizon may be continuing but unclear and Tmobile is iffy. Not sure outside U.S.
Email to text was super handy for me when used it
Thank you; good to know.
FWIW, in my case, I am outside the USA. There was talk, some while ago, about my carrier eliminating the service but it still continues to work for me. I found an alternative (SMS via a VOIP provider I already use for another purpose) but won’t switch until it’s absolutely necessary.