Need help setting up a temperature automation

Somewhat new to HA and am trying to set up an automation that occurs when it is cooler outside than inside. My automation is below but isn’t triggering. I am assuming the issue lies in my condition statement syntax being incorrect.

  alias: TEST Baby Room Is Hotter than outside / Turn His Fan On
  trigger:
  - above: '78'
    entity_id: sensor.baby_room_temp
    platform: numeric_state
  condition:
  - condition: state
    entity_id: switch.baby_fan
    state: 'off'
  - condition: template
    value_template: '{{ states.sensor.baby_room_temp | int > states.sensor.dark_sky_temperature | int }}'
  action:
  - entity_id: switch.baby_fan
    service: switch.turn_on
  - data:
      message: baby room is above 78 farenheit! Turning the fan on.
    service: notify.alert_living_room
  - data:
      message: baby room is above 78 farenheit! Turning the fan on.
    service: notify.alert_bedroom
  - service: script.ghvolumereset
  - delay: 00:00:02
  - data:
      message: baby room is above 78 degrees farenheit! I'm turning on his fan! It is cooler outside!
    entity_id: media_player.home
    service: tts.google_translate_say

add quotes to your delay. Remove quotes from 78 in the trigger. Your conditional value template should be this:

    value_template: '{{ states("sensor.baby_room_temp") | int > states("sensor.dark_sky_temperature") | int }}'

Thanks, still doesn’t seem to work with the changes. Here it is now.

 alias: TEST Baby Room Is Hotter than outside / Turn His Fan On
  trigger:
  - above: 78
    entity_id: sensor.baby_room_temp
    platform: numeric_state
  condition:
  - condition: state
    entity_id: switch.baby_fan
    state: 'off'
  - condition: template
    value_template: '{{ states("sensor.baby_room_temp") | int > states("sensor.dark_sky_temperature") | int }}'
  action:
  - entity_id: switch.baby_fan
    service: switch.turn_on
  - data:
      message: baby room is above 78 farenheit! Turning the fan on.
    service: notify.alert_living_room
  - data:
      message: baby room is above 78 farenheit! Turning the fan on.
    service: notify.alert_bedroom
  - service: script.ghvolumereset
  - delay: '00:00:02'
  - data:
      message: baby room is above 78 degrees farenheit! I'm turning on his fan! It is cooler outside!
    entity_id: media_player.home
    service: tts.google_translate_say

Is your baby_room_temp changing? If the answer is no, then it won’t trigger. It will only trigger when it changes state. It will not ‘see that is above 78’ and trigger unless there is a state change.

Im changing the state manually. But it is working now! I forgot to enable the automation!

from below 78 to above?

Sorry yes, it was my fault - I forgot to turn the automation back on! Thanks! All working now.

1 Like