Tautulli (PlexPy) Custom Component

your file is here:

config_directory/custom_components/sensor/tautulli.py

Can you post your configuration entry?

@kylerw sure as you indicated I added the file in the directory: config_directory/custom_components/sensor/tautulli.py and my config is this one:

sensor:
  - platform: tautulli
    host: 192.168.1.70
    ssl: false
    verify_ssl: true
    token: 'XXXXXXXXXXXX'
    monitored_conditions:
      - stream_count
      - stream_count_transcode

I have renewed the token just to be sure it’s still valid :wink:

put the port in there on the host

host: 192.168.1.70:8282

I’ve update the OP to clarify.

oki so I changed my config with 8181 as I use that port for web server of Tautulli but no change, still exactly the same problem :frowning: Something else to test ?

the error is on the import of logging - you can try commenting that out to see if it proceeds but I’m guessing other imports will fail as well…

Thank you !! Great work and much appreciated.

I don’t know if it can help but I found that in Tautulli API logs:

2018-02-02 15:36:54 - DEBUG   :: CP Server Thread-8 : Tautulli APIv2 :: API called with kwargs: {'cmd': u'get_server_friendly_name', 'apikey': u'********62'}
2018-02-02 15:36:54 - DEBUG   :: CP Server Thread-8 : Tautulli APIv2 :: Cleaned kwargs: {}
root@serveur:/opt/plexpy/logs#

Thanks for this! Super easy to toss in and now I can dump my plex platform sensor.

1 Like

I am also seeing a TON of errors like the ones above. Good news though is that the sensors seem to be reporting correct info.

2018-02-07 17:54:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 212, in async_update_ha_state
    state = self.state
  File "/config/custom_components/sensor/tautulli.py", line 106, in state
    return self._api.data['response']['data'][self._var_id]
KeyError: 'stream_count_transcode'
2018-02-07 17:54:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 212, in async_update_ha_state
    state = self.state
  File "/config/custom_components/sensor/tautulli.py", line 106, in state
    return self._api.data['response']['data'][self._var_id]
KeyError: 'stream_count_direct_stream'
2018-02-07 17:54:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 212, in async_update_ha_state
    state = self.state
  File "/config/custom_components/sensor/tautulli.py", line 106, in state
    return self._api.data['response']['data'][self._var_id]
KeyError: 'stream_count_direct_play'
2018-02-07 17:54:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 212, in async_update_ha_state
    state = self.state
  File "/config/custom_components/sensor/tautulli.py", line 106, in state
    return self._api.data['response']['data'][self._var_id]
KeyError: 'stream_count'
2018-02-07 17:54:54 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 212, in async_update_ha_state
    state = self.state
  File "/config/custom_components/sensor/tautulli.py", line 106, in state
    return self._api.data['response']['data'][self._var_id]
KeyError: 'total_bandwidth'

interesting - can you hit: http://[[HOST]]:[[PORT]]/api/v2?cmd=get_activity&apikey=[[API-KEY]] and provide the json response?

`{“response”: {“message”: null, “data”: {“sessions”: , “stream_count”: “0”, “total_bandwidth”: 0, “stream_count_transcode”: 0, “wan_bandwidth”: 0, “stream_count_direct_play”: 0, “lan_bandwidth”: 0, “stream_count_direct_stream”: 0}, “result”: “success”}}

Nothing up and running at the moment

if you are using reverse proxy I like I did, I got the above url only working with this:

http://xxxx.lan:port/plexpy/api/v2?cmd=get_activity&apikey=APIKEY

host: xxx.lan:port/plexpy
1 Like

@kylerw Working perfectly. Thanks for putting this together!

Tried this component out over the weekend and got the same errors?

@kylerw thanks for sharing this.

FYI, I am currently on PlexPy. Before I take the trouble to change it to Tautulli, I just want to know can your custom component tell me which user is playing on which media player? The current Plex media component seems to be broken.

I can tell you that it isn’t extracted in the provided script but the data is presented by the Tautulli API JSON response along with a ton of other values. There’s just a for loop in the python script that populates the entity attributes so if you wanted to include the “player” value it should be pretty simple.

1 Like

thanks. by the way, will it work with PlexPy? or must I change to Tautulli?

UPDATE: I just tried this custom component on PlexPy and I can see there is a new sensor created called sensor.tautulli_total. This is what I put in the configuration…

- platform: tautulli
  host: 192.168.1.125:8181
  ssl: false
  verify_ssl: false
  token: 'XXXXXXXXXXXX'
  monitored_conditions:
    - stream_count
    - stream_count_transcode
    - stream_count_direct_play
    - stream_count_direct_stream
    - total_bandwidth

I wonder where is the rest of the monitored_conditions.

Anyway, the attributes in sensor.tautulli_total only show me the username and the media title. It doesn’t show me the media_player. I wonder can the media_player be included in the attributes?

I still haven’t had any luck getting this to work.

Im running PlexPy…is there a difference to Tautulli…I cant see a means to install Tautilli?
secondly, the token that is needed in the config, is this my Plex token, or an api key from PlexyPy?

TIA

Tautulli is the new version of PlexPy. I believe the API is backwards compatible but it is not tested.

Yes the API does come from PlexPy.

Thanks, strange I cant get it to work.?
The sensors appear in my frontend but are never populated with data etc.