[Release] Roku Connect integration App and Roku TV Device Handler

I had used a very similar Roku plug-in back on the Vera platform, so am quite familiar with how things should work, but seem to have run into an unexpected roadblock. So thanks for the kind offer of assistance. Here's what I have set up:

• Roku Connect and all things installed via HPM;
• App and Child device properly configured;
• Roku TV properly detected and queried;
• All controls (setMediaInputSource, VolumeUp, etc.) work;
• Full logging turned ON and polling lowered to 10s;

Here's where I get stumped:

• Created a rule that looks like this...

• Yet when I hop among various Inputs (HDMI1, HDMI2, etc.) and linger on each for more than 10 seconds, the Hubitat Log never shows those changes, nor does the Rule fire...

Despite all Logging forms turns on in Rule, nothing manifests, and the local variable remain initialized. Guess I am left wondering what I'm missing when it comes to using RokuTV as a Trigger.

Thanks for any insights.

  • Libra

And on the device do you see the attribute value changing for each app/input?

1 Like

Almost a trick question, as when it switches away from HDMI1 I cannot see my PC/browser. I had expected it would, but I'll have to double-check using some other access method, like my smartphone.

Truth be told, this is exactly why I crafted that test rule, was to check whether those values were changing at all. So far, looks like the answer is, "No" but I'll check tomorrow.

I turned on my tv. I set input to hdmi1, and after a very short pause the application changed to PlayStation 5, and mediaInputSource changed to InputHDMI1

If the attribute values are changing, then it may be an issue in RM for the hub firmware version.

1 Like

If the values don’t change, what about when you click refresh? And, before clicking refresh, take note of the scheduled jobs…. They should change somewhat after each page refresh.

At this point, we are going to take a somewhat methodical shotgun approach to figure out what is different on your system. The log entries look fun and the rule should be fine.

So, what I want to do is rule out RM as the source of your issue. If the attributes are not changing then the issue is with the integration, but if they are changing then the issue is with the rule manager.

After that we can run a series of checks to ensure your system is in fact configured right.

I'm back, with a report on my immediate findings. Good news and bad news:

• The good news is that I was indeed able to watch from a smartphone to see the value of "mediaInputSource" change as different inputs (HDMI1, HDMI2) got selected.

• The bad news is that for whatever reason, my Rule -- with changed Triggers on both mediaInputSource and application -- was never firing.

• So I added one more Trigger: HDMI2 (child device) turns ON

Funny thing, though. While the Rule (app:295) indeed fired (I forgot to turn on Event Logging, so sorry to say it's missing from the Log capture below), instead of stuffing "InputHDMI2" into the variable, I kept seeing "Home" there. The Logs bear this out:

But here's the kicker.... I never once clicked HOME (in fact, I was not holding the remote at any time); I merely alternated between either clicking ON in the "HDMI2" (child dev:291) device, or typing InputHDMI1 into the (parent) device's Set Input Source box during this round of tests.

Is "HOME" kind of a step-through or default? Judging from the Log, you'd think I was viewing the HOME screen of my Roku TV, whereas I can attest it went straight to HDMI1 ("Computer") and stayed there. That's how I am seeing this PC / browser screen, LOL. :slight_smile:

I wonder why the Log entries (made by my Rule) appear doubled?

For next round of testing, I reverted the Rule to something simpler and easier-to-read:

Polling remains set at 10s. But despite my changing mediaInputSource several times (once from child, twice using Roku Remote) with pauses between, the Rule never triggered.

Q: Should I expect child device "HDMI2" to automatically turn ON right after I manually enter "InputHDMI2" in the parent device's Set Input Source box?

Home is the name of the main Roku screen, which the Roku resorts to when you power off the TV, and when you power it on.

Yes. The same code that updates the application and inputMediaSource attributes also turns on the child device and turns off all child devices not associated with the selected app.

I have never used the log action. I will test this on my system to see how it does.

Can assure you that in my case, all of the corresponding child devices are remaining set to OFF regardless. Obviously, more testing on my part is in order.

I truly did not intend to come in here with silly problems, so sorry.

I would like to invite you to DM me on this topic. Is there is a bug in my code, I want to find and squash it. If there is a behavior idiot that I can be reproduced on another system, let’s identify it.
The first step will be to reproduce the issue, which I will try to do in a couple hours.

I just pushed an update to fix a bug that was discovered, where the child input devices fail to change state of "switch" when the input device is activated on the Roku. This bug only affected those users that renamed their input device on their Roku TV, or where the Roku auto-assigned a name for the input device based on the detected attached device.

Also in this update I added the ability to manage the input devices for any Roku device using the Roku Connect app in the same way that apps are managed.

Finally, I added the iconPath for input devices and set it up to reflect the same icon being used on the Roku device, only inverted in colors so as to render well on a white background, making the icon more presentable in Roku Connect app.

2 Likes

Hey, been loving your dh to turn my TV off and on when I leave (I use a 43' 4K model for my computer monitor). One question, though....what's the keyPress command for the OK key (in the center of the up/down/left/right)? When my monitor goes to sleep, I have to press OK to turn it back on, and it would be nice to throw that in my webcore piston to wake up the TV.

Use Key Press (select).

Would that be a string?

Yes...not sure if it is case-sensative or not, but in my RM rule is shown as

 keyPress('Select') on  Roku

"Select" is a parameter with "string" as the type. I'm not familiar with how that would be entered in WebCore.

It is case sensitive, but the case is as shown in the drop-down list on the device handler page. And yes, the Ok button is actually called Select in the API, so Select is the option to use.

Make sure your TV is set to either use Ethernet, or to never power off (sleep is fine). Do this by enabling "Fast TV Start" in Settings -> System -> Power -> Fast TV Start. Also, even if on Ethernet, I do not recommend relying on the Wake-On-LAN feature to power on the TV, because when it is not visible to the network, the Hubitat essentially gets hung up for 10 seconds on every ping request, where the statistics under logging will show excessive CPU time for my device handler, even though it isn't doing anything but waiting for the ping packet to time out. This is an experimental feature that you can turn on, I just don't recommend it.

Have fun!

1 Like

Having an odd problem here. I've had one Roku TV connected to Hubitat with your driver for awhile (43" 4K TV that I use as a computer monitor) so I can tell Alexa to turn it off and on. I finally decided to add my living room Roku TV (55"), but I realized I didn't have the Roku Connect app loaded (Not sure how I connected the first Roku without it.)

Anyways, I installed Roku Connect, and added the 55". Now I'm seeing this on the logs about my 43".

It's doing something over and over again. I'm thinking I should remove the 43" and re-add it with the Roku Connect app.

A second, minor problem is what, while the Volume up/down buttons on the device page work, the commands are reversed when I implement them in Webcore (This was the only reason I added the TV to Hubitat. It's not a huge deal, as I just reversed the programming, but I thought I'd let you know.

[EDIT] Oh, and Happy New Year! :slight_smile:

Roku connect is not required to use the Roku Tv driver. You can install the TV manually in the drivers section, where you have to manually enter the IP Address, or you can use Roku Connect. If you add the device using the Roku Connect app, then the device will be deleted if the app is deleted. Also, the app cannot manage roku devices that were not created through the app. If you still have your original Roku TV device, and did not have a parent Roku Connect app, then you must have setup the TV using just the driver.

What you describe would imply a failure in WebCore. The buttons on the device page are the actual volumeUp and volumeDown methods in my code. So, if the buttons work in the device page, then they must work across the board, unless webcore is doing something else.

Please DM me the details of the piston so I can understand how webcore is integrating to the device. I have not used webcore since it’s original iteration on SmartThings, but I understand the basic concepts…

So I've been using this app for a few years now, and I love it. However, just in the last few days I have started to see this error appear in my logs and I'm not sure why:

The automations I have set up in RM based on which app is in use on the TV are not working anymore, because the status is not being reported to RM. The TV itself on the device page shows the correct app being in use. Nothing has changed with my hub, other than updating to the most recent platform version a few days ago.

Not sure where to start troubleshooting...

What is app number 1565? Sounds to me like this is a RM bug, as I only have 481 lines in the Roku Connect app, and only 1409 lines in Roku TV driver.

If you click on the header of the long entry what device does it select for the filtering?

Are there any other lines of text in the logs?

Today e you can provide the rule in question?