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

1235725

Comments

  • MikeOneMikeOne Member
    edited May 2016
    Little update: I'm pretty far with the re-write, got it working locally with a driver and PHT as player. Next step is implementing some flow cards, hopefully including media search.

    On another note, I bough a ChromeCast (v2) Friday... I hacked my way into it and are now (programmatically) able to cast a Plex Media item to it :-) 
    This means I will probably be able to support ChromeCast. This means that even if your main Plex Player is for example your Samsung TV, you could fork out 35 euros for a chromecast and still use Homey on it (just not using the samsung plex app..). It is a start I guess.

    I'll do my best to include chromecast in the driver.
  • @MikeOne Good to hear you're making progress. Would love to have some discussions about best practices and app-architecture to align Kodi and Plex in functionality (and maybe even portability of features). 
  • MikeOneMikeOne Member
    @EvertorN sure! I have been thinking about abstracting some reusable features (like the speech logic to get to one playable item). If you have any ideas once the app is a bit more 'final' - I'm all ears. At least the Kodi API is a breeze compared to the Plex API so back-porting to Kodi should be fairly straight forward.
  • @MikeOne. Theoretically it should be possible to share most of the app.js (and thus speech parsing etc)  if we clearly interface our driver functions... What's your slack? 
  • MikeOneMikeOne Member
    I've started a dedicated slack on https://homeyplex.slack.com

    BTW - before we start this (which in principle I'm fine with) - I need to focus on getting the Plex app ready ASAP. Further  cleanup and interface definitions will have to wait until it's fully functional I guess.
  • Sure, I'll join the channel. Are you sure you don;t wanna use the Homey slack ? We can create a seperate channel there.
  • MikeOneMikeOne Member
    hehehe, I'm never on the athomcommunity slack (only on the homeylabs internal one). I see the Slack now that was made by Emile. Ignore my slack, we'll use that one

  • MikeOneMikeOne Member
    I have submitted the Plex App to the App Store for review. Besides PHT, it also has ChromeCast (v2) support.
    Once it has been approved, I am expecting issues when it's released in the wild and used on PMS's, PHT's and ChromeCasts on OS's and Networks that have never been tested. Please feel free to comment on this thread with any issues you might encounter. Obvious bugs can be reported on the Github issue tracker. I'm inviting contributors as well so feel free to discuss features you'd like to code and submit Pull Requests.
  • JVCS909JVCS909 Member
    MikeOne said:
    @BasPost - yes I noticed. I hope I can get a real Homey soon so I can continue working on the app :-)
    @JVCS909 - I suddenly had an epiphany regarding the Samsung Plex client. I have now directly contacted the main developer and hope to start a dialog with him to explore options (and to see if my epiphany is worth investigating :-)).

    Good to see your progress here.

    Still wondering about your epiphany though, I could use a ChromeCast but i really like the Samsung Plex app and it's development. Any news to share @MikeOne ?


  • jordenjorden Member
    edited May 2016
    I am installing it now, eager to try!

    Pairing with Plex.tv works fine. I can add my Synology NAS as the Media server. Works great.
    I can then add my Sony Bravia AndroidTV as a Chromecast device. It does not recognize the Plex installation otherwise. It also recognizes my Philips Hue there... strange thing :)

    I can say "I want to watch Deadpool" and it starts it over Chromecast. Sadly it's a bit slower to start than via the Plex app on the remote control, however, the coolness factor is very high!
  • jordenjorden Member
    edited May 2016
    WOW, I love what you did...  <3

    I just told Homey "I want to watch Transformers".
    Homey responds:

    "I found 3 matching results for transformers. Which would you like to watch? Age of extinction, Dark of the moon, revenge of the fallen, transformers?"

    I replied: "Age of extinction". And within a second it started playing. This is the greatest app on Homey if you ask me ;)

    I don't even have to turn on my TV, it start automatically when it starts Chromecast'ing.

    Two notes you might want to add to the documentation / settings page:
    1. After pairing, you need to setup a device before you can use the app.
    2. when using flows, the triggers are in the 'app' while the action is in the 'device' that you added.

    Two requests from my side:
    1. Create a pause-function, and add a trigger to that.
    2. Just name the app 'Plex'. Looking at the other apps, 'Homey Nest app' is just called 'Nest' :)

    My appreciation for Homey grew once more, now that I can tell Homey what I want to watch and add 'scenes' to your triggers (for example: set an appropiate volume level for watching movies, use some cool dimmed Hue lights, close the Hallox curtains, if light level > 50 and no rain is expected close the Somfy blinds). 

    Thanks so much for this great app!
  • MikeOneMikeOne Member
    @JVCS909 - unfortunately that was a dead end for now. Samsung simply doesn't allow external connections to it's internal apps it seems. Only approved apps can do casting (like the youtube app). This might all change though once PMP comes out of BETA and is also ported to the televisions. This is the main reason why I decided to right away build in ChromeCast support, so at least there is an affordable option for this use-case. If a developer wants to have a crack it though I welcome it, I might have missed something after all..

    @jorden - Thanks! I really appreciate that. With regards to your feedback, you are totally right, I need to beef up the instructions. I also need to make the App Setting page much more descriptive. BTW, If you paired your server and didn't yet install any players (using the devices page) - and you ask Homey to watch something, Homey should actually give you instructions ("I couldn't find any installed players, please go to the Devices page to install one").

    With regards to your notes:
    1) Agreed
    2) Yes- this is a Homey thing I'm afraid. I'm not sure how to change this. Because the plex app supports multiple drivers, you need to be able to select one in the flow - that is why you get an additional device in the Flow Editor. The trigger however is an App thing and programmatically unrelated to which driver you want to use.

    1) Pause should actually work, however, there might be a bug there with the ChromeCast driver. I'll check that.
    2) I might actually rename it indeed :-)

    - There are some other side-notes. I don't have many setups available to test on so it is possible that other setups encounter issues. Also, the ChromeCast implementation is pretty much a reverse-engineered hack as I'm bypassing the 'real' cast capabilities that the Plex Web player and IOS/Android players have. This also means that PMS doesn't actually report an active playing session for something playing something on the chromecast. This has as a result that the Plex App is unable to perform certain features that DO work in a PHT session (like Automatically select the next episode of a TV show etc). 

    This release is a start - it should be expanded on further.
  • RobinRobin Member
    MikeOne said:

    2) Yes- this is a Homey thing I'm afraid. I'm not sure how to change this. Because the plex app supports multiple drivers, you need to be able to select one in the flow - that is why you get an additional device in the Flow Editor. The trigger however is an App thing and programmatically unrelated to which driver you want to use.
    I didn't really follow this thread so sorry if it is unrelated, but I saw your comment passing by regarding triggering flows on devices instead of apps. Recently Emile build something for this, you can see the documentation on: https://developers.athom.com/library/flow/devices/, and for example in https://github.com/athombv/am.smarter where I use triggerDevice() as well. Hope this helps.
  • MikeOneMikeOne Member
    Thanks @Robin, I saw that in the docs indeed but didn't really understand the scenario I could put that to use (yet) :-)

    What I do need though is a solution for multiple drivers in combination with Flows. I have duplication now in my App in order to show (and handle the events of) the separate device actions. It seems it is not possible (?) to either define 2 identical ID's as flow ids or add mulitple driver sections in a single flow definition.  I guess the way I implemented player types as separate drivers is a slightly different concept then intended.
  • jordenjorden Member
    edited May 2016
    @Robin @MikeOne It is actually not really a problem in this case, but something worth mentioning (I myself didn't understand why I couldn't drag the device to the 'When' column). It's more that I think it is worth to mention to prevent other people asking about it ;)
    Oh and indeed it did tell me that I didn't setup a device yet. It's just that I thought it would be a smoother installation if it would mention it.
  • MikeOneMikeOne Member
    I can create more flow triggers, conditions and actions if people request it, no problem!
  • RobinRobin Member
    Maybe I don't understand you, but perhaps the code snippet below could give some inspiration, it uses the device flow cards (so not the general app cards) and it gives you information on the device that is being triggered, so then you can select which driver should perform an action:

    // app.json
    "action":[
    {
    "id": "off",
    "title": {
    "en": "Turn off",
    "nl": "Zet uit"
    },
    "args": [
    {
    "name": "device",
    "type": "device",
    "filter": "driver_id=<driver_name_here>"
    }
    ]
    }
    ];
    // app.js
    // Turn off
    Homey.manager('flow').on('action.off', function (callback, args) {

    // args contains data on your device, at least the device id,
    // use this to select the correct driver and perform the action
    // e.g.:

    if (Homey.manager('drivers').getDriver('device1').hasDevice(args.device)) {

    // use this driver
    Homey.manager('drivers').getDriver('device1').capabilities.onoff.set(args.device, {
    onoff: false
    });

    }
    else if (Homey.manager('drivers').getDriver('device1').hasDevice(args.device)) {
    // use other driver
    Homey.manager('drivers').getDriver('device2').capabilities.onoff.set(args.device, {
    onoff: false
    });

    }
    });
  • MikeOneMikeOne Member
    Hmm.. I'm already doing something similar I guess. The issue is not multiple devices in one driver, but having multiple devices in multiple drivers. So in order to choose between a PHT player and a Chromecast player I have to have multiple action objects (in app.json), which also means that I have to duplicate my flow trigger handlers (as these are triggered on action ID's - and i can't seem to have mulitple action objects with the same ID). Does that make sense?
  • MikeOneMikeOne Member
    ...but I might actually be able to use some of your example... the hasDevice call might be more efficient than the way I have done it now..

    Thanks!
  • MikeOneMikeOne Member
    edited May 2016
    To expand... this bit:

    "args": [
    {
    "name": "device",
    "type": "device",
    "filter": "driver_id=<driver_name_here>"
    }
    ]

    ..is causing me issues. As I really don't yet know which driver_id I need (as I have more than one driver). So in order for a user to select a specific device (or driver really) in a flow, I have to duplicate that action block. I tried to simply add another 'device' object inside args, but this doesn't seem to work.. Maybe you can have a quick look at my app.json file and give me some advice on how to improve it?
  • RobinRobin Member
    edited May 2016
    Hmm I had a look at it, and I think it is quite ok right now. The approach you took to separate players as drivers is good, as they are indeed separate devices. So in app.json there is not much to do about it you need all the triggers and actions defined for all drivers, personally I would move the Homey.manager('flow').. stuff to the driver it belongs to, to separate concerns. I see that the actions below use the same functionality, for this I would make a call from the driver to the app like: Homey.app.getAutoCompleteOptions(); This way you have all the shared functionality in app.js and the flow triggers and actions (which are driver specific) in their own driver.js

    //driver.js chrome
    Homey.manager('flow').on('action.playitemchrome.selected.autocomplete', function( callback, args ){
           var items = Homey.app.getAutoCompleteOptions();
           callback( null, items );
       });
       
       Homey.manager('flow').on('action.playitemchrome', function( callback, args ){
           Homey.app.playItem({mediaItem: args.selected.mediaItem, command: 'playItem', devices: [args.device]});
           callback( null, true );
       });
    //driver.js pht
       Homey.manager('flow').on('action.playitempht.selected.autocomplete', function( callback, args ){
           var items = Homey.app.getAutoCompleteOptions();
           callback( null, items ); 
       });
       
       Homey.manager('flow').on('action.playitempht', function( callback, args ){
           Homey.app.playItem({mediaItem: args.selected.mediaItem, command: 'playItem', devices: [args.device]});
           callback( null, true );
       });

    Not sure if this helps with your problem, more of an architecture thingie:p
  • MikeOneMikeOne Member
    @Robin  - glad to hear it's quite okay :-) - I hope the app will be App Store approved soon!

    Good advice though, I'm all for separation of concerns so I will implement your advice in a next version as it indeed makes more sense like that - thanks!

    You know what's going on with Emile btw? He hasn't responded to me in a while (maybe he is tired of me - which is understandable :-)). 
  • RobinRobin Member
    Haha. Well most likely being busy:p If you have a question you can always shoot me a message on the forum/slack though.
  • MikeOneMikeOne Member
    Robin said:
    Haha. Well most likely being busy:p If you have a question you can always shoot me a message on the forum/slack though.
    Thanks! Will do.
  • MikeOneMikeOne Member
    Actually.... I do have a question... It's about Zones and Devices in Speech Results Object - can you help with that?
  • RobinRobin Member
    To be honest, I haven't done a lot with speech.  But when a speech trigger fires your app, and devices or zones are mentioned it should return an array with devices that match the spoken criteria

    "devices": [ { id: "abcd" }], // list of device_data objects of founds devices. If one or more zones are mentioned, only devices in those zones are returned

  • MikeOneMikeOne Member
    Well, and that is exactly my question :-)
    If I install a device, let's say in the kitchen, and I tell my app to watch a movie in the kitchen, I get a zone back (with ID and stuff) - but not the device that was installed in that zone. However, If I give my device (player) a friendly name (by renaming it), than I can ask Homey to play on that specific device ("watch on 'chrome' - if I rename my chromecast to just 'chrome') - in that case the correct device is in the devices array.

    So in short - I'm either doing something stupid that prevents Homey from giving the actual device reference when a zone is detected in speech - or there is a bug. I'd like to find out which :-)
  • RobinRobin Member
    Hmm well, that smells like a bug to be honest. But I do not know the very specifics of the code behind this.
  • MikeOneMikeOne Member
    Okay no probs.. I'll wait for @Emile ; to respond to that one...
Sign In or Register to comment.