Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95397

Plex template conditions?

$
0
0

@DeanKellham wrote:

Hi everyone,

I’m new to Home Assistant and am after a bit of guidance. I’ve been reading through the wiki and trying to work this out but it’s eluding me.

Basically what I’m trying to create is for the living room light to switch off when I begin a Plex movie on either my living room TV (Android TV app) or living room ChromeCast. I then want the light to come back up to ~25% brightness when the movie finishes or is paused. Finally I only want this to happen after sunset (as why would I want my lights coming up during the day?).

I currently achieve this using Plex’s built-in webhook, which sends playback information in a JSON payload to a PHP script I’ve written, which does the relevant checks (client ID, media type, and time of day). If the checks pass the relevant command is then sent as a webhook to IFTTT, which then either switches off or on the light. It’s become apparent that this could all be replaced by Home Assistant, and would also be kept local (reducing points of failure and latency).

So far I’ve got everything recognised on HA, and can successfully use it’s webhooks in place of IFTTT to keep things local, however would be interested in replacing the Plex webhook and my PHP script with HA’s built-in functionality.

I’m able to bind an automation event to the relevant Plex clients state change, however I’m struggling with the conditions. How specifically do I extract and check the attribute data of a given device in HA? Ideally I’d need to check “media_content_type” from the relevant device to ensure the content being played back is a movie. I’ll also need to use this further when isolating ChromeCast streams, but I suspect doing so will be much simpler once I crack how to use attribute data as a condition.

From what I’ve read on the wiki a template condition of the following should work:
value_template: "state_attr('media_player.plex_plex_for_android_tv_living_room_tv', 'media_content_type') == 'movie'"
But it doesn’t. Can anyone shed any light as to what I’m missing here?

Thanks,
Dean

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95397

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>