Automation to alert garage door left open using temperature difference

Does anyone know why this automation never runs? I clicked on the paper clip for automation.check_garage_door and Last Triggered is Never. Thanks in advance.

- alias: Check Garage Door
    platform: time
    at: '21:35:00'
    - condition: state
      entity_id: input_boolean.check_garage
      state: 'on'
    - condition: template
      value_template: '{{states.sensor.dark_sky_apparent_temperature+4 > states.sensor.garage_temperature}}'
    - service: script.turn_on
        entity_id: script.check_garage
    - service: input_boolean.turn_off
        entity_id: input_boolean.check_garage

I do have the input_boolean sets to on in another automation at 21:30.

- alias: turn on garage
    platform: time
    at: '21:30:00'
    service: input_boolean.turn_on
      entity_id: input_boolean.check_garage

Your second condition will never evaluate to true, because of the wrong states.


should be



states.sensor.dark_sky_apparent_temperature.state | int

or even better


same for states.sensor.garage_temperature

You can check your templates in Dev Tools/states.
Just copy and paste the whole template {{ ... }}

1 Like

states are always strings. you can’t add a number 4 to a string and get the answer you think you will. you have to convert the string to a number first using “int”.

And you can’t compare the two strings and get the result you expect either for the same reason.

And as VDRainer said, your syntax for the states is wrong.

using your original format the template should look like:

value_template: '{{ states.sensor.dark_sky_apparent_temperature.state | int + 4 > states.sensor.garage_temperature.state | int }}'

And again as VDRainer said it’s best to use the alternative syntax which is less prone to errors (remembering to also change the type of quotation marks):

value_template: "{{ states('sensor.dark_sky_apparent_temperature') | int + 4 > states('sensor.garage_temperature') | int }}"

1 Like

Thank you both!