Hi.
I got the following tamplate
{{ expand('group.batterier')
| map (attribute='state')
| map ('int') |select('<', 10) | list | count > 0 }}
generating the following output when everything is ok
Result type: boolean
false
This template listens for the following state changed events:
* **Entity**: group.batterier
* **Entity**: sensor.bedroom_switch_battery
* **Entity**: sensor.caroline_switch_battery
* **Entity**: sensor.front_door_battery
* **Entity**: sensor.gang2_switch_battery
* **Entity**: sensor.have_hegn_battery
* **Entity**: sensor.have_spot_battery
* **Entity**: sensor.livingroom_switch_battery
* **Entity**: sensor.motion_hallway_battery
* **Entity**: sensor.pool_battery
* **Entity**: sensor.sensor_badevaerelse_battery
* **Entity**: sensor.sensor_stue_battery
* **Entity**: sensor.sovevaerelse2_battery
* **Entity**: sensor.trappe_battery
This is the result if one of the sensors become unavarible.
Is there anyway to exclude that sensor in the template ?
ValueError: Template error: int got invalid input 'unavailable' when rendering template '{{ expand('group.batterier')
| map (attribute='state')
| map ('int') |select('<', 10) | list | count > 0 }}' but no default was specified
Code in the automation, it is triggered by a timer, purpose is to notify if a battery need attension.
action:
- if:
- condition: template
value_template: "{{ expand('group.batterier') \n|map(attribute='state')\n|map
('int') \n|select('<', 10)|list|count > 0 } default=0}\n"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.batterystate
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.batterystate
mode: single