alexjsp / homebridge-plex-sensors

Homebridge Sensors for Plex - a plugin for Homebridge to adds sensors triggered by Plex playbacks.
MIT License
110 stars 10 forks source link

Trigger event on media pause and resume? #10

Closed LP0101 closed 6 years ago

LP0101 commented 6 years ago

Is there a way to trigger a sensor based on media pausing and resuming? I'm trying to use this to replace some python scripts I was using to accomplish the same thing, but it doesn't seem to work.

This is my config right now:

"platforms": [
    {
        "platform": "homebridge-plex-sensors.Plex",
        "sensors": [
        {
            "name": "Media Playing",
            "types": ["movie","episode"],
            "players": ["Luca's TV"],
            "customFilters":
            {
                "event": "media.play"
            }
        },
        {
            "name": "Media Paused",
            "types": ["movie","episode"],
            "players": ["Luca's TV"],
            "customFilters":
            {
                "event": "media.pause"
            }
        },
        {
            "name": "Media Resumed",
            "types": ["movie","episode"],
            "players": ["Luca's TV"],
            "customFilters":
            {
                "event": "media.resume"
            }
        },
        {
            "name": "Media Stopped",
            "types": ["movie","episode"],
            "players": ["Luca's TV"],
            "customFilters":
            {
                "event": "media.stop"
            }
        }
        ]
    }   
    ]

I understand now that the media stop sensor isn't quite needed, as I can just trigger a scene on the "media playing" sensor going off. However, the pause sensor doesn't seem to trigger when I pause media.

alexjsp commented 6 years ago

I think you're configuring this kinda of wrong. The idea is the plugin will make sensors triggered by play / pause / resume / stop, so using custom filters for those events isn't necessary.

The intention is that you would have one sensor:

        "sensors": [
        {
            "name": "Media Playing",
            "types": ["movie","episode"],
            "players": ["Luca's TV"]
        }

And it would be triggered to "on" when playback starts / resumes and "off" when it stops / pauses.

If you really want to run specific separate actions for all four events, you could probably instead do something like this:

        "sensors": [
        {
            "name": "Media Playing",
            "types": ["movie","episode"],
            "players": ["Luca's TV"]
        },
                {
            "name": "Media Active",
            "types": ["movie","episode"],
            "players": ["Luca's TV"],
                        "ignorePauseResume": true
        }

Then you could set your events / scenes to be triggered something like this:

But it's a little bit messing with the system and not quite how it was intended to be used so YMMV

martyjp commented 5 years ago

I created a fork that addresses this issue as I wanted different behavior for my lights when a movie started/stopped and when it was paused/resumed.

I have created a "TriggerType" for each sensor that defines what type of events the trigger responds too. I think this will give you the behavior that you are looking for.

hstamas commented 5 years ago

How do you install a plugin from a GIT fork?

This fork is exactly what I’m looking for as I like to have a separate lighting scene activate when I pause a movie but I can’t find any info on how to install a plugin manually.

martyjp commented 5 years ago

To install from a fork, you add the user’s name prior to the package you wish to install. So you can try the following:

sudo npm install -g martyjp/homebridge-plex-sensors That should install the forked package.

Martin

https://www.pinterest.com/marcospizza https://www.facebook.com/MarcosPizza https://www.twitter.com/MarcosPizza https://plus.google.com/103997922956601937459
Martin J Puls Franchise Owner Marco's Pizza (479) 685-9769 <tel:(479) 685-9769> | mpuls@marcospizza.net mailto:mpuls@marcospizza.net www.marcos.com http://www.marcos.com/

On May 25, 2019, at 10:33 AM, hstamas notifications@github.com wrote:

How do you install a plugin from a GIT fork?

This fork is exactly what I’m looking for as I like to have a separate lighting scene activate when I pause a movie but I can’t find any info on how to install a plugin manually.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/alexp2ad/homebridge-plex-sensors/issues/10?email_source=notifications&email_token=AJI7VVF5PJ6A7UQMDEFBII3PXFL4LA5CNFSM4FIZ5TVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWHT6HY#issuecomment-495927071, or mute the thread https://github.com/notifications/unsubscribe-auth/AJI7VVBN5ROQLVRYEDCSXULPXFL4LANCNFSM4FIZ5TVA.

hstamas commented 5 years ago

excellent - thanks!