I’d suggest a template sensor. Play around in the template editor — something like this should give a list of entities that you’re looking for, provided the battery level is the sensor state and not an attribute:
{% for sensor in states.sensor %}
{{ sensor.entity_id if "_battery_level" in sensor.entity_id and sensor.state|int < 50 }}
{% endfor %}
Then you need to work out a way for the template to return True
if there is an entity in the list.
Need to sort out:
- A trigger. Probably use
sensor.time
or a time pattern trigger. - How you’d get the triggering entity, as this won’t work.
Recommendation: use AppDaemon instead. It’s ideal for this sort of more complex logic, but is a bit of a learning curve.
Alternatively, see this topic.