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

Great! Thank you for straightening me out.. I am hoping to get a bit of quiet time later today to fiddle with this and get everything updated! Your help and time is greatly appreciated!

1 Like

Awesome, thank you so much!


update:
@armand - Just wanted to confirm, a week in and this has drastically reduced the number of entries in my System Events, making it much easier to parse out my weekly audits.

Thank you!

Hello, I am new to Hubitat and have a question which might have an obvious answer but I have been searching for hours without solution. So any guidance would be greatly appreciated.

I have installed the driver, added my Roku Ultra device IP, and now I have the Roku device along with all the apps as child devices.

I have been trying for hours to use the power and/or volume buttons for the actual Roku Ultra within automations and button clicks but it is not working. I see the option to "Select a key to add a child switch for, and save changes to add the child button for the selected key" and have tried using that to add the volume up button as a device. But every time I save, it shows up in component devices but when I go back to the devices list, it is not there. Then when I go back into the component devices, it disappears. Am I doing something wrong?

Maybe I am trying to do something that's not even possible. My Roku remote has volume buttons on it and my TV is connected to Sonos. I have to be really close to the TV with the remote in order for it to control the volume on Sonos. I was hoping to setup a rule so that when I click volume up on the Roku remote, it increases the volume on the Sonos. Idea being that Hubitat can recognize the volume up even though the IR does not.

Another use case: I just want to turn the TV off as part of an automation. But the Power button is not accessible as a device. When I try to click it via custom attribute, it does not seem to control the actual power...

Perhaps I am missing the purpose of this driver. Thanks in advance.

Outside of this integration, does your Roku Ultra itself let you power on/off your TV and/or control the volume via the Roku app on your iOS or Android?

If those work, then I imagine this app should work for you as it calls in directly to your Roku to perform these functions. This app cannot do what your Roku cannot do, nor what some Roku remotes can do if they are sending IR blasts to your TV instead of commands through the Roku service and say CEC via your HDMI cable. I hope that makes sense.

For example, on my iOS device I can do the following via the Roku app, and all of these functions work on my RokuTV: e.g. All of the navigation commands, and Volume, and Power on/off.

And here are all the commands I have in HE with this integration:

@SoundersDude,

Thanks. Well said, and better job than I usually do trying to explain this.

@maxwell.poe,
I would like to add that distance from TV should not play a role in the Roku’s ability to control volume. This comes from CEC codes over the hdmi link, or via an IR blaster feature (which I am not aware of a feature for on Rokus).

The set volume command is not supported by Roku, but it is in my driver, because it supports the volume control capability (for up/down).

There is no need to create child devices for the roku, and it sounds like you are not using the Roku Connect app, which helps manage the roku for you.

First and foremost, this driver and integration app were created for Televisions with Roku built-in, but it was discovered that it works great with Roku media players too, so I enhanced it to better support them as well. Support for roku media players is more difficult because the abilities vary by device.

In the case of On/Off and volume, if the app cannot turn on the TV by pressing the on or off buttons in the driver, then volume also will not work. This means you need to first fix your HDMI-CEC issue. This may be as simple as rewriting your system.

Make sure the roku is connected directly to the TV.
Make sure the hdmi port on the TV is NOT the ARC port
Ensure your HDMi cable supports CEC (not all do, but must 1.3 cables should work.
Verify on the TV that HDMI-CEC is enabled,
Make sure the remote power on option is turned on for the TV.

If all the above are addressed, on and off control should work.

For volume control to control the Sonos, connect the Sonia to the HDMI-ARC port of the TV. This option allows the TV to send audio backwards form TV to Sonos while ensuring Video still goes from Sonos to TV. This interface also uses the CEC protocol, so once the TV is working then the Sonos should work, if it supports CEC. If it does not, then you probably will need to use WiFi and find a Sonos driver for Hubitat to control the Sonos,

In both cases, this turns the Hubitat into a powerful remote control, but you will need to use rules to create integrations between them, and neither will perform well using if you use the TV remote in hopes for the HE to respond to the remote, because these devices do not notify HE of changes.

Thank you very much @SoundersDude and @armand for the quick and thorough responses.

My Android App for the Ultra device does not have the options for volume and power like in your screenshot. I assume that is because you have a RokuTV rather than Roku device...

Thanks @armand for the connection advice. I had actually been using the optical adapter and TV's optical digital out port for some reason. I should note that the reason the remote has to be close is because there is a garland in front of the Beam. But I just switched it to use the HDMI ARC and changed the TV setting accordingly. Now the Roku remote works for the volume even with the garland in the way and from any distance. So now I don't need Hubitat! (kidding)

I would still like to be able to turn the TV off in an automation. But since I cannot control volume and power with the Roku android app, that means I will not be able to control them with this driver. Is that correct? (The Power on the physical remote does turn the TV off and I see those Power and Volume commands in HE, they just don't work)

Thanks again.

That is not correct, no. There are several android apps, and many simply don't implement power. Power is available in the ECP protocol on all Roku devices, but whether it works depends on if you have HDMI-CEC. Your android app simply doesn't support it.

Please try with Habitat to see. I have a Roku Premier+ (an older one that looks like the Roku Ultra) and I use it to turn my TV on and off. The power status will always report ON though. This does not hinder automation or Alexa/Google control. If you have CDC working now, then the my driver should work just fine.

Hubitat is not able to control the power nor volume. The TV has HDMI CEC enabled and the Roku Ultra supports it. I am unable to verify if the cable is correct yet. Will try again in the morning.

Yeah, TVs, HDMI-CEC are all very finicky.
I had an old Roku Gen 1 that would not power on/off my old 2015 Vizio tv, but that TV now has an AppleTV and it does power it on and off, and i can even get my Sonos beam with Alexa connected to HDMI-ARC to do the same with voice controls.

Same with my RokuTV, works great powering off (and on if I have sleep enabled), and same with the Sonos Beam, Alexa can power it on and off.

Good news is none of this is a problem with this app, but between Roku and your TV.

I'm updated to Roku Connect v1.2.1 (app)
Roku TV v2.5.0 (driver)

And all the child devices already say "Generic Component Switch". Do I need to do anything else?

Also, I've noticed that my television screen will periodically go black for a second. I don't recall it doing this before installing this driver, and if I disconnect the ethernet, it doesn't blank out. The only command I have created for this was for Alexa to be able to turn it off and on. (So I don't have to dig around for the remote on my desk, or if I step away from the computer for a long time.) Is there a way to determine if your app is sending something to my TV causing this?

Great. Was this before too, or since my comment?

If they work, then you are good.

My driver cannot change the behavior of your Roku. I simply send remote control commands via Ethernet/WiFi to the Roku. Roku supports networked remote controls via a protocol they created called ECP (External Control Protocol). This protocol only has a few actions, the ones I use are:

  • keypress - used to send a remote control key press
  • launch - used to launch an app
  • search/browse - used to search for a movie/tv-show and browse the results if more than one hit.

and a few query command to read the data from the Roku

  • query/device-info - returns the current TV information. I use this to determine if the unit is on or off
  • query/active-app - returns the id and name of the current application that is running on Roku
  • query/apps - returns a list of all the currently installed applications

My driver is not connected to the Roku all the time. It connects just long enough to query and disconnects. Or if sending a keypress (on/off, etc), then it connects just long enough to send the keypress and disconnects. So it is not likely my app or driver could do this.

What I recommend is we take this offline to the GitHub site. Open an issue, and we can walk through some testing w/o flooding this thread with troubleshooting. Aside from that, to research issues, on any driver, you can click the "events" tab to see hub events for the device, and you can enable logging, to see what the driver is doing in the logs.
Random screen blanking, in my experience, usually has to do with a bad HDMI connection, or a bad HDMI cable. It can also be a failing display.

I cannot do anything that a remote cannot do. My driver does not have any low-level access to the Roku. If you only see the issue on the Roku, it may even be that the Roku is slowly dying -- though I doubt that would be the issue, unless it is overheating due to poor ventilation.

[updated: fixed auto-correct mistakes]

1 Like

I'll do that for now, and let you know if I find out anything. Other than that, this handler has been awesome. Thank you very much. :slight_smile:

1 Like

First, thank you for developing this.
Second, just wondering if you have thought about using PowerOn instead of Power for the On command?

Frankly, I don’t recall if I ever tried PowerOn. PowerOff is documented as supported by some Roku TVs, but they ECP protocol documentation does. It define power at all, a
So I just tried Power because it is a key, and it worked. I will try PowerOn, and if it works I will add it as an option. And if it ports over to the premier, I may make it the default. I will get to you

That was quick. PowerOn does not work. Only Power (toggle) and PowerOff. PowerOff works on my Premier and it was just left that way when I released the driver, so there were no issues. What is your use case that you. Need power to not be a toggle? With the non -TV roku devices, the power state reported is always on, so I needed to ignore the state when powering on devices, but I could add an option to enable only pushing power if the is already off, so prevent it from turning off, when you turn it on, if you configure the driver as a TV device.

This is for the RokuTVs. I only ask because Harmony exposed it and it made it so, even if I had manually turned on the TV, it would just call to turn it on. You are polling and should pick that up, but it was a thought. I have premiere as well, but on an old TV that doesn't support CEC, so I need Harmony to turn it on. This question was specific for the RokuTV. Thank you again. I will work with it.

I have the harmony. The harmony uses only IR to turn on the TV, then uses WiFi for other things. it was because Harmony used IR for power that I wrote this driver. I needed a way to turn all my roku TV on. The harmony would control all my rooks, but only if I turned them on manually, or if the TV was in line of sight of the IR blaster of the harmony hub.

Still, I will add more intelligent logic for managing power. I am working on how to detect it the Roku is a TV or not to make the necessary changes automatic if possible.

Yeah, I found a thread that they offered 2 power commands and you can change them in the device Power Settings

Changed from PwrOn

I understand. I have the same harmony setup. I remembered that the harmony only used IR power, but what I forgot what the I did support PowerOn, and I replaced it with just Power for compatibility with older devices. I just updated the driver to allow you to choose you mode. The default mode, once the TV performs a reset, will try to default the system to use PowerOn/PowerOff if the Roku return is-tv=true, otherwise it will refresh the TV state, and then issue the command if not already in the desired state. No matter what, it immediately sets the target state to ensure alexa doesn't time out.
Try it out, and let me know how it works

1 Like

Awesome! Thank you.
One issue: Invalidkey has a misspelling: PoweOn

Changed it to PowerOn and worked brilliantly.

Your code is great to look at. I'm a hacker not a programmer, so really wish the IDE was more interactive for me to screw up and try again. Thank you again for the update. :slight_smile:

1 Like