It appears the main sensor lists the information I’m after but it does not contain a key so I don’t know how to get to the information and how to parse it out.
I can’t seem to reliably get the information I’m after from the created media clients because they seem to always change.
I didn’t write this and I’ve had it as a sensor for a long time but I think it will help
Obviously change the sensor
- platform: template
sensors:
plexuser:
friendly_name: "Plex User"
value_template: >
{%- if not states('sensor.plex_piplex')=="0"-%}
{%- if states.sensor.plex_piplex.attributes -%}
{%- for attr in states.sensor.plex_piplex.attributes -%}
{%- if not attr=="friendly_name" and not attr=="unit_of_measurement" and not attr=="icon"-%}{{attr}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- elif states('sensor.plex_piplex')=="0"-%}
No-one
{%- endif -%}
That does get me a lot closer. Everything after the first " : " is being dropped and I can’t figure out how to escape it.
any idea’s?
- sensor:
- name: "Plex User"
state: >
{%- if not states('sensor.plex_server')=="0"-%}
{%- if states.sensor.plex_server.attributes -%}
{%- for attr in states.sensor.plex_server.attributes -%}
{%- if not attr=="friendly_name" and not attr=="unit_of_measurement" and not attr=="icon"-%}
User: {{attr}}{{"\r\n"}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- elif states('sensor.plex_server')=="0"-%}
No-one
{%- endif -%}
template results
User: RJ - Plex for Windows
User: RJ - Plexamp
Entity data
RJ - Plex for Windows: Mysteries of the Abandoned - s09e48 - Episode 48
RJ - Plexamp: 'Newsboys - Restart: Deluxe Edition - That Home'
Ok… it’s more than a year ago but I’ve done in the developer tool, this and it works showing the user and what it’s watching:
{%- if not states('sensor.plex_server')=="0"-%}
{%- if states.sensor.plex_server.attributes -%}
{%- for attr in states.sensor.plex_server.attributes -%}
{%- if not attr=="friendly_name" and not attr=="unit_of_measurement" and not attr=="icon"-%}
User: {{attr}}{{"\n"}}watching: {{ state_attr ('sensor.plex_server',attr) }}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- elif states('sensor.plex_server')=="0"-%}
No-one
{%- endif -%}