I’m seeing errors like this:
TemplateError('ValueError: Template error: float got invalid input 'unavailable' when rendering template '{{ [ states('sensor.main_house_net_power'), states('sensor.west_wing_power'), states('sensor.tool_store_net_power'), states('sensor.garage_power') ] | map('float') | sum }}' but no default was specified') while processing template 'Template("{{ [ states('sensor.main_house_net_power'), states('sensor.west_wing_power'), states('sensor.tool_store_net_power'), states('sensor.garage_power') ] | map('float') | sum }}")' for attribute '_attr_native_value' in entity 'sensor.total_power'
that relate to template sensors like this:
- sensor:
- name: "Total Power"
unit_of_measurement: "kW"
device_class: power
state: >
{{ [ states('sensor.main_house_net_power'),
states('sensor.west_wing_power'),
states('sensor.tool_store_net_power'),
states('sensor.garage_power') ]
| map('float') | sum }}
availability: >
{{ not 'unavailable' in
[ states('sensor.main_house_net_power'),
states('ssensor.west_wing_power'),
states('sensor.tool_store_net_power'),
states('sensor.garage_power') ] }}
I think it’s because if one of the sensors becomes unavailable then the template can’t be evaluated as it sees a string instead of an expected float.
Is there a way to catch this and prevent the error?