Template sensor from json

i have a sensor with attributes. one of this attribute is metric (json)
Metric

temp: -1 heatIndex: -1 dewpt: -2 windChill: -1 windSpeed: 0 windGust: 0 pressure: 1015.92 precipRate: 0 precipTotal: 0 elev: 157

with state: “{{ state_attr (‘sensor.balkon_wetter’, ‘metric’) }}” i get:
{‘temp’: -1, ‘heatIndex’: -1, ‘dewpt’: -2, ‘windChill’: -1, ‘windSpeed’: 3, ‘windGust’: 0, ‘pressure’: 1015.92, ‘precipRate’: 0.0, ‘precipTotal’: 0.0, ‘elev’: 157}

but how can i access the value (f.e. windSpeed) ?

template:

  • sensor:
    • name: “balkon_wetter_windspeed”
      unique_id: balkon_wetter_windspeed
      #unit_of_measurement: “°C”
      state: “{{ (state_attr (‘sensor.balkon_wetter’, ‘metric’)|from_json()).values.4 }}”
      #this works not
    • name: “balkon_wetter_windspeed2”
      unique_id: balkon_wetter_windspeed2
      #unit_of_measurement: “°C”
      state: “{{ state_attr (‘sensor.balkon_wetter’, ‘metric’) }}”
{{ state_attr('sensor.balkon_wetter', 'metric')['windSpeed'] }}

many many thanks. this works. it can be so easy :wink:

is it possible to add a lovelace card from “sensor.balkon_wetter’, ‘metric’)[‘windSpeed’]” directly? or do i have to create a template sensor for each attribute (metric)->value ?

type: entity
entity: sensor.balkon_wetter
attribute: metric[‘windSpeed’]

this did not work for entity card.