Template items in weblinks

I’m trying to create a weblink that contains the GPS data (or other variables or states) pulled from one of the devices that’s tracked, e.g. “click here to find Bob”. The code that I’m using is this, but it does not render the template into the attributes:
weblink: entities: - name: Find Bob url: https://www.google.com/maps/place/{{ states.device_tracker.pi_something.attributes['latitude']}},{{ states.device_tracker.pi_something.attributes['longitude']}}
(please forgive the lack of tabbing, as no matter what tabs and spaces I put into this post, it’s not showing up in the preformatted text properly)
The URL that I end up with is: https://www.google.com/maps/place/{{%20states.device_tracker.pi_something.attributes[‘latitude’]}},{{%20states.device_tracker.pi_something.attributes[‘longitude’]}}

I’ve tried within quotes, etc…any recommendations for this?

This article may help:

Also, when posting code, just paste the code into the forum editor, then select the entire code block and press the pre-formatted text button as indicated in the image below:

1 Like

The article for showing a map is great (I was looking for this as well), but I’m looking to get a link popped up so that on a mobile the maps app pops up, and on a computer a new tab/window opens. The reason for this is because I want to be able to get directions to that person/device by clicking a link.

It was more for showing how to construct the URL.

It was more for showing how to construct the URL.

The template items I used are working in other locations. I tried the different code that you referenced, and the template items are still not rendered into their values; the URL has “{{ states.device_tracker.pi_something.attributes.latitude }}” instead of a GPS coordinate

1 Like

This is another case of not-knowing if a value can be templated. It looks like URL attribute of weblink does not support templates. You should open this as a feature request.

2 Likes

This is another case of not-knowing if a value can be templated. It looks like URL attribute of weblink does not support templates. You should open this as a feature request.

Thanks, this is the info I was working towards (lack of information and documentation) :slight_smile: This community is wonderfully responsive!

This is something we’ve been struggling with - with values and configuration settings all over the place, what’s a good way to document what’s templateable?

I’m thinking we need to add this info to each platform where the default keys are shown.

2 Likes

You and me both - as you know. And part of the problem is that sometimes an attribute can be templated one place and not another.

1 Like

I’d really like this too, we could make all kinds of RESTful weblinks if templates were honored.