Get attributes deep in detail

How do I get an attribute deep in this sensor? I want to get the timerLabel. How do I do this?
I can get {{states.sensor.kitchen_next_timer.attributes.total_active}} which shows “2” but how do I get something deeper?

recurrence: Never Repeat
prior_value: '2020-05-30T10:27:42-05:00'
total_active: 2
total_all: 3
sorted_active: >-
  [["f87c2c79-d811-3b53-a1b9-7bef6f7e82a3", {"alarmTime": 0, "automationId":
  null, "createdDate": 1590852272449, "deferredAtTime": null, "deliveryType":
  null, "deviceName": null, "deviceSerialNumber": "",
  "deviceType": "", "extensibleAttribute": null,
  "geoLocationTriggerData": null, "id":
  "--f87c2c79-d811-3b53-a1b9-7bef6f7e82a3",
  "lastOccurrenceTimeInMilli": 0, "lastUpdatedDate": 0, "musicAlarmId": null,
  "musicEntity": null, "notificationIndex":
  "f87c2c79-d811-3b53-a1b9-7bef6f7e82a3", "originalDate": null, "originalTime":
  null, "personProfile": null, "provider": null, "rRuleData": null,
  "recurrenceEligibility": false, "recurringPattern": null, "remainingTime":
  169000.0, "reminderAppLabel": null, "reminderLabel": null, "reminderSubLabel":
  null, "skillInfo": null, "snoozedToTime": null, "sound": {"displayName":
  "Simple Timer", "folder": null, "id": "system_alerts_melodic_02",
  "providerId": "ECHO", "sampleUrl":
  "https://s3.amazonaws.com/deeappservice.prod.notificationtones/system_alerts_melodic_02.mp3"},
  "status": "ON", "targetPersonProfiles": null, "timeZoneId": null,
  "timerLabel": "Muffin", "tmwNotificationProperties": null, "triggerTime": 0,
  "type": "Timer", "version": "2"}], ["91db0c14-ecac-3ed1-90d6-",
  {"alarmTime": 0, "automationId": null, "createdDate": 1590852282598,
  "deferredAtTime": null, "deliveryType": null, "deviceName": null,
  "deviceSerialNumber": "", "deviceType": "",
  "extensibleAttribute": null, "geoLocationTriggerData": null, "id":
  "--91db0c14-ecac-3ed1-90d6-",
  "lastOccurrenceTimeInMilli": 0, "lastUpdatedDate": 0, "musicAlarmId": null,
  "musicEntity": null, "notificationIndex":
  "91db0c14-ecac-3ed1-90d6-", "originalDate": null, "originalTime":
  null, "personProfile": null, "provider": null, "rRuleData": null,
  "recurrenceEligibility": false, "recurringPattern": null, "remainingTime":
  239000.0, "reminderAppLabel": null, "reminderLabel": null, "reminderSubLabel":
  null, "skillInfo": null, "snoozedToTime": null, "sound": {"displayName":
  "Simple Timer", "folder": null, "id": "system_alerts_melodic_02",
  "providerId": "ECHO", "sampleUrl":
  "https://s3.amazonaws.com/deeappservice.prod.notificationtones/system_alerts_melodic_02.mp3"},
  "status": "ON", "targetPersonProfiles": null, "timeZoneId": null,
  "timerLabel": "Banana", "tmwNotificationProperties": null, "triggerTime": 0,
  "type": "Timer", "version": "2"}]]

Google value_json for info how to use and examples.

  1. Go to JSONPathfinder.com.
  2. Paste the contents of sorted_active into the left pane.
  3. In the right pane, navigate the treelist and click timerLabel.
  4. The correct JSON path will be displayed at the top of the right pane.

So your template will look like this:

 {{states.sensor.kitchen_next_timer.attributes.sorted_active[0][1].timerLabel}}
1 Like

I was looking down that path, when put the template in developer tools I get the error “Error rendering template: UndefinedError: str object has no element 1”

Ha, I was looking at a earlier post by you, Value template to extract JSON value - #14 by 123

Not sure how to overcome this error.

That means the value contained in sorted_active is understood to be a string and not a JSON object. As a result, the template I suggested won’t work. We must convert the JSON string to a JSON object.

Try this:

 {{ (states.sensor.kitchen_next_timer.attributes.sorted_active | from_json)[0][1].timerLabel }}
1 Like

You rock! Thank you!!

1 Like