I have 2 sensors that need to be subtracted from each other. the first one holds a date_time value, the other holds an integer value in minutes.
When subtracted, this needs to be compared against the current date & time to trigger an automation.
The following gives me the right output, but doesn’t trigger the automation. This makes sense, since the documentation states that a trigger only occurs when a state changes, and now() poses a problem to this.
Question is: how do I make it work?
trigger:
platform: template
value_template: >
{% if (as_timestamp(now()) | int) == ((as_timestamp(states("sensor.calendar_time")) | int) - (states("sensor.travel_time") | int * 60) - 3600) %}
true
{% endif %}
I tried to replace now() with states.sensor.date_time.state, but this seems to have a problem to be converted to timestamp… this gives me “None” as output