Companion app (android) > Home Assistant > Automation > setlocation

Attempting to use the action to set home-location

service: homeassistant.set_location
data:
  latitude: device_tracker.sm_g965f.latitude
  longitude: device_tracker.sm_g965f.longitude

… WHAT am I missing here?
Randomly searching through the forum does not turn up anything that comes even close to this.
Why wouldn’t this work as is?

Guessing you need a template for this (but untested):

service: homeassistant.set_location
data_template:
  latitude: "{{ state_attr('device_tracker.sm_g965f', 'latitude') }}"
  longitude: "{{ state_attr('device_tracker.sm_g965f', 'longitude') }}"

Right :wink:

That apparently works. :slight_smile:

So, do you have any idea where I can read up on similar things?
“Template” seems to be the related “term”,
searching on that alone gives a tremendous amount of hits.

A good point to start with is the templating documentation But this is not really easy, templates are very mighty and are hugh expanding the possibilities of automations, but starting from the beginning costs a lot of time to understand how they work and how the syntax is.
It helped me a lot to look how others solved my problem, if you google for ‘homeassistant.set_location’ first link points you to the solution (i only had to adept the attribute part).