Automation not turning on

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"
        

You have nothing that triggers the automation…?

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.

Think of it this way:

  • trigger: look for birds
  • condition: only red birds sitting on the fence
  • action: take photo

What you have is this:

  • trigger:
  • condition: only red birds sitting on the fence
  • action: take photo

I like your way of “noobifying” it. Nice explanation.

But yeah that’s basically it

Thanks for the quick reply. I tried the following but no luck:

  trigger:
   platform: numeric_state
   entity_id: sensor.backyard_temp, sensor.bedroom
  condition: 
     value_template:"{{ (states.sensor.backyard_temp.state | int)  >  (states.sensor.bedroom.state | int) }}"
  action:
  - service: tts.google_say

I like your Robinifying (Bird Analogy) though.

So I think I now have:

  • trigger: numeric_state change
  • condition: only if backyard temp is > than bedroom temp
  • action: tts.google_say

You have to give it a value like example below

  trigger:
    platform: numeric_state
    entity_id: sensor.temperature
    value_template: '{{ state.attributes.battery }}'
    # At least one of the following required
    above: 17
    below: 25

Well how do I go about it then to test if a temperature is greater or less than another, then act on that?

OK, I understand that I just need to check out one temperature if it is above or below a value. But with this code now:

  trigger:
   platform: numeric_state
   entity_id: sensor.backyard_temp
   value_template: '{{ states.sensor.backyard_temp.state }}'
   above: 60

I get the following error message:

Invalid config for [automation]: required key not provided @ data['condition'][0]['condition']. Got None
required key not provided @ data['condition'][0]['entity_id']. Got None

Thanks Infineghost for your help, for it is greatly appreciated!

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.

So now I have the following:

- alias: 'Close Windows'
  initial_state: 'on'
  trigger:
   platform: numeric_state
   entity_id: sensor.backyard_temp
   value_template: '{{ states.sensor.backyard_temp.state | int}}'
   above: 60
  condition: 
     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: "Close Window"

Taras, I tried your code above but get an error of:

Invalid config for [automation]: required key not provided @ data['condition'][0]['condition']. Got None
required key not provided @ data['condition'][0]['entity_id']. Got None.

But now comparing your snippet of code to my last code post, there is nothing different between the two.

Try this

condition:
  - condition: template
    value_template: '{{ (trigger.to_state.state | int)  >  (states.sensor.bedroom.state | int) }}'

If not, then this

condition:
  - condition: template
    value_template: '{{ (states.sensor.backyard_temp.state | int)  >  (states.sensor.bedroom.state | int) }}'

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?

Well it is 78 degrees outside now where I am at.so no need for any more heat please :slight_smile:

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:

- alias: 'Close 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
  condition: 
     value_template: '{{ (trigger.to_state.state | int)  >  (states.sensor.bedroom.state | int) }}'
  action:
  - service: tts.google_say
    entity_id: media_player.googlehome6442
    data_template:
      message: "Close Window"

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

I have no AC and just depending on windows to cool the house. I restarted HA but still no alerts.

So what would the whole code look like if I did it your way and had no conditions then?

Thanks in advanced

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

just make the condition the trigger:

- alias: 'Close Windows'
  initial_state: 'on'
  trigger:
   - platform: 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: "Close Window"
1 Like

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.

1 Like