Trigger based on previous state

I have a device_tracker entity and trying to trigger an action when I leave a location - let’s call it ‘mall’.

On state change I want to pass the previous state to the next node. I have read that this is stored in payload.old_state.state. I have tried passing this, but my debugging shows that it is passing as ‘undefined’ rather than the actual location string.

This is the setup for my state node:

How do I get it to pass the old state string?

image

Use a debug node to output msg.data and you’ll see at the event data.

msg.data.old_state.state will contain the previous state of the entity

1 Like

That worked. Thank you!