Entity: sensor.derivee_temperature_sud → derivative from outdoor sensor
{## store temperatures in var ##}
{% set temp_int = float(states.sensor["0x00124b0025033e5e_3_temperature"].state) %}
{% set temp_ext = float(states.sensor["0x00124b0025031c97_4_temperature_2"].state) %}
{## calculate the difference between the two ##}
{% set temp_diff = float(states.sensor["0x00124b0025031c97_4_temperature_2"].state) - float(states.sensor["0x00124b0025033e5e_3_temperature"].state) %}
{## predict the temperature in 30 minutes given the current temperature and the derivative (mili Celcius/minute) ##}
{% set derivate = float(states.sensor.derivee_temperature_sud.state) * 30 / 1000 %}
{% set predicted_temp_ext = temp_ext + derivate %}
{## if the predicted outdoor temperature (in 30min) is above the indoor temperature, trigger the actions. ##}
{% if predicted_temp_ext > temp_int %}
true
{% endif %}
The result in dev tool is ‘true’.
Automation trace is empty (I also checked that notification is working using time pattern as trigger).
Consider using float filters instead of functions for readability.
Set your template to provide a true or false result. e.g.
{{ predicted_temp_ext > temp_int }}
Consider editing your entity ids to be something human readable that does not begin with a number so that you don’t have to use square bracket notation.
config/home-assistant.log doesn’t show errors anymore but the automation is still not triggered.
Consider editing your entity ids to be something human readable that does not begin with a number so that you don’t have to use square bracket notation.
Thanks for the tip, I’ll consider it (changing the entity ID from mqtt devices causes issues with HA).
Indeed, that’s the object I’m using for sensor.derivee_temperature_sud
It is the derivative from the outdoor temperature (sensor.0x00124b0025031c97_4_temperature_2). I created it using the UI but I can’t find it in the yaml files in /config.
2022-05-02 14:23:00 DEBUG (MainThread) [homeassistant.helpers.event] Template group [TrackTemplate(template=Template("{## Store temperatures in var ##}
{% set temp_int = float(states('sensor.0x00124b0025033e5e_3_temperature'), 0) %}
{% set temp_ext = float(states('sensor.0x00124b0025031c97_4_temperature_2'), 0) %}
{## calculate the difference between the two ##}
{% set temp_diff = temp_ext - temp_int %}
{## predict the temperature in 30 minutes given the current temperature and the derivative ##}
{% set derivate = float(states('sensor.derivee_temperature_sud'), 0) * 30 / 1000 %}
{% set predicted_temp_ext = temp_ext + derivate %}
{## optional: use absolute values ##}
{% set abs_temp_diff = int(temp_diff - derivate) | abs %}
{% set abs_derivate = derivate | abs %}
{% set v = states.sensor.time.state %}
{{ predicted_temp_ext >= temp_int }}"), variables=None, rate_limit=None)] listens for {'all': False, 'entities': {'sensor.derivee_temperature_sud', 'sensor.time', 'sensor.0x00124b0025031c97_4_temperature_2', 'sensor.0x00124b0025033e5e_3_temperature'}, 'domains': set(), 'time': False}, re-render
blocker by super template: False
I tried to change the condition to predicted_temp_ext >= temp_int or predicted_temp_ext > temp_int