How to get Entity Previous State? Node Red

Hi! I would like to get an entity previous state based on an input only, and not on an event change. I tried the get history node, but I was only able to get the payload with variable outputs, depending on how many times the state changed on the set amount of time. I also tried the trigger state, but since I want to put the node on the middle of a flow and want it only to be triggered by an input and not from an state change (since I have some validations before), it also doesn’t work.

I would like to make an automation to turn lights on when I arrive home and my ssid changes from not connected to my ssid (since i can change from 2.4G to 5G wifi).

Any light here?