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

So “on mode” is what confused me. Mode is a thing for the hub, but kit my driver. The power and the switch report if the device is in or off. If the device is not a TV, it will always be On. This is normal.!!you can control on/off of the TV but the Roku will only report that the player is in the on state.

Switch is the preferred mechanism for monitoring power. Power is provided for those that to know more about the power state than simply on or off.

I instead chose to implement volumeUp10 and volumeDown10 as commands. This raises and lowers the volume by exactly 10. I tried to simulate a setVolume, but if the volume is not perfectly in sync, the only way to accurate set the volume is to decrease to 0, and increase to the desired state. To lower volume 100 time (because volume is 0 - 100) take nearly 10 seconds, then it must raise the volume back up. This is a horrible solution. I continue to monitor the ECP protocol, and the system status reports to see if I can query the volume, or set the volume, and if it is ever implemented in the roku, I will add it.

1 Like

That is AWESOME!!!
Thank you!

The command, if you use it in a rule, is a blocking call -- meaning that is blocks until the call is done, then returns. This is so that in a rule you can make the call more than once, if you want to perform a volumeDown20 type of operation.

1 Like

I relatively new to Hubitat and I'd like to try the "dim the lights when the TV plays" rule. I installed the app and all the child devices appear (per directions in the reply to the first comment by photographicnature). I'm using Rule Machine to select a custom attribute of transportStatus for the trigger. So, if the Roku is playing, then set the theater lights to 5. I'm sure it's something simple I'm missing, but I don't know what. I have another rule for 'Pause' to brighten up the room - but that one doesn't work either (it's the same rule just opposite).


Did you do the install manually, or by using Hubitat package manager?

If manually, be sure to install the drivers, but use Roku connect app to install the Tv devices.

Then, use the auto-refresh setting to tune the refresh intervals. If you want the device to react to media playing states, turn on the advanced refresh, and provide a custome refresh for media state that is more aggressive. Roku devices do not offer any mechanism to tell us when things change — we must query the TV, and that slows the hub down, so you want to be careful on how aggressive each refresh option is.

1 Like

I see! So I'm just not waiting long enough when testing it out. :blush: I tried again and waited a tad and the lights dimmed in about two minutes. Totally works! I'll just leave-as is for now (with up to a five minute wait for the lights to change) but if that is bothersome later I'll do your suggestion of the advanced refresh. Btw I used Hubitat Package Manager and also installed the Roku Connect. Thanks for your help!

Hi Guys,
Im using the hubitat package manager to install the "Roku TV integration", but as soon as I click on the package or click "next", nothing seems to happen. It doesnt seem to install the package at all.
Any workarounds to this is definitely appreciated

Once you do that you create a virtual device the. Pick the Roku driver and click save. Then you fill out the IP address etc and click save again

Hubitat Package Manager only installs the software. It does not run the software. To run the software, you have two options (the officially supported method at this time is the app based solution).

App Based
Navigate to Apps section of Hubitat, and add a new User App. Select the Roku Connect application, then once executed and completed the initial configuration, open the installed a Roku connect instance, and start discovery of the roku devices and select the ones you want to install. Each one will create an instance of the a Roku TV device driver specific to the roku device selected.

Manual Device method
If you do not want to install or use the Roku Connect app, that is fine. I wrote the Roku TV device driver to work independently of the Roku Connect app. When you use the Device driver method, you will have to know the IP address of the Roku player, and some features, like the ability to detect IP address changes, will not work.

2 Likes

Thanks for that Armand. I used your App based method via the user app. It worked great.
Except that it only found my one Roku TV and not the other.
Both my Roku TVs are on the same subnet and have reserved MAC to IP. Not sure why the other TV wasnt picked up.

I probably have to go with the manual method, as it gives me the ability to punch in the IP manually.
Regarding the manual method, should I just install the device driver here: hubitat/roku/device at master · apwelsh/hubitat · GitHub , is that all ? or does that have an app accompanying it ?

Once the Tv device driver is installed. You don’t need to install it again. You just use it multiple times. If the Roku is not found, make sure it is powered on, and set for fast start under power preferences. Any other setting will result in an inability to wake it, unless it has a wired connection, but to learn the MAC address (required to wake it up) the Roku must be powered on, and awake. If turned on, and awake, then auto discovery will work.

both tvs are on fast start. The tv which wasnt discovered is on wired ethernet, but on the same subnet as the hubitat and the other tv.

That is interesting. I know some network switches have multicast issues — auto discovery relies in multicast. But it can also be because the TV is not setup to allow remote control access from the network. I cannot lookup the setting right now.

1 Like

For the TV that is not discovered, would you mind checking some settings.

  • Settings/Connection/Setup up connection/Wired
    • even if an ethernet cable is plugged in, it can be set to use wireless, so double checking this is worth the effort
  • Settings/System/About
    • Take note of the software version. My current Roku TV version is 11.0.0 (build 4193-92)
  • Settings/System/Advanced system settings/Device connect
    • Should one set to Enable 'Device connect'
  • Settings/System/Advanced system settings/Control by mobile apps/Network access
    • Should be set to Permissive
    • Default works on my TV, but if it's not working, it may be because that TV defaults to Disabled

Finally, as a last resort, you may consider Settings/System/Advanced system settings/Network connection reset/Reset connection. This will clear the wifi and ethernet settings, and reboot the TV. When it comes back on, it will default to using ethernet DHCP mode if the ethernet cable is plugged in, and it should clear up any other restrictions that may be in place preventing the auto-discovery.

Hi Armand,
You were right earlier. I had to manually enable IGMP snooping on the switch on which the wired roku was on. It discovered right away.

All other settings you mentioned, I had those enabled earlier.

1 Like

IGMP Snooping is a problematic setting. Sometime enabling fixes multicast, and sometimes disabling it fixes multicast traffic. It depends entirely on the switch / router software. Good to hear it is working.

1 Like

Did something change with the app or TLC version of Roku,

I have a rule that has been running for probably a year that automates ambient light with the Switch attribute on the TV. Basically it just turns the TV lights on and off when the tv turns on and off. Recently it quit working. When I look at logging it looks like it turns it off and then seems to think it is active because the TV reports it is on the Home app.

Any ideas. Only idea I have right now is to either resort to what i do for two other tv's that use roku sticks which is power monitoring, or change the automation from switch to the Power state on the TV.

Checking. Nothing should have changed. Power state should only be controlled by the device info status, and media streaming status. If the device is no home, them media state should be stopped, but if media state reports something else, I use that to trigger that the TV is on. Last I checked, my TCL TVs were fine. But again, I will test this out to see.

Notice: If you TV is not setup to use FAST-START then things do not work as intended.

Q: Is the Application "Home" or is the MediaInputSource "Home"? When the TV is in the off state, the mediaInputSource should read Home, and that should trigger setting the App to Home.

Here is the code snippet:

   // only perform updated if the application is different from last check
    if (currentApp != previousApp) {

        if (currentApp == 'Roku') {
            unschedule('queryMediaPlayer')
            scheduleQueryDeviceInfo()
        } else  {
            if (currentValue('switch') != 'on') {
                if (this[SETTING_LOG_ENABLE]) { log.info "turning on, because app is not roku" }
                sendEvent(name: 'switch', value: 'on')
            }

From this, you can see the a couple things must happen. First, the currentApp had to have changed from the previous refreshed state. Next, the currentApp must not be 'Roku', and finally, the switch must not be 'on'.

From your logs, I see that the powerOff keypress was initiated. This in turn resulted in a refresh which would have updated the application and all device info. Then, 10 seconds later, the current application was quarried, and the current application was not "roku", so it set the TV state to "on".

Perhaps your TCL is taking more than 10 seconds to shutdown, and incorrectly reporting Roku as the current app. Try unplugging the TV, to see if the adequately resets the TV and clears up the issue. I know the TCL Roku software is a bit buggy, and my older Roku TV will get very slow, requiring me to reboot the TV. Although sometimes, a reboot is not enough, and I have to unplug it.