Bill's Roku Plugin from the old forum

Regarding your Roku plugin from the old forum, if I copy the code and create a new plugin from code, it doesn’t ask me for an IP address for my Roku and therefore gives an error when trying to sync. But if I use the HRP that’s attached in the same post, it asks me for an IP address and sync’s fine.

I’m trying to understand plugins as I’m creating my own and attempting to add functionality to the Roku plugin. Understanding why the above is happening would help me.

It’s because that Plugin in the old forum doesn’t have the “DefaultSettings” defined at the top of the file. During the import process, those are the fields the Designer will ask for. The exact reason it’s failing with the old plugin is that it’s trying to access Settings in the connect function that haven’t been defined yet. If you look at the new Roku Plugin @hotelfoxtrotnovember has shared, his does include that line, so his should work for you.

plugin.DefaultSettings = {
    "Host"  : "192.168.1.1",    // this needs to be an IP address and not a hostname or the Roku won't respond
};

Thank you, I assumed that’s what it was, but the weird thing is your HRP doesn’t have that defined in the script, which really threw me. HFN’s didn’t work for me, but I’m sure it’s on my end - I didn’t have MCE yet. Either way, it’s unimportant - I added the defaultsettings and it worked.

1 Like

Two questions:

  1. I was trying to add the ability to show the active app for the Roku plugin. I added this for OnConnect in lines 50-56 and 70 and added in OnPoll lines 84-89 and 92. It is working well except it keeps crashing the app after 10 seconds or so. Running in the designer doesn’t crash or show errors. Do I have fundamental flaw somewhere?

  2. When I add the plugin, it’s named “Plugin.Plugin”. How do I get it to be named “Roku”?
    Roku.plugin (3.0 KB)

  1. You haven’t defined activeapp. It’s not scoped globally nor have you defined it in either of the 2 functions. Also, it might not be the plugin that’s crashing it. Delete any custom XAML files you have created or modified & just do a fresh import of the Plugin so you can be certain that’s not your issue.

  2. You have to include plugin.Name at the very top.

plugin.Name = "Roku";

I defined activeapp and still crashes. If I remove the plugin, it doesn’t crash. I’m trying to add the plugin to a blank template but I’m having problems. If I add plugin from code or file and add my Roku.plugin, when I synchronize, it says “An error occurred while sending the request.” I’ve triple checked the ip address is the same, and is correct. If I copy and paste the script and the plugin device from one open hrp to another, then it synchronizes without issue.

I did copy and paste the Roku plugin script and device to an empty hrp. When it loaded, I received multiple toast error messages about custom variables from a previous project. Do I need to clear cache from the app or something?

Your Setting Names don’t match. You’re using a mixture of both “HostName” & “Host”. In my original plugin I was using “HostName”, HFN is using “Host”. I actually prefer “Host”. I’ve been using that on new device integrations & Plugins. So update your plugin.Settings references.

Thank you, that is a big help. Still crashes. So if I start deleting things one at a time to find out what is causing the issue, do I start with xaml pages or devices?

Sorry I’m late to the party on this. I took a look at the Roku documentation on the active app query–it looks like it would be pretty straightforward to add support for it to my plugin. I’ll try to take a stab at that tonight.

One thing I would propose is that since the original Roku app used the Media Input Source capability to define the available apps (in device.SupportedInputSources), we should probably use the device.InputSource to store the active one (rather than the device.ActiveApp attribute). That would seem to make the most sense, right? I believe that is how the plugin changes the active app also, although I personally have not used that functionality, so I think that would be the most consistent approach within Home Remote.

This is more a question for @bill: per the Roku documentation, there are some additional available “active apps” that do not seem to be valid as “launchable”: homescreen/Roku, screensaver, and black. Any thoughts on whether it is a problem to set device.InputSource to a value not in device.SupportedInputSources?

Lastly, I wanted to quickly clarify that my Roku plugin does NOT require the MCE stuff–it merely supports the same commands as that plugin so that you can use a common keyboard interface with both devices.

I agree. Instead of ActiveApp use InputSource.

You can go ahead do that. It’s not a problem to set the InputSource to a value not in SupportedInputSources.

@hotelfoxtrotnovember Thank you for the information. It was an ISY plugin that was causing issues, it just happened coincidentally at the same time that I attempted my first plugin edit with this Roku. The active-app added code was straight-forward and is working well.

No problem, Greg. I’ve updated my Roku plugin to include the active app info (via device.InputSource), so thank you for the motivation to do so! I opted not to include support for the screensaver stuff. It would be easy enough to add, I think, if anyone cared, but I think it might make things more complicated for most users. In that vein, Greg, if I’m reading the source code for the plugin you posted above correctly, it will not handle the active app correctly if the screensaver goes on (or, at least, it may give you an unexpected value)–just something to be aware of.

Cool! I’m going to give your plugin another go. I could use that MCE functionality.