I have had this automation a few years:
- id: 'batterisjekk'
alias: 'Batterisjekk'
trigger:
platform: time
at: '10:00:00'
action:
service: mqtt.publish
data_template:
payload_template: >
{%- for s in states.sensor if ('battery' in s.entity_id ) and s.state|int < 20 and s.state != 'unavailable' and s.state != 'idle' %} {{s.name}}: {{ s.state }}% {%- endfor %}
topic: eg/Batterialarm
This has told me that devices do not have more than 20 % left on the battery. Especially important for the ID Lock Z-Wave door locks. But I found out today that my door is down to 10 % without any warning! So something must have happened somewhere that has put this template out of action. When I try the template in the template section of developer’s tools I get:
ValueError: Template error: int got invalid input ‘unavailable’ when rendering template ‘{%- for s in states.sensor if (‘battery’ in s.entity_id ) and s.state|int < 50 and s.state != ‘unavailable’ and s.state != ‘idle’ %} {{s.name}}: {{ s.state }}% {%- endfor %}’ but no default was specified
Can somebody please tell me what’s going on there, it’s too cryptic for me, I’m afraid.