Feel free to move this if I got where I posted this wrong.
I would love for a way to figure out which media library is in use on Plex when a device is streaming content, at least content being used at home. For example, if I have music or music videos going on in the backyard, I want to be able to automatically turn on my backyard lights to a different mode (specifically turning my Govee music synch box on, which flashes the lights in time with the music) or for playing either my movies or TV shows library, I really do not want those lights flashing so I want to keep them pretty static and set to a low level, which I have overall whenever the device is playing through a scene, which also dims the lights pretty far.
If you look at the media_player for the Plex client in Developer Tools > States, there should be an attribute called media_library_title
. Using a template, you should be able to extract that and then determine which library is being accessed.
1 Like
I’m new to HA so still trying to get to grips with YAML and automations. I have this but am getting an error Message malformed: extra keys not allowed @ data[‘automation’]
It seems to be fairly similar to what you were trying to do so any pointers or obvious error with what I have would be great
automation:
- alias: Dim lights when Plex starts playing Movies
trigger:
platform: state
entity_id: media_player.plex_plex_for_android_tv_shield_android_tv
from: 'idle'
to: 'playing'
condition:
condition: template
value_template: "{{ state_attr('media_player.plex_plex_for_android_tv_shield_android_tv', 'media_library_title') == 'Movies' }}"
action:
- service: light.turn_on
entity_id: light.livingroom_light_group
data:
brightness_pct: 30
mode: single
It should look like this:
- alias: Dim lights when Plex starts playing Movies
trigger:
- platform: state
entity_id: media_player.plex_plex_for_android_tv_shield_android_tv
from: 'idle'
to: 'playing'
condition:
- condition: template
value_template: "{{ state_attr('media_player.plex_plex_for_android_tv_shield_android_tv', 'media_library_title') == 'Movies' }}"
action:
- service: light.turn_on
entity_id: light.livingroom_light_group
data:
brightness_pct: 30
mode: single
I have not been able to get the Shield TV to show me what library is being played.
Here is it when playing my Music Video library:
Here is the Plex portion, itself:
Overall play/not playing, I have figured out. I need to make these dependent on what library is being played. I do not see that option.
Did you create a template sensor for it like I suggested?
How? I am sorry I am new to templates and sensors. I am trying to give you all the information I can. Here is what I see, which gives me what I think I need. I just do not know how to apply this to a sensor and then once I see that as a status, then I am sure I can do the automation part.
Here is the same information in the states screen and it looks like line12 is what I want:
One thing I noticed is that this screen has a bit of a delay as it switches songs where it looks like it stopped but eventually refreshes with the new song playing.
So, the first thing you need to do is create a template sensor helper (Settings > Devices & Services > Helpers > Add Helper). In the state template, put the following:
{{ state_attr('media_player.plex_in_use_kirks_living_room_shield_tv_pro', 'media_library_title') }}
Name it something like Plex Media Library
. This will create a new entity called sensor.plex_media_library
that you can use in automations and scripts.
In an automation, you could use something like {{ states('sensor.plex.media_library') == 'Movies' }}
in any template condition and then react accordingly.
1 Like
That was it. Thank you so much.
1 Like
ive been trying to get this to work as well with no luck, created the template sensor, tried automation with it…nothing…really want this to work to close blinds for blackout watching