I’ve got a template that only shows a door keypad entry for about a minute then resets to 0. Since the door keypad itself hangs on to the value until a new code is entered.
template_door_code_entered:
value_template: >-
{% if (((as_timestamp(strptime(states.sensor.date_time.state, "%Y-%m-%d, %H:%M")) + 18000 -
as_timestamp(states.sensor.schlage_fe599gr_wireless_door_lock_alarm_level.last_changed))) | abs < 60) %}
{{ states.sensor.schlage_fe599gr_wireless_door_lock_alarm_level.state }}
{% else %}
0
{% endif %}
friendly_name: 'Door Code Entered'
This works fine EXCEPT the adjustment of 18000 seconds has to be made since the sensor.date_time
is in my local timezone and the schlage timestamp is in UTC. This 18000 value “breaks” when daylight savings changes.
Anyone know how to make this template work by forcing everything to local timezone or everything to UTC? I have tried a few things unsuccessfully.
Note: I rely on sensor.date_time
since it updates regularly on it’s own, hence why now()
or utcnow()
are not used in this case.