I have the following automation that will not turn on. I can not find anything in the log file to help me out with this problem. If I do a manual trigger of it, I do here my Google speaker tell me the correct temperatures though.
- alias: 'Open Windows'
hide_entity: false
initial_state: 'on'
trigger:
condition:
- condition: template
value_template: "{{ (states.sensor.backyard_temp.state | int) < (states.sensor.bedroom.state | int) }}"
action:
- service: tts.google_say
entity_id: media_player.googlehome6442
data_template:
message: "The outside temp is {{states.sensor.backyard_temp.state | int | string }} and the inside temp is {{states.sensor.bedroom.state | int | string }}. Time to open the windows"
When you manually run an automation, it skips the automation’s trigger and condition and just executes the action. That’s why when you run it manually you’re hearing the announcement.
The problem is what Infineghost identified: the automation lacks a trigger.
trigger:
platform: numeric_state
entity_id: sensor.temperature
value_template: '{{ state.attributes.battery }}'
# At least one of the following required
above: 17
below: 25
My whole goal here is to check when the outside temperature is greater than our bedroom temperature. Then send a message to my google device. But I was advised from above to just first check to see if the outside temp is above (or below) a certain temp so it would trigger the trigger, then have a condition based off of that event.
pvakerlis, thanks. They both were valid. But when I reload my automation and turn that automation off then back on, it does not execute. Do I have to wait till that temp goes below 60 degrees again to reset this?
Yes.The way it’s set now, it has to be over 60 degrees to just trigger the automation and then the backyard sensor has to be higher than the bedroom sensor.
Try to hold a lighter close to the outside temp sensor to check.
I assume if you trigger the automation, it still sounds from the speakers right?
If it works, you can put a checkpoint for the automation to trigger, so it won’t trigger if it has a momentary jump over 60 and goes below that immediately.
like this:
This way, if the temp reaches 60, it will continue to monitor it for the next 2 minutes and if it stays above 60, it will trigger the automation. If not, it was a false alarm and won’t trigger it
And why have a conditon? Do you have an A/C on the bedroom or depend on just windows? If it’s just windows, you don’t need a condition, just the trigger
Ok I just reviewed the code with logic and assuming you want the hass to tell you to OPEN the windows when the temp goes ABOVE 60 then this:
- alias: 'Open Windows'
initial_state: 'on'
trigger:
platform: numeric_state
entity_id: sensor.backyard_temp
value_template: '{{ trigger.to_state.state | int}}'
above: 60
for:
minutes: 2
action:
- service: tts.google_say
entity_id: media_player.googlehome6442
data_template:
message: "The outside temp is {{states.sensor.backyard_temp.state | int | string }} and the inside temp is {{states.sensor.bedroom.state | int | string }}. Time to open the windows"
So if the temp rises above 60 and is consistent for 2 minutes, then it will tell you to open the window.
If you want, you can create another automation that’s just below your current temp, so it will trigger in shorter amount of time. So assuming your current temp is 78 and it’s night so it’s dropping, paste this as an extra automation:
- alias: 'check windows'
initial_state: 'on'
trigger:
platform: numeric_state
entity_id: sensor.backyard_temp
value_template: '{{ trigger.to_state.state | int}}'
below: 78
for:
minutes: 2
action:
- service: tts.google_say
entity_id: media_player.googlehome6442
data_template:
message: "Ok the automation is correct. You just have to wait for the temp to get below 60 and rise again!"
Actually as stated in my previous posts, I just want to know when the temperature outside is either colder or warmer than inside my house. It would then tell me to either open or close the windows.
Someone posted that I had to first have a trigger temperature value to make this work, so I just inserted 60 degress to have it trigger the automation. Logic tells me that I would not need such a boolean test. Just a simple greater than or less then temperature differences between the two temp readings
OK finity (would Buzz Light Year say to you, “Finity, and within!!!”)?
That seemed to do the trick. I am getting the correct responses from my google unit. But as luck would have it, one of my temperture sensors just went out of wack. Go figure.