I would like to create an automation that’s adds a todo item when a battery level gets low. It seems straight forward to create an automation for a specific device but is there a way to make a single automation that can add todo list items for each device?
Yes, you can create a list of your batteries in state ‘low’ and then run an action/service to add this to the list.
This is but an example for how I create zones
alias: New automation
description: ""
trigger:
- platform: time_pattern
minutes: /5
condition: []
action:
- repeat:
for_each: >-
{{states.zone |selectattr('entity_id', 'search',
'station_')|map(attribute='entity_id') | list }}
sequence:
- action: zone.delete
data:
entity_id: "{{ repeat.item }}"
- repeat:
for_each: "{{ state_attr('sensor.test_stations', 'stations') | list }}"
sequence:
- action: zone.create
data:
radius: 100
icon: mdi:gas-station-in-use-outline
name: "{{ 'station_' + repeat.item.name }}"
latitude: "{{ repeat.item.latitude }}"
longitude: "{{ repeat.item.longitude }}"
mode: single