Automation Sensor Check Logic

I have an automation that switches on the airconditioner if the temperature sensor reports a temperature of 25.3:

It doesn’t work if the temperature is above 25.3 at the time the automation is activated/enabled. So the only way to use this automation is to manually bring the temperature down to below 25.3 or below, then as the temperature rises to above 25.3 the automation will run correctly.

So I guess programmatically the logic is looking for the sensor value to increase from 25.3, rather than checking if the current temperature is above 25.3. I think either the labelling needs to be corrected or the logic needs to be more logical.

alias: Lounge A/C Auto
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.lounge_temperature
    above: 25.3
conditions:
  - condition: device
    type: is_off
    device_id: 267862dd569a416e61ca8c95f16f5757
    entity_id: 955f3bebceee0ee1f6fb8d61866c3ffb
    domain: switch
actions:
  - action: script.turn_on_main_a_c_1_hour
    metadata: {}
    data: {}
mode: single

Use a template trigger.

{{ states("sensor.temp") | float(0) > 25.3 }}

Or consider using a generic thermostat

You are correct. The trigger has to basically be false and change to true.

A template trigger will not change that.

Hello wtzitabt,

Use a state trigger to fire on any change of the temperature, then add a condition that the temp is > your setting to continue.

You described exactly how a numeric trigger works…

The Numeric State Trigger’s documentation explains how it works. The entity’s state value must cross the threshold value.

From the documentation:

Note

Crossing the threshold means that the trigger only fires if the state wasn’t previously within the threshold. If the current state of your entity is 50 and you set the threshold to below: 75, the trigger would not fire if the state changed to e.g. 49 or 72 because the threshold was never crossed. The state would first have to change to e.g. 76 and then to e.g. 74 for the trigger to fire.

The word “crosses” is also used to describe the trigger’s behavior when displayed in the Automation Editor.

If you want your automation to trigger every time the sensor’s value changes and exceeds 25.3, then implement Sir_Goodenough’s suggestion. Be advised that it means the automation will trigger every time the sensor’s value exceeds 25.3 (so for 25.4, 25.5, 25.6, etc).

1 Like