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?
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