Roku TV device driver

If anyone is interested, the following ST code runs with just a few changes:

Aside from changing a few physicalgraphs, there is a RunEvery1Minute that based on my logs appears to run MANY times a minute (?hundreds?), so every 5 minutes is fine for me. It also has some quirky behavior for determining if the device is on (it will query the TV, but will send an off event and then an on event if the TV is on so the event log will be filled with off and on events. I changed it so that it only updates if the state has changed. All I wanted this device driver to to was to power the TV on or off, and it does that and can change inputs as well, among a few other things. Very handy for these relatively inexpensive Roku TVs (I have Costco's Hisense model, but works for others such as TLC).

Could you possibly post your code with the changes you mentioned above?

This is completely untested, but I've created a fork on github at kxhawkins/hubitat-roku-tv (sorry I cant post a link yet).

I'll try to test tonight and go from there

1 Like

Alright I was able to test this successfully and the latest commit on my fork is functional: GitHub - kxhawkins/hubitat-roku-tv

All buttons are working correctly for me

The readme written by the original author covers installation, but you just need to paste this into Drivers Code, add a virtual device for the Roku, and set these three options:

  • Device IP: Regular IP e.g.
  • Device MAC Address: MAC address with no delimiters (12 alphanumeric characters)
  • Device Network ID: IP and port in hex notation, no 0x prefix, e.g. C0A80178:1F7C


I'm GIT challenged so I'll post my suggestions here.

def parse(String description) {
def msg = parseLanMessage(description)
if (msg.body && msg.body.contains("PowerOn") && this.state!="on") {
sendEvent(name: "switch", value: "on")
if (msg.body && msg.body.contains("PowerOff") && this.state!="off") {
sendEvent(name: "switch", value: "off")

This only causes events when the TV changes state

def queryDeviceState() {
// sendEvent(name: "switch", value: "off")
sendHubCommand(new hubitat.device.HubAction(
method: "GET",
path: "/query/device-info",
headers: [ HOST: "${deviceIp}:8060" ]

The commented out code stops the device driver from constantly sending off and then on events if the TV is on. One thing...I have my TV in the 'fast turn on' mode which presumably means it can be queried even when it is powered off. I haven't tested my changes with the TV in the default state which may require the WOL code to work....


Awesome, thank you. I know nothing about groovy so I'm just stumbling through the translations. I've added a dev branch and committed these changes here: GitHub - kxhawkins/hubitat-roku-tv at dev

I'll play with it tonight and push to master after.

Thanks again

I played with it last night and it was pretty easy to get up and running. The only difficulty I found was when the TV goes to sleep, then I get a "no route to host" error in the logs. I was hoping to drive the TV back lights with it, but even with a 1 minute poll, that's a bit of a delay to get the lights on after the TV is fired up. I'll keep playing with it though.

My time has the option for a 'fast' start which I assume means it never goes to sleep. Perhaps yours does too (I found the option in the Roku Remote app on my phone but I can't recall seeing it on a TV menu).


So here's what I came up with. I had an existing rule using a power meeting. The issue is that sometimes when the scenes got really dark, the power would drop below and the backlights would shut off until the scene got brighter. Now I use the TV being on as one of the conditions:

I augmented that with a refresh rule, so when the TV is on, it refreshes ever 15 seconds. I do this so when I turn the TV off, the backlights don't stay on for almost 5 minutes (depending where in the polling cycle the off command executed). Note that the refresh only occurs when the TV is on so I'm not hammering it throughout the day:

That's awesome @homeauto2112. Glad you got it working for you.

As @drsprange indicated this definitely works better in fast start mode so it can take the power on commands. I've tested the new suggestions and merged everything to master with an updated readme.

I can't contribute any actual development to this effort, but I'm more than happy to maintain the repository if anyone has suggestions.

Thanks all

This is awesome. Glad that I now have some commands available. My only issue is it constantly reporting the TV as "on". Is this expected? I've refreshed the device and it still shows as on. TCL Roku TV with Instant On enabled.

I found I needed the following change to make it detect my TCL TV being "off"

change line 83 to

if (msg.body && ( msg.body.contains("PowerOff") || msg.body.contains("Headless") ) && this.state!="off") {



That didn't work for me. I can't get it to register that the TV is off, though I can use the buttons to turn it on and off.

If you have linux or a Mac, you can use the following curl command to see what the TV is reporting for its device-info. Not sure what the windows equivalent would be to make a low level http call.

curl http://IP_address _of_TV:8060/query/device-info

power-mode is the parameter we are interested in. On mine, it shows this when its powered off


and this when its on


I was looking at the device query responses and indeed Headless does show up eventually. Good catch!

Very interesting. Mine shows DisplayOff.

I --think-- I saw Poweroff immediately after it being turned off, but eventually Headless shows up. Haven't seen DisplayOff. Maybe in the preferences we can enter the proper subtext to search for in msg.body so we don't need multiple versions.

The Windows version is:

curl http://IP_address _of_TV:8060/query/device-info

Windows has had curl, ssh, and a number of other open-source tools for the past couple releases. :slight_smile:

I think that the problem is that when the device go to sleep or off need a WOL wake on lan, the original driver you find do that on line 98 "wake on lan ${deviceMac}", I don't know if hubitat have support the command if they do I could probably change a couple lines to make it work.

Turning the tv on and off from the driver via WOL seems to work fine, this issue was related to detecting if it was on or off.

Download the Hubitat app