Help with automation based on temp

Hi. Just getting started with automation so please forgive me if this is basic. I have successfully written an automation that plays a message to “close the front door” every 15 seconds if left open until its closed.

# Front Door left open
- id:  front_door_open
  alias: 'Front door open'
  trigger:
    platform: time
    seconds: '/15'
  condition:
    condition: state
    entity_id: binary_sensor.front_door
    state: 'on'
  action:
    #play TTS on chromecast audio Den    
    - service: tts.google_say
      entity_id: media_player.den_speaker
      data:
        message: 'The front door is open.  Please close the front door.'

What I would like to do now is add a criteria that the outside temperature is above 65 or below 75. So if it’s 74 outside then the automation will not trigger but if it’s 80 then it will. Is this possible?

I have the dark sky weather sensor setup already:

sensor:
  - platform: yr     
  - platform: darksky
    api_key: 1e60a12a404ff1b094e1b7ca320c3853
    monitored_conditions:
      - summary
      - icon
      - nearest_storm_distance
      - precip_type
      - precip_intensity
      - temperature
      - wind_speed
      - wind_bearing
      - humidity
      - minutely_summary
      - hourly_summary
      - daily_summary
      - temperature_high
      - temperature_low
    units: us

The temperature sensor is: sensor.dark_sky_temperature

I fell like I have all the pieces in place I’m just not sure how to pull it together.

First, be sure to format your code per the the instructions at the top of every page.

Second, you are looking for a numeric state condition.

You will need to have two conditions and make them ‘and’ conditions so both must render true for the action to be executed.

1 Like

Thanks for the reply. Based on the examples you linked to I wrote this automation

# Front Door left open
- id:  front_door_open
  alias: 'Front door open'
  trigger:
    platform: time
    seconds: '/15'
  condition:
    - condition: state
      entity_id: binary_sensor.front_door
      state: 'on'
    - condition: numeric_state
      entity_id: sensor.dark_sky_temperature
      above: 75
      below: 65 
  action:
    #play TTS on chromecast audio Den    
    - service: tts.google_say
      entity_id: media_player.den_speaker
      data:
        message: 'The front door is open.  Please close the front door.'

The current value of sensor.dark_sky_temperature is 48.2 which is below 65 so should meet that condition.

However the automation is not firing. If I comment out the temp condition it works as expected

# Front Door left open
- id:  front_door_open
  alias: 'Front door open'
  trigger:
    platform: time
    seconds: '/15'
  condition:
    - condition: state
      entity_id: binary_sensor.front_door
      state: 'on'
    # - condition: numeric_state
      # entity_id: sensor.dark_sky_temperature
      # above: 75
      # below: 65 
  action:
    #play TTS on chromecast audio Den    
    - service: tts.google_say
      entity_id: media_player.den_speaker
      data:
        message: 'The front door is open.  Please close the front door.'

Sorry I re-read my earlier post and I wasn’t 100% clear, you need an or condition, the way you have it written is an and condition and could never be true.

The way you have it written it would have to be above 75 and below 65.

You need to have the on condition and then an or for above 75 or below 65.

condition:
  condition: and
  conditions:
    - condition: state
      entity_id: 'binary_sensor.front_door'
      state: 'on'
    - condition: or
      conditions:
        - condition: numeric_state
          entity_id: 'sensor.dark_sky_temperature'
          above: 75
        - condition: numeric_state
          entity_id: 'sensor.dark_sky_temperature'
          below: 65
1 Like