Rest url template is malformed, works if statically assigned

I am trying to create a rest API to call weather based on my location. but the issue with this rest sensor is that I get the error that lat/long is malformed.
If I set q=30,-100 for example, in the url, it works and returns valid data
If I set

params:
  q: 30,-100

it returns malformed lat/long

And ultimately I want to use the template to get q dynamically, but it returns invalid lat/long from the api both inline and as a param

is there a workaround for this annoying template bug?

# Location Key from Starlink
- platform: rest
  name: PTH REST Weather Key
  resource: "http://dataservice.accuweather.com/locations/v1/cities/geoposition/search?apikey=xxxxxxxx&q={{ state_attr('device_tracker.pth_starlink_device_location', 'latitude')|round(2) }},0"
  #{{ state_attr('device_tracker.pth_starlink_device_location', 'latitude')|float(default=0)|round(2) }},{{ state_attr('device_tracker.pth_starlink_device_location', 'longitude')|float(default=0)|round(2) }}
  value_template: "{{ value | tojson | truncate(200) }}"
  json_attributes:
    - Version
    - Type
    - LocalizedName
    - GeoPosition
  scan_interval: 5  

If you need to use templates in the resource then you need to use the resource_template: option, not resource: See: https://www.home-assistant.io/integrations/rest/#resource_template

1 Like