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.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
Comments
If I can find some time next week, I'll do some tests and see how and if this can be (safely) implemented.
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.
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.
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.
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).
I also need to test Chrome for it's stop behaviour, not sure how that one is doing..
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?
From PlexPy:
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.
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.
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 ;
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..
A manual refresh seems to have sorted it.
Perhaps not, now it's asking for the PIN again. Nup, it died...