This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

Homey Plex application - main discussion thread

1141517192025

Comments

  • @MikeOne if you been something tested that is Plex Pass restricted , I have a lifetime plex pass at I could test some stuff for you
    Thanks man. The new PMP player is plex pass only. It is now supported in the current github version.
  • MikeOne said:
    MarkSwift said:
    PHT driver? :-)
    Me not understand what you mean.. :-) 

    I'm still desperate to base flows of PHT / Plex status...
  • MarkSwift said:
    MikeOne said:
    MarkSwift said:
    PHT driver? :-)
    Me not understand what you mean.. :-) 

    I'm still desperate to base flows of PHT / Plex status...
    Started outside of Homey I assume?
  • MikeOne said:
    MarkSwift said:
    MikeOne said:
    MarkSwift said:
    PHT driver? :-)
    Me not understand what you mean.. :-) 

    I'm still desperate to base flows of PHT / Plex status...
    Started outside of Homey I assume?
    Yes, would be a huge feature for me.
  • I understand. You saw my other post about this right? It's a hard one to do really. 

    If I can find some time next week, I'll do some tests and see how and if this can be (safely) implemented.
  • MikeOneMikeOne Member
    edited August 2016
    @MarkSwift  - I've done some research and I might have found a way to do this. However, some caveats;

    PMS doesn't really have a 'stop' state (see your PHT player, it has no stop button really). Determining a hard stop is therefore pretty hard. I could run a combination of a PMS websocket subscription (found one!) and polling the session endpoint. Basically, that might give you triggers for 'start playing' (a session), and 'pause playing' (a session). A hard stop of a watch will not directly result in something within PMS that I can use as a hard trigger, this basically means that a 'stop' will have a delayed (somewhere between 10 and 20 secs I think) trigger, unless you stop with a voice command (using Homey) of course, than I can trigger it straight away (I know when these events happen :-)).

    Some other points;
    1) Only a local PMS will work I think (so no shared servers)
    2) This will only work if you use a single player (at the time). So if you have multiple playing sessions on multiple devices at the same time (if they are never playing concurrently, it's not an issue I think), it will become overcomplicated to track playing states and you'll see unexpected behaviour.

    My suggestion would be to introduce 4 trigger flow cards:

    1) A sessions starts playing trigger (this will NOT re-trigger of you are watcthing a movie, and then using a voice command to start watching another movie - so from play to play status). The question is, should this event re-trigger if the previous state was 'paused' and you are now continuing?
    2) A session pauses card (detection happens when I determine that the previous state was 'playing', and is now 'paused')
    3) A session becomes idle card (will trigger when i'm unable to detect a playing state, or when I haven't received timeline updates from Plex for about 15 - 20seconds). This state will actually be caused by a hard stop (so not a pause) by an external device. This doesn't give me any event from Plex (thanks plex!) and the session data will still show as playing. This is basically an annoying Plex shortcoming. This state might last for somewhere between 20 and 30 seconds.
    4) A session stopped. This state is when I either get a stop event from PMS, or when I detect a stop via voice (homey 'stop watching') or when the session endpoint is showing empty. So this trigger might be delayed, depending on how things were stopped, or is instant when you stop using voice. Not much I can do about this I'm afraid.

    If the above is acceptable, I can start working on the code for it. If anyone has any feedback on the above, please let me know.
  • On a side note to the above, the crappy 'stopped' state seems to be player dependent, Plex Media Player (new driver is ready!) actually causes an immediate stop event which is nice! While PHT keeps the state as playing for a while, even though it is stopped.
  • Sound very promising and would be a great addition. 

    1) I think it should re-trigger if you go from pause to play. Would be good if you pause a movie and lights brighten to get a drink. Then dim again when you unpause. 

    Eventually (no idee when) PHT will be replaced by PMP. Guess the stop event will never be added to PHT as its not actively developed anymore (only bug fixes) as far as I know.
  • Agreed @Sillyjan, thanks for the feedback.
  • @MarkSwift - any feedback from your side maybe?
  • @DieterKoblenz - I think you requested this as well right? Any feedback from you?

    I'm planning to start a PoC to iron out the glitches this evening. Hopefully I'll have a testable (github) version by tomorrow or at least later this week.
  • Yep!  MikeOne said:
    The question is, should this event re-trigger if the previous state was 'paused' and you are now continuing?

    Yes, I do think it should. When I start watching a movie I lower Homey's volume and turn off the led ring. When I pause the movie I want it back to normal (and when I resume I want both dimmed again).
  • Btw, I just read about Plex Media Player and it sounds great. I wouldn't mind waiting for that if it makes the stop event easier to code.
  • Okay, I think that is feasable. I'll start working on that this evening
  • Btw, I just read about Plex Media Player and it sounds great. I wouldn't mind waiting for that if it makes the stop event easier to code.
    I think I can implement something workable, even for PHT. At least you'll have play, pause and stop triggers (immediate if you use Homey to stop and delayed when you use another method). The experience will just be better in PMP. 

    I also need to test Chrome for it's stop behaviour, not sure how that one is doing..
  • @MikeOne This is all sounds good, albeit I still don't understand how PlexPy for example does it with the websocket? I never see a stop delay of more than a second or 2 when using that (I use it now to fire my Hue lights).
  • MarkSwift said:
    @MikeOne This is all sounds good, albeit I still don't understand how PlexPy for example does it with the websocket? I never see a stop delay of more than a second or 2 when using that (I use it now to fire my Hue lights).
    I'm not sure either :-) 

    I found the websocket endpoint in PMS (it looks like the same one PlexPy is using), and that seems to work fine. However, I also found that the reliability of the 'stopped' state depends on the player used. What player are you using?
  • I'm using RasPlex (PHT)... And it seems to have a stop button? :-/
  • I'm digging through the PlexPy code now... it seems to be a known issue... Now I just have to find out how their work-around (if any) functions..

    From PlexPy:

    # Make sure the same item is being played
    if this_key == last_key:
    # Update the session state and viewOffset
    if this_state == 'playing':
    ap.set_session_state(session_key=self.get_session_key(),
    state=this_state,
    view_offset=self.timeline['viewOffset'])
    # Start our state checks
    if this_state != last_state:
    if this_state == 'paused':
    self.on_pause()
    elif last_state == 'paused' and this_state == 'playing':
    self.on_resume()
    elif this_state == 'stopped':
    self.on_stop()
    elif this_state == 'buffering':
    self.on_buffer()
    # If a client doesn't register stop events (I'm looking at you PHT!) check if the ratingKey has changed
    else:
    # Manually stop and start
    # Set force_stop so that we don't overwrite our last viewOffset
    self.on_stop(force_stop=True)
    self.on_start()
    Note the "(I'm looking at you PHT!)" comment :smile: 
    So it seems I might have to investigate the session key (seems to be what they are checking here). Hopefully I can still resolve this.
  • Superb work!
  • MikeOneMikeOne Member
    edited August 2016
    @MarkSwift @DieterKoblenz @Sillyjan - If you guys know how to install using athom-cli, the current version in GitHub (not yet in app-store) support Plex notifications. This means that the Homey app will monitor PMS itself and will trigger flow cards, even if a media session is not started via Homey!

    I've got it working here. Simple flows for playing, paused and stopped that control my hue lighting. Even when I use my main Plex player ) - my samsung smart tv - (not supported by the Homey app) - it works nicely :-)

    Please, whoever knows how to install apps using athom-cli - please test it for me.
  • MarkSwiftMarkSwift Member
    edited August 2016
    Testing now, first thing is it seems to detect RasPlex (PHT) twice? I've not got the statuses working, yet!

    Update 1: Status seems to fire right, I added both the duplicate devices.

    Can we specify a player in the flow, this is awesome, but it means my triggers will fire when any of the 8 players we have in the house play anything :-/

    Great update though @MikeOne ;
  • MikeOne said:
    @MarkSwift @DieterKoblenz @Sillyjan - If you guys know how to install using athom-cli, the current version in GitHub (not yet in app-store) support Plex notifications. This means that the Homey app will monitor PMS itself and will trigger flow cards, even if a media session is not started via Homey!

    I've got it working here. Simple flows for playing, paused and stopped that control my hue lighting. Even when I use my main Plex player ) - my samsung smart tv - (not supported by the Homey app) - it works nicely :-)

    Please, whoever knows how to install apps using athom-cli - please test it for me.
    Not at home this week, will try this weekend ;)
  • MarkSwift said:
    Testing now, first thing is it seems to detect RasPlex (PHT) twice? I've not got the statuses working, yet!

    Update 1: Status seems to fire right, I added both the duplicate devices.

    Can we specify a player in the flow, this is awesome, but it means my triggers will fire when any of the 8 players we have in the house play anything :-/

    Great update though @MikeOne ;
    Hmmm... 8 players... Okay :-)

    You might want to read the readme..
    It was pretty complicated already... 

    Dude... Pfff

    I'll have to let this sink in and see if this is solvable somehow.. The problem is that the socket I'm using doesn't give any data about the player.. And the players itself aren't consistently queryable for meta data. Also, I'm not allowed to do polling of the session endpoint at a high interval (max once every 15 secs). Plus holding all the states of several players, all in memory is pretty complicated as well, as the player logic is detached from the PMS logic. 

    But then.. I do like a challenge. And I do have some ideas on how to do this. Still, PHT is causing a lot of extra logic to handle, so is Chrome when playing using Homey (no session recorded in PMS for that scenario, buggy as hell).

    For now, this solution is pretty good for a straight forward setup....I hope..
  • ...plus.. There seems to be an issue in Homey that prevents actions from triggering when that action is filtered on device... @Emile will need to provide some input on how I could make this work..
  • MikeOne said:
    ...plus.. There seems to be an issue in Homey that prevents actions from triggering when that action is filtered on device... @Emile will need to provide some input on how I could make this work..
    We'll get there, I hope... Right now PlexPy does my lights based on player, but I'll se if I can figure out how I can use this. The issue is the amount of players and friends that use Plex... The lights would be going on and off every 5 minutes during the evening :(

  • MikeOne said:
    But then.. I do like a challenge. 
    We noticed haha  :D Thumbs up already for your work. 
  • MarkSwiftMarkSwift Member
    edited August 2016
    Mine stills shows 0 movies and 0 TV...

    A manual refresh seems to have sorted it.

    Perhaps not, now it's asking for the PIN again. Nup, it died...
  • Anything in the console? Cpu warns? Any hints? 


  • Huge media lib maybe @MarkSwift ?
Sign In or Register to comment.