Config-template-card: use of variables with gps coordinates

Hello!

I have a custom config template card and would like to display a weather map. So far it works, but only if I provide fixed gps coordinates. However, my plan was to use variables like this:

      - type: custom:config-template-card
        variables:
          LAT: states['sensor.router_gps_latitude'].state
          LON: states['sensor.router_gps_longitude'].state
        entities:
          - sensor.router_gps_latitude
          - sensor.router_gps_longitude
        card:
          type: iframe
          url: >-
            https://radar.wo-cloud.com/mobile/wr?wrx={{LAT}},{{LON}}&wrm=8&wro=false
          aspect_ratio: 100%

Unfortunately, this does not seem to work, i.e. the map does not show the correct location, despite I found the coordinates from the 2 sensor entities being correct.

I assume that the syntax is not right (though there are no error messages), or I am just not using the variables correctly.

Can somebody please point me into the right direction? Thank you so much for your help! :+1:

It will definitely not work because you are trying to use smth looking like a jijnja template where it is not supported.
Open Docs fo this card, it has examples with a proper syntax.

Btw, there is a dedicated huge thread for this card where these questions can be asked.

Do you refer to this one?

Yes, it does work. All I needed was correcting the url line from:

https://radar.wo-cloud.com/mobile/wr?wrx={{LAT}},{{LON}}&wrm=8&wro=false

to:

${"https://radar.wo-cloud.com/mobile/wr?wrx="+LAT+","+LON+"&wrm=8&wro=false"}

Obviously, the url needs to go into ${...} and the variables into "+...+", respectively.

Solved - by myself. :wink:

If it DOES work - why you asked in the beginning about “does not seem to work”?
Of course it will work after a proper fix.

Have I annoyed you? Then please accept my apologies. This thread can be closed.

No annoying. Just for clarity.

1 Like

This is the dedicated thread:

1 Like