Template help - info nested within a value

Hey all,

{{ state_attr('sensor.jamie_s_echo_spot_next_timer', 'sorted_active') }}

im trying to get this value out of a template: , “timerLabel”: “Mouse” (<-- mouse is the name i gave the timer, so i can use this in a card to see what i called different timers around the house)

Ive played around with it loads but cant quite work out how to get into this level of detail, found under “sorted active”

got it

{%- set sorted_active = states.sensor.jamie_s_echo_spot_next_timer.attributes.sorted_active | from_json -%}
{%- set duration = (sorted_active[0][1].timerLabel) -%}
{{ duration }}

There’s an online tool called JSONpathfinder that can help compose the correct JSONpath.

  1. Paste your JSON string into the left hand pane.
  2. It will appear as a JSON object in the right hand pane.
  3. Click on the desired key name in the right hand pane.
  4. The path to that key will appear at the top of the right hand pane.
1 Like

this is so helpful! thanks a lot!!