The previous state of a single entity

Hello everyone,

is there actually any possibility to find out the previous state of a single entity?

been looking for this for a while but can’t find anything

Thanks for every response.

have you tried to look at the logbook?

Thank you for your response,
No, I haven’t done that yet, but want to use this in an automation. Can I call data from the log in an automation?

Node Red makes it easy to see all of the attributes of an entity. This is from a debug node (complete message object) querying the current state of a ZigBee light bulb. So to reference the previous state I would simply query msg.data.original_state.

msg : Object
object
_msgid: "0d544e746480e8a1"
payload: "off"
topic: ""
data: object
entity_id: "light.lamp_1_on_off"
state: "off"
attributes: object
supported_color_modes: array[1]
0: "brightness"
off_with_transition: false
off_brightness: 254
friendly_name: "Lamp 1"
supported_features: 40
context: object
id: "01H24GGN0DTBY6EKH89WC6D4CE"
parent_id: null
user_id: null
last_changed: "2023-06-05T00:50:04.429Z"
last_updated: "2023-06-05T00:50:04.429Z"
timeSinceChangedMs: 223023514
original_state: "off"