Hi everyone
I still have a problem with my template sensors…
The problem: I have defined a template sensor that should give exactly the same result as the physical sensor:
Physical sensor:
sensor.smart_plug_p07_power
And my template sensor:
# ---------------------------------------------------
- name: "Elektriciteit Kring A power"
unique_id: "sensor.elektriciteit_kring_a_power"
icon: mdi:flash
unit_of_measurement: "W"
device_class: energy
state_class: measurement
state: >
{% if ( states('sensor.smart_plug_p07_power') not in ['unknown', 'unavailable', 'None'] ) %}
{{ states('sensor.smart_plug_p07_power') | float }}
{% else %}
{{ "0" | float }}
{% endif %}
availability: >
{{ states('sensor.smart_plug_p07_power') }}
attributes:
attribute: >
{{ now().minute }}
If I take a closer look at the values in Grafana, I can see the following:
- my physical sensor “P07” reports correct values (1) and (2)
- my template sensor only shows differences in values different from zero. So when my “P07” reports a power consumption of zero, it seems that my template sensor doesn’t get this information.
If I take a closer look to the native Home Assistant data:
Physical Sensor
Template Sensor:
So for some reason, my template sensor goes to “unavailble” despite my physical sensor is still available.
What’s the reason for this?
How this can be avoided?
Kind regards,
Bart Plessers