Node-Red Output Last_changed of Binary Sensor

Tags: #<Tag:0x00007f3281d07ce8>

I have a door binary sensor that I am trying to use in a Node-Red automation. The only output from this entity I am able to get is the state.state (on/off). I am trying to make some node return state.last_changed so that I can use that to check how long ago the door was opened/closed so I can turn the lights off.

Hi, you can do this with a current_state node. It gives you the current state in the payload and beside that a complex data object with all attributes of the entity. I tried it with my door sensor and it even contains a timeSinceChangedMs property which sounds perfect for your case. To figure out which properties are contained in the message, you can use a debug node, which shows the hole message: