I want to create a template sensor that will compare the states (time) of the 2 sensors (Door sensor & motion sensor) to define the occupancy status of my bathroom.
i understand that {{ ((as_timestamp(states.binary_sensor.touch_less_toilet_door_sensor.last_changed)) | int) }}
returns the last changed
state time of the binary sensor .(iresspective it was ON or OFF change.
In the above, how do I template to get the last changed ON
state only?
I basically want to compare the time of ON state of Door senor with ON state of motion senor & decide occupancy status
please help