I have a command line sensor:
command_line:
- sensor:
name: cmd_disk_lifetime
command: 'curl -s -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/host/info | jq ".data.disk_life_time"'
unit_of_measurement: "%"
state_class: measurement
# This fixes the silent 'unavailable' state by handling null or empty strings
value_template: >
{% if value in ['null', '', 'None'] or value is not defined %}
0
{% else %}
{{ value | int }}
{% endif %}
scan_interval: 3600
unique_id: host_disk_lifetime
The sensor obtains a value at the moment of reloading only, but then becomes unavailable without any errors.
I would appreciate any help or advice on where to look for the problem.
