I have an automation that notifies me when a Sonoff temperature / humidity sensor’s battery drops below a certain level. Given that I have a few of these sensors, what’s the best way to create automations for all of these sensors? I assume there’s some way to have an array of sensor names / IDs or to use wild cards?
Hello gsoper,
Possibly this?
You can make a blueprint, then generate multiple automations by just providing the entities.
I’d say it depends very much on what these automations are supposed to do.
If you only want to be notified that the battery is below a certain percentage, you can add as many entities as you need, to the trigger like this:
alias: IKEA Battery below 15%
description: ""
triggers:
- entity_id:
- sensor.ikea_01_battery
- sensor.ikea_02_battery
below: 15
for:
hours: 48
minutes: 0
seconds: 0
trigger: numeric_state
conditions: []
actions:
- data:
message: "{{ trigger.to_state.name }} is less than 15%!"
title: Battery Reminder
data:
ttl: 0
priority: high
tag: ikea_battery
action: notify.mobile_app_wg_s_pixel_9a
mode: single
You don’t need the tag, but if the battery goes back up above 15% because it just dipped for a strange reason, I have the notification deleted automatically again.
If you need to carry out different actions per device, it gets a little more complicated/convoluted.