Automation Data Template not stored

Hi!

I’m trying to use the attributes from an entity to get some geolocation / show it on the map.
For this, I’m using the information provided in How to create a custom device tracker (from GPS coordinates)? and How to display template sensor attributes in HA home page?

When I try to put in the data_template into an action in an automation, it does not get stored.

Before saving:

After page reload:


Any idea why I can’t set this?

Thanks

You are missing the closing " double quotes at the ends of your templates.

Also you can just use data: instead of data_template:

:grimacing: #facepalm
Thank you very much, it’s stored now!

It creates the device_tracker entity now, but I don’t get any location data:
image

Currently the code is:

service: device_tracker.see
data:
  dev_id: Caravan
  source_type: gps
  location_name: "caravan"
  gps:
    - "{{ state_attr('sensor.caravan_location', 'latitude') }}"
    - "{{ state_attr('sensor.caravan_location', 'longitude') }}"

Also tried with

      - "{{ state_attr('sensor.caravan_location', 'latitude') | float | round(7) }}"
      - "{{ state_attr('sensor.caravan_location', 'longitude') | float | round(7) }}"

But the second one is malformatted after saving:
image

What do you get when you type : -

{{ states.device_tracker.see }}
{{ state_attr('device_tracker.see', 'latitude') }}
{{ state_attr('device_tracker.see', 'longitude') }}

Into the template editor ?
Warning ! Redact your response if you are concerned about privacy !

Edit, I’m not too sure about what you are trying to achieve, the post you linked to was taking json inputs from mqtt. Is this a ‘real’ device tracker or are you planning on just manually updating a ‘device’ to act as a mobile ‘zone’ ?

Hi,

honestly I don’t know where I can find this template editor. Do you mean the yaml editor inside automations?

I now changed red node to store each value in a separate value (after converting it to a float) and am now using these individual sensors, which works fine.

You can find it here:

Open your Home Assistant instance and show your template developer tools.

Smi, Tom’s link didn’t work for me, I suppose my configuration is a bit non-standard.

Down the left side of your HA interface you should have some icons.
Right at the bottom should be a disc with the first letter of you ‘logged in’ user name.
That opens options about your account.
In the top box (I suppose it’s a card) you should have an option for 'Advanced Modev
This allows for more options.
When you come out of this (back to you ha home page) you should have more options available down the left side.
Above Supervisor (if you run supervised) should be a hammer icon
That takes you to developers tools
One of the tabs along the top is ‘TEMPLATE’
That is where you find the template editor.
It allows you to test templates and read their output
Useful for all sorts of things when setting up sensors etc. Anything that needs a jinja2 interpreter
In the template box is the standard introduction to jinja2 (as written by Paulus) you can get rid of this as it can be restored by clicking on the ‘RESET TO DEMO TEMPLATE’ at the bottom.
Copy the code from above, Paste it into the window, And read what the output is on the right.

There are two things you need for my-homeassistant links to work.

  1. Either default_config: or me: in your configuration, and
  2. Storing your home assistant URL in your browser. See:
1 Like

Thanks Tom

I don’t use default_config:
And I have no idea what me: brings to the party.

I understand that these links are shortcuts to certain parts of the UI
But Im fairly confident I can find stuff I need.

Still, I’m going to have to convert one of my instances to default_config: just to see what’s going on in the world outside my “bubble”

Thanks for the heads up

It’s not for you. It’s for people like smi who don’t know where things are.

Yes, I understand that too.
And it’s good to know that they exist for those who need them
And it’s a hellofvalot shorter than the explanation I gave to get him to that page.
(hence why I shall trial a default_config instance)

But I guess I’m asking “what does me: do for me ?” (i.e. anything other than the ability to use shortcuts that will save me a few clicks ?)

As a side note, assuming he didn’t have ‘Advanced Mode’ activated, would it still take him to the template editor ?

I appreciate the time spent :+1:

It lets you creat links to places in home assistant when helping others. You personally don’t need the integration installed to create these links.

I don’t know.

Thank you very much for all you support.

As written before, I solved it by creating individual sensors per attribute in Node Red.