Hi - looking to extract this timestamp to know when my backdoor was last closed. I am struggling to find a way to get this timestamp as its not an attribute of the zwave sensors.
Is it sitting in the DB and I can pull using SQL or is there another way?
That will only work for the last state change, so is also valid for last opened, not just last closed.
If you want to specifically just know when it last closed, you can either pull it from SQL, or you could create an automation that records the timestamp when the door changes from open to closed in an input_text.
Database stores in UTC and HA appears to then apply a timezone, unfortunately that doesnt seem to happen when accessing the sensor values. Probably a cleaner way but…
Ok not there but close. I have the below configuration but it doesnt populate time nor throw any errors. Any idea what I am doing wrong?
- id: '1589198310461
alias: 'Back Door: Set Time Closed'
description: Sets the time for when the Back Door Was Last Closed
trigger:
- entity_id: binary_sensor.aeon_labs_zw112_door_window_sensor_6_sensor
platform: state
to: closed
action:
service: input_datetime.set_value
data_template:
entity_id: input_datetime.time_back_door_closed
value: "{{as_timestamp(states.binary_sensor.aeon_labs_zw112_door_window_sensor_6_sensor.last_changed) | timestamp_custom('%H:%M', True) }}"