How can I set my darksky sensor location variables with my device_trackers location?

I want to set the longitude and latitude values of my darksky sensor with the attributes of my mobile phone device tracker so I get the the weather nifo for the actual location I’m right in.

I’ve tried this code so far:

- platform: darksky
  api_key: !secret darksky_api
  language: nl
  latitude: {{ states.device_tracker.jeroen.attributes.latitude }}
  longitude: {{ states.device_tracker.jeroen.attributes.longitude }}
  monitored_conditions:
    - hourly_summary 
    - precip_type
    - precip_intensity
    - precip_probability
    - temperature
    - apparent_temperature
    - wind_speed
    - wind_bearing
    - cloud_cover
    - humidity
    - pressure
    - minutely_summary
    - daily_summary
    - uv_index

I got this error:
HA_error

What am I doing wrong?

I don’t believe you can dynamically pull config data like this. Templates can only be applied to certain areas of the configuration.

2 Likes