tom_l
4
Almost. If you don’t want to use the shorter config I posted yours should be:
template:
- sensor:
- name: "CPULoad"
unit_of_measurement: "%"
state: >
{% if states('sensor.cpuload') == 'unavailable' %}
0
{% else %}
{{states('sensor.cpuload')}}
{% endif %}
You could also just do this:
template:
- sensor:
- name: "CPULoad"
unit_of_measurement: "%"
state: "{{ states('sensor.cpuload')|float }
The float
filter will return 0 for strings.
Yes. Here are two ways:
or
1 Like