Simple fan automation

Hey Everyone, not sure why this simple automation is giving me so much trouble. I just want this fan to turn on when the room is above 60, and turn off when it is above 62. Any help would be greatly appreciated

alias: Cure room fan automation on
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    above: input_number.cure_room_templow
    below: input_number.cure_room_temphigh
condition: []
action:
  - type: turn_on
    device_id: 78293e8e119adfc3be273c2be92cc798
    entity_id: switch.cure_room_fan
    domain: switch
mode: single

that doesn’t make sense.

you used above in both scenarios.

which is it?

1 Like

I’m assuming you used the correct input_numbers to turn on and off by above and below values.

So to make it easy without using templates:

alias: Cure room fan automation on
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    below: input_number.cure_room_temphigh
    id: fan_off
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    above: input_number.cure_room_templow
condition: []
action:
  if:
    - condition: trigger
      id: fan_off
  then: 
    - type: switch.turn_off
      entity_id: switch.cure_room_fan
  else:
    - type: switch.turn_on
      entity_id: switch.cure_room_fan
mode: single
1 Like

thanks for helping me through this, doesnt seem like it’s as simple as I thought. That automation still isnt working, but it could be because my yaml indentation is off. Is the format of the code you wrote designed to be copy and pasted into File Editor directly?

when i plug it into HA automations yaml I get:

Message malformed: Unable to determine action @ data[‘action’][0][‘then’][0]

Try this:

alias: Cure room fan automation on
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    below: input_number.cure_room_temphigh
    id: fan_off
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    above: input_number.cure_room_templow
condition: []
action:
  - if:
      - condition: trigger
        id: fan_off
    then:
      - service: switch.turn_off
        entity_id: switch.cure_room_fan
    else:
      - service: switch.turn_on
        entity_id: switch.cure_room_fan
mode: single
1 Like

i was able to pull it off with two separate automations, but i feel that’s not ideal

- id: '1675045867864'
  alias: cure room fan on
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    above: input_number.cure_room_temphigh
  condition: []
  action:
  - type: turn_on
    device_id: 78293e8e119adfc3be273c2be92cc798
    entity_id: switch.cure_room_fan
    domain: switch
  mode: single
- id: '1675045944190'
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    below: input_number.cure_room_templow
  condition: []
  action:
  - type: turn_off
    device_id: 78293e8e119adfc3be273c2be92cc798
    entity_id: switch.cure_room_fan
    domain: switch
  mode: single

Indentation was right, but the service call was incorrect:

2 Likes

hey it worked! but i dont really understand how lol

i think i got it, there’s two triggers, and the first trigger will override the second trigger if met

All the merits to @finity who came with the solution first. :wink:

But basically you have two triggers, the first one for when the temperature is below your helper. Note this trigger has an Id named fan_off.
The other trigger test for the temperature above the other helper. Note this trigger doesn’t have an id, although it would work the same if you had a different id.

Then in the actions it tests if the automation was triggered by the trigger with Id fan_off and, if this is the case, it calls the service switch.turn_off to turn off your fan, otherwise (else) it will call the switch.turn_on service.

Yup.

I copied the original and converted it to a service call instead of a device trigger and forgot to actually call the correct service.

:man_facepalming:

thanks for the correction.

1 Like

This was working last night, but stopped responding today. Think It could have something to do with the fact I’m trying to integrate an Ecowitt sensor with a Kasa smart plug? Should I convert them both over to mqtt?

This shouldn’t be an issue.

Which one is not working properly? The sensor or the switch? What is the problem?
Maybe you should create another topic specifically for the sensor or the switch becoming unavailable.

i believe the problem is with either the automation, or my helpers. I hooked up a binary switch as the trigger and relay works fine. I also tried out this automation, bypassing my helpers and it seems to work fine

alias: cure room fan on
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    above: 61
condition: []
action:
  - type: turn_on
    device_id: 78293e8e119adfc3be273c2be92cc798
    entity_id: switch.cure_room_fan
    domain: switch
mode: single

alias: cure room fan off
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.cureroom_ecotemp
    below: 60
condition: []
action:
  - type: turn_off
    device_id: 78293e8e119adfc3be273c2be92cc798
    entity_id: switch.cure_room_fan
    domain: switch
mode: single