I created a “Delta” template sensor to work out a temperature difference between a single sensor and a Min/Max Helper created for an average to measure against, but I noticed that the results spiked every time HA is restarted.
To start, I created the Helper to get an average value from selected nearby rooms.
Then I created a template sensor to calculate the delta between the Helper value and a weather sensor on my (dumb) boiler. This is set up so I can double check that it’s been switched on by our switchbot switch and that we have hot water ready for use.
Typically the delta value will range from -1 to +15 depending on the average ambient and if the boiler is generating heat
But it looks like the helper or template isn’t starting in time, so the calculation returns the full value of the Boiler Temperature as there’s no Helper number available to calculate against for a few seconds.
This results in false spikes in the Lovelace card (heating’s been off for a few hours):
I tried changing the template sensor to default as 0 if the helper or isn’t available or the helper returns a 0, but that hasn’t worked.
Has anyone else had this kind of issue and needed to ignore or set a default value until the true value is returned?
Template as it is atm:
# Boiler Room Delta
- sensor:
- name: boiler_room_temperature_delta
unique_id: ddd99cd0-ddd99cd0-ddd99cd0-ddd99cd0
unit_of_measurement: °C
icon: mdi:thermometer
state: >
{% if is_state('sensor.home_temperature', '0') or is_state('sensor.boiler_room_temperature', '0') or is_state('sensor.home_temperature', '0.0') or is_state('sensor.boiler_room_temperature', '0.0') %}
0
{% else %}
{{ (((states.sensor.boiler_room_temperature.state) |float (0)) - ((states.sensor.home_temperature.state) | float (0))) | round(1) }}
{% endif %}