Ok worked all night and here is where I stand can anyone help
configuration.yaml
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
- platform: rest
unique_id: tautulli_activity
name: Tautulli Activity
icon: mdi:plex
scan_interval: 5
force_update: true
resource: http://192.168.1.45:6565/api/v2?apikey=XXXXXXXXXXXXXX&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
template:
- sensor:
- unique_id: plex_session_1
name: Plex Session 1 (Tautulli)
icon: mdi:plex
state: >
{% if (state_attr('sensor.tautulli_activity','sessions')|length >= 1)%}{{ state_attr('sensor.tautulli_activity','sessions')[0].state }}{%else%}off{%endif%}
attributes:
user: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].user }}{%endif%}
progress_percent: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].progress_percent }}{%endif%}
media_type: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].media_type }}{%endif%}
full_title: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].full_title }}{%endif%}
grandparent_thumb: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].grandparent_thumb }}{%endif%}
thumb: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].thumb }}{%endif%}
parent_media_index: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].parent_media_index }}{%endif%}
media_index: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].media_index }}{%endif%}
year: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].year }}{%endif%}
product: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].product }}{%endif%}
player: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].player }}{%endif%}
device: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].device }}{%endif%}
platform: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].platform }}{%endif%}
location: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].location }}{%endif%}
ip_address: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].ip_address }}{%endif%}
ip_address_public: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].ip_address_public }}{%endif%}
local: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].local }}{%endif%}
relayed: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].relayed }}{%endif%}
bandwidth: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].bandwidth }}{%endif%}
video_resolution: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].video_resolution }}{%endif%}
stream_video_resolution: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].stream_video_resolution }}{%endif%}
transcode_decision: >
{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].transcode_decision }}{%endif%}
#- sensor:
# - unique_id: plex_session_2
And here are the errors I am now getting
Logger: homeassistant.helpers.template
Source: helpers/template.py:2629
First occurred: 11:11:08 AM (66 occurrences)
Last logged: 11:11:08 AM
Template variable error: None has no element 0 when rendering '{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].relayed }}{%endif%}'
Template variable error: None has no element 0 when rendering '{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].bandwidth }}{%endif%}'
Template variable error: None has no element 0 when rendering '{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].video_resolution }}{%endif%}'
Template variable error: None has no element 0 when rendering '{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].stream_video_resolution }}{%endif%}'
Template variable error: None has no element 0 when rendering '{% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].transcode_decision }}{%endif%}'
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:197
integration: Template (documentation, issues)
First occurred: 11:11:08 AM (23 occurrences)
Last logged: 11:11:08 AM
TemplateError('UndefinedError: None has no element 0') while processing template 'Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].relayed }}{%endif%}) renders=4>' for attribute 'relayed' in entity 'sensor.plex_session_1_tautulli'
TemplateError('UndefinedError: None has no element 0') while processing template 'Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].bandwidth }}{%endif%}) renders=4>' for attribute 'bandwidth' in entity 'sensor.plex_session_1_tautulli'
TemplateError('UndefinedError: None has no element 0') while processing template 'Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].video_resolution }}{%endif%}) renders=4>' for attribute 'video_resolution' in entity 'sensor.plex_session_1_tautulli'
TemplateError('UndefinedError: None has no element 0') while processing template 'Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].stream_video_resolution }}{%endif%}) renders=4>' for attribute 'stream_video_resolution' in entity 'sensor.plex_session_1_tautulli'
TemplateError('UndefinedError: None has no element 0') while processing template 'Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].transcode_decision }}{%endif%}) renders=4>' for attribute 'transcode_decision' in entity 'sensor.plex_session_1_tautulli'
Logger: homeassistant.helpers.event
Source: helpers/template.py:605
First occurred: 11:11:08 AM (23 occurrences)
Last logged: 11:11:08 AM
Error while processing template: Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].relayed }}{%endif%}) renders=2>
Error while processing template: Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].bandwidth }}{%endif%}) renders=2>
Error while processing template: Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].video_resolution }}{%endif%}) renders=2>
Error while processing template: Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].stream_video_resolution }}{%endif%}) renders=2>
Error while processing template: Template<template=({% if this.state !='off'%}{{ state_attr('sensor.tautulli_activity','sessions')[0].transcode_decision }}{%endif%}) renders=2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 603, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2616, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1304, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 939, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
TypeError: object of type 'NoneType' has no len()
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 715, in async_render_to_info
render_info._result = self.async_render( # noqa: SLF001
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 605, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: object of type 'NoneType' has no len()
What am i missing?