Output most recent location (i.e. from: 'home') in template result

I can create a notification that announces that a device_tracker has arrived at a location, but I’d really like to be able to notify someone when a device_tracker leaves a location with the name of the location they’re leaving.

“iPhone just left the Apple Store” for example.

Is there a way to hold the previous location as a variable or report it as a zone is changed?

Yep! Easy peazy. You’ll want to use the trigger.entity_id and trigger.from_state in your notification.

The example at the top of that page is similar to what you want.

Ooh…thanks. I’m stuck though.

Take a look at this: https://github.com/arretx/HASSIO/blob/master/automation/IFTTT/track_locations.yaml

The 3 values in the data template are passed to a script, which looks like this:

https://github.com/arretx/HASSIO/blob/master/config/scripts/location_tracking.yaml

All 3 values are inserted into 3 columns of a Google Spreadsheet on a new row every time the script is run.

The first value identifies the {{ states.device_tracker.jons_iphone_7.attributes.friendly_name }}. I’d like the 2nd value to be the “from_state” of the device, but I can’t figure out what the syntax is for the value2 field in the automation.

Ideas?