Using a calculation as an automation trigger

Hi,
I’d like to trigger my minisplit a/c heating/cooling only when the room temp falls outside certain boundaries. So that the units are not blowing 24/7.

So i’d like two automations, one that switches the mode to cooling when the room temp is 1.5C above the current setpoint (i have an input number as my setpoint, that is sent to the a/c and also a diesel heater, simultaneously) and another automation that triggers heat mode when the room temp falls 1.5C below the setpoint.

I have been trying to understand all the options here:
But my mind is getting scrambled.

I would appreciate some pointers to better understand the correct approach

cooling

triggers:
  - trigger: numeric_state
    entity_id: sensor.room_temp
    value_template: "{{ state.state|float(-1000) + 1.5 }}"
    above: input_number.set_point

heating

triggers:
  - trigger: numeric_state
    entity_id: sensor.room_temp
    value_template: "{{ state.state|float(1000) - 1.5 }}"
    below: input_number.set_point

The default values in brackets will prevent the triggers from occurring if the room temperature state becomes unknown or unavailable - assuming your set point never gets near +/-1000° :grin:

1 Like

Note there is one edge case that might be an issue with doing it that way. If you change the set point input number so that it should trigger the automation the trigger will not occur until next time the temperature sensor changes. Only the temperature sensor is monitored for changes in that type of trigger. This is by design. If you want it to immediately trigger in this case then you will have to use template triggers. These monitor all entities in the trigger for changes:

cooling

triggers:
 - trigger: template
   value_template: "{{ states('sensor.room_temp')|float(-1000) + 1.5 > states('input_number.set_point')|float }}"

heating

triggers:
  - trigger: template
    value_template: "{{ states('sensor.room_temp')|float(1000) - 1.5 < states('input_number.set_point')|float }}"
1 Like

Many thanks, I will test this in the morning and mark as solved as appropriate.