Simple temperature-based automation not working, please help!

Got a temperature sensor and I need to make sure that my fan switch is OFF when the temperature is within the (18C, 21C) range, and ON outside of this range. The OFF part works fine, but the ON does not. What am I doing wrong?

Here’s the OFF yaml:

alias: Gabe's fan OFF
description: ""
trigger:
  - type: temperature
    platform: device
    device_id: cce31f7baee6b00cedc9178847d7c01e
    entity_id: 5cf1a7f469c5fee78ef19b2becd6b634
    domain: sensor
    above: 18
    below: 21
condition: []
action:
  - type: turn_off
    device_id: 6005320f572f169d9ae6e355455a8163
    entity_id: d13dbbf26106c1d40ebdc1917b65a0e0
    domain: switch
mode: single

And here’s the ON yaml:

alias: Gabe's fan ON
description: ""
trigger:
  - type: temperature
    platform: device
    device_id: cce31f7baee6b00cedc9178847d7c01e
    entity_id: 5cf1a7f469c5fee78ef19b2becd6b634
    domain: sensor
    above: 21
    below: 18
condition: []
action:
  - type: turn_on
    device_id: 6005320f572f169d9ae6e355455a8163
    entity_id: d13dbbf26106c1d40ebdc1917b65a0e0
    domain: switch
mode: single

From the documentation of numeric state trigger:

Listing above and below together means the numeric_state has to be between the two values.

That can never happen. So you should use two separate triggers, one for above and one for below.

So you are saying that instead of one ON automation I should have two ON automations, right? One for “below,” and one for “above,” right? (The OFF automation can stay the same, right?)

One automation is fine, you can put two triggers in it. And you do not need to change the one that is working. If you change that, potentially very big sudden changes could trigger falsely.

1 Like

Thanks, it’s working! You da man!

1 Like