Tautulli REST End Point and custom-button-card

I’m taking this one piece at a time…so trying to get just the REST part to work without error, no other info entered yet…this is what I have in my configuration.yaml:

sensor:
#Tautulli Plex_Sessions
  - platform: rest
    unique_id: tautulli_activity
    name: Tautulli Activity
    icon: mdi:plex
    scan_interval: 5
    force_update: true
    resource: http://192.168.1.105:8181/api/v2?apikey=<KEY>&cmd=get_activity
    method: POST
    headers:
      Content-Type: application/json
    value_template: "{{ value_json.response.result }}"
    json_attributes_path: "$.response.data"
    json_attributes:
      - stream_count
      - sessions
      - stream_count_direct_play
      - stream_count_direct_stream
      - stream_count_transcode
      - total_bandwidth
      - lan_bandwidth
      - wan_bandwidth

But, the log is showing me this error:

Logger: homeassistant.helpers.template
Source: helpers/template.py:2758
First occurred: 12:52:56 PM (253 occurrences)
Last logged: 1:14:05 PM

Template variable error: 'value_json' is undefined when rendering '{{ value_json.response.result }}'

The STATE shows UNKNOWN when I go look at the Entity State info, while something is playing in Plex and showing up as playing in Tautulli.

Any idea what I messed up?

It’s set up exactly how mines is, minus the API key for Tautulli. You do also need the template though. See here for example: Tautulli REST End Point and custom-button-card - #130 by cm86

I had all that in but thought I needed to ensure the REST part was working first…I’ll add it back in and test.

I see the API calls working in the Tautulli API logs…but HA just can’t store anything due to the error of the json being undefined. I get the same error even with the template stuff entered. Not sure how to get it defined or why it isn’t.

Well, I now see why it wasn’t working. I am doing proxy redirects with URL Base/root reverse proxy info…it didn’t like being pointed to the local IP at all…as soon as I switched it to the external URL base/root name all started working…doh.

:loudspeaker: Tautulli Active Streams – Now Available for Home Assistant! :clapper:

:rocket: Real-time Plex Stream Monitoring in Home Assistant!

I’m excited to introduce Tautulli Active Streams, a Home Assistant integration that brings live Plex stream tracking from your Tautulli server into Home Assistant. View detailed session data in dashboards and custom cards, making it easy to track what’s currently playing!

:link: GitHub: Tautulli Active Streams


:small_blue_diamond: Features

:white_check_mark: Monitor Active Plex Streams – See who’s watching and what they’re watching.
:white_check_mark: Custom Sensor Count – Choose how many active streams to display.
:white_check_mark: Adjustable Scan Interval – Set how often HA updates stream data.
:white_check_mark: Detailed Session Attributes – Each active stream sensor provides:

  • :film_strip: Media Title & Type (Movie, TV Show, etc.)
  • :bust_in_silhouette: User (Who is watching)
  • :earth_africa: IP Address & Device
  • :tv: Playback Progress & Quality

:inbox_tray: Installation

:one: Install via HACS or manually from GitHub.
:two: Add the integration in Home Assistant → Settings → Devices & Services.
:three: Enter your Tautulli details (Host, Port, API Key).
:four: Display real-time stream data in Lovelace cards!


:link: GitHub: Tautulli Active Streams

Give it a try and let me know what you think! :rocket:

3 Likes

image

What’s a card that you recommend using in order to view the active streams? I’ve got the sensor set up now, just curious to know how to move forward…

Edit: Nvm. I can use the same setup I have as a card. This sensor eliminates the need for the coding in sensors.yaml and templates.yaml. Thank you for simplifying it!!!

2 Likes

@ronmramsayii What did you modify the image yaml to for the card? Thanks!

@richardbeetwell thanks for this! I happened to be looking for taitulli in ha tonight and came across this.

The card in the post instantly worked which was AMAZING DETAIL on your end.

What would you recommend changing this line of code to?

card:
              type: picture
              image: |
                [[[
                  if (states[variables.entity].attributes.grandparent_thumb != ''){
                    return "https://[TAUTULLI SERVER:PORT]/api/v2?apikey=[YOUR API KEY HERE]&cmd=pms_image_proxy&img=" + states[variables.entity].attributes.grandparent_thumb + "&amp;width=300&amp;height=450&amp;fallback=poster&amp;refresh=true";
                  } else {
                    if (states[variables.entity].attributes.thumb != ''){
                      return "https://[TAUTULLI SERVER:PORT]/api/v2?apikey=[YOUR API KEY HERE]&cmd=pms_image_proxy&img=" + states[variables.entity].attributes.thumb + "&amp;width=300&amp;height=450&amp;fallback=poster&amp;refresh=true"                    
                    } else {
                      return states['sensor.' + states[variables.entity].attributes.user + '_session_thumbnail'].state
                    }
                  } 
                ]]]

replace with this

          image: |
            [[[
              return states[variables.entity].attributes.image_url;
            ]]]
1 Like

What did the url look like ? Can you give an example

image: |
        [[[
          if (states[variables.entity].attributes.grandparent_thumb != ''){
            return "https://tautulli.xxxxx.dev/api/v2?apikey=xxxxxxxxxxxx&cmd=pms_image_proxy&img=" + states[variables.entity].attributes.grandparent_thumb + "&amp;width=300&amp;height=450&amp;fallback=poster&amp;refresh=true";
          } else {
            if (states[variables.entity].attributes.thumb != ''){
              return "https://tautulli.xxxxx.dev/api/v2?apikey=xxxxxxxxxxxx&cmd=pms_image_proxy&img=" + states[variables.entity].attributes.thumb + "&amp;width=300&amp;height=450&amp;fallback=poster&amp;refresh=true"                    
            } else {
              return states['sensor.' + states[variables.entity].attributes.user + '_session_thumbnail'].state
            }
          } 
        ]]]

I’m about to try it the way you said though… I just never changed it from the setup before…

Edit: Yeah, the way you suggested works lol. Eliminates the need for the url and api key. Keeps on getting better!

Perfect! Great to hear it’s working fine for you

There’s one issue I just found. When accessing things remotely, I get a blank screen for the poster. Reverting back to the way I posted above fixes it.

I will look at this. Also I see that you use a reverse proxy. I will add setup for that too.

Yep I do. When I set up the sensor though, I used my local IP and port for Tautulli. I’m not sure what needs to be done in order to get things to work remotely without the need of reverse proxy, but it works with it. Currently those who aren’t using reverse proxy or possibly nabu casa to access via cloud, might have issues with the poster showing up when connecting remotely. I don’t use nabu casa cloud, so I couldn’t test to verify…

Will have an update shortly for this. So you can use reverse proxy / ssl connections

1 Like

Is it possible to do an if/else type of setup? If local IP doesn’t work, then use ssl link? I like the idea of when I’m connected locally, it uses local IP, and then if I’m connected remotely, it uses the reverse proxy url?

i have now posted an update to handle reverse proxy which is now working externally.

How should the coding for the card work? Is it the same as you suggested?