How do I parse the json of an attribute of a sensor

Hi all, I’m trying to figure out how to parse the JSON of an attribute from the Tautulli sensor. I’ve set some monitored conditions for each user, and I’d like to create a template sensor for some of the info on a per user basis for inclusion in a dashboard I’m creating to monitor my home server.

sensor.tautulli outputs data like this:

Top Movie: The Avengers
Top TV Show: Downton Abbey
Top User: plexuser
stream_count: 2
total_bandwidth: 5967
stream_count_transcode: 2
wan_bandwidth: 5967
stream_count_direct_play: 0
lan_bandwidth: 0
stream_count_direct_stream: 0
plexuser: {
  "Activity": null,
  "full_title": "",
  "player": "",
  "stream_video_bitrate": "",
  "transcode_hw_encoding": "",
  "quality_profile": "",
  "progress_percent": "",
  "transcode_decision": "",
  "product": ""
}

For instance I’d like to create a template sensor for the “Activity” of user “plexuser”, but I’m completely lost. I’m trying something along the lines of:

sensors:
  -platform: template
    sensors: 
      plexuser_activity: 
      friendly_name: "Plexuser's Activity"
      value_template: "{{ state_attr('sensor.tautulli', 'plexuser') | 'value_json.Activity' }}"

But I’m not having any luck. Tried a few variations of the above to no luck, even tried just seeing if the entire json output remains with the template sensor if I don’t try to grab one of the sub-attributes, and it just spat out my friendly_name with nothing else.

Any help would be appreciated.

2 Likes
{{ state_attr('sensor.tautulli', 'plexuser')['Activity'] }}
1 Like

And that’s it! Thanks @ludeeus!

I am trying to do similar exercise. When I use template in dev tools its ok, but my template sensor does not show anything.

Any ideas?