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
  trigger:
    platform: time
    at: '21:35:00'
  condition:
    - 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}}'
  action:
    - service: script.turn_on
      data:
        entity_id: script.check_garage
    - service: input_boolean.turn_off
      data:
        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
  trigger:
    platform: time
    at: '21:30:00'
  action:
    service: input_boolean.turn_on
    data:
      entity_id: input_boolean.check_garage

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

states.sensor.dark_sky_apparent_temperature

should be

states.sensor.dark_sky_apparent_temperature.state

maybe

states.sensor.dark_sky_apparent_temperature.state | int

or even better

states('sensor.dark_sky_apparent_temperature')

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!