I have the following automation within an automations.yaml file which works when the template condition is removed, but not when it’s included. What the template should do is check if the garage door was opened in the last two hours before the automation reminds me to take out the trash. If it was opened, I don’t want it to remind me since I already completed the task.
I think I have the formatting correct, however it always evaluates true.
- id: '1596851171131'
alias: Reminder - Trash
description: Reminds User to take out the trash
trigger:
- above: '0'
below: '2'
entity_id: sensor.trash
platform: numeric_state
value_template: '"{{ state.attributes.days }}"'
- at: '18:30:00'
platform: time
condition:
- after: '17:00'
before: '22:00'
condition: time
- above: '0'
below: '2'
condition: numeric_state
entity_id: sensor.trash
- condition: template
value_template: '''{{ (as_timestamp(now()) - as_timestamp(state_attr("binary_sensor.garage_door_42",
"last_triggered") | default(0)) | int > 7200000)}}'''
action:
- data:
message: Please take out the trash if it is not done already.
title: Task
service: notify.user_devices