Get location state before away

Hi,

I would like to make an automation that gets the state before the “away” state so I can let my google home say: Welcome home from “x” and run other automation’s based on where I came home from.

I thought of storing states in input selects but I’m not sure if this would be the smartest way to do it.

Any ideas?

Thanks

You could use trigger.from_state.state