You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this template sensor stays in °C, there is no issue. However if the units are changed to °F from the UI, we now have a scenario where the undesired value is selected by the max function (because this.state has already been converted to °F and is therefore larger). Even worse, that returned value is again "converted" to °F. The end result is that upon each trigger, the value of this template sensor skyrockets due to double-conversion.
This unintended behavior will occur for any sensor which:
is defined with a device_class that supports unit conversions
contains a template which self-references
has its unit of measurement changed, either by a user from the UI or automatically by HA due to the unit system selected when the sensor was added.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let's define a trigger-based template sensor which reports the max temperature from all time:
If this template sensor stays in °C, there is no issue. However if the units are changed to °F from the UI, we now have a scenario where the undesired value is selected by the
max
function (becausethis.state
has already been converted to °F and is therefore larger). Even worse, that returned value is again "converted" to °F. The end result is that upon each trigger, the value of this template sensor skyrockets due to double-conversion.This unintended behavior will occur for any sensor which:
Beta Was this translation helpful? Give feedback.
All reactions