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

change line 25 for Roku TV to

definition (name: "Roku TV", namespace: "apwelsh", author: "Armand Welsh", importUrl: "https://raw.githubusercontent.com/apwelsh/hubitat/feature-switch/devices/roku-tv.groovy") {

then when you use import on the driver it will always import the latest updated file from github.

for Roku App line 22 would be

definition (name: "Roku App", namespace: "apwelsh", author: "Armand Welsh", importUrl: "https://raw.githubusercontent.com/apwelsh/hubitat/feature-switch/devices/roku-app-child.groovy") {

1 Like

wow! That is cool. Thank you for that.

I merged the feature-switch branch back with the master branch.

Please update.

1 Like

I'm getting a ton of these but I'm also getting a ton that are successful. My DNI is unique and is not used anywhere else.

dev:1892019-07-07 04:12:51.697 pm errorFailed to create child device with exception: java.lang.IllegalArgumentException: A device with the same device network ID exists, Please use a different DNI

Thanks for reaching out. Are you using the new device handler from GitHub? This was an issue in the old driver because of updates in the way devices are created in the hub. If you have the latest hub firmware and the latest DTH, let me know, and I will try to reproduce and fix the issue.

Yeah, I just installed this today from github... updated hub yesterday.

Okay. I wonder if there is an issue with the child disconnecting from the parent. Can you seek for all you devices, and delete all the child devices manually, then rerun the update manually.
I will double check later in the week to see if I can identify an issue in the DTH, though I suspect Italy be as simple as wiping out the children drives manually. I may also add a local state variable that keeps track of all the children that I add so I can remove them if necessary, when things change

Ok, I'll start that right now and let you know. Thanks!

So I removed them all, then saved the preferences and it did a refresh but it did the same thing again:

[dev:316]2019-07-07 08:45:08.517 pm debugCreated child device: Nickelodeon (livingRoomRoku-52838)

dev:3162019-07-07 08:45:08.474 pm errorFailed to create child device with exception: java.lang.IllegalArgumentException: A device with the same device network ID exists, Please use a different DNI

dev:3162019-07-07 08:45:08.418 pm debugCreated child device: CBS All Access (livingRoomRoku-31440)

dev:3162019-07-07 08:45:08.403 pm errorFailed to create child device with exception: java.lang.IllegalArgumentException: A device with the same device network ID exists, Please use a different DNI

dev:3162019-07-07 08:45:08.343 pm debugCreated child device: Plex (livingRoomRoku-13535)

dev:3162019-07-07 08:45:08.239 pm debugCreated child device: Spotify Music (livingRoomRoku-19977)

dev:3162019-07-07 08:45:08.087 pm debugCreated child device: YouTube (livingRoomRoku-837)

dev:3162019-07-07 08:45:07.539 pm debugCreated child device: VUDU (livingRoomRoku-13842)

dev:3162019-07-07 08:45:07.375 pm debugCreated child device: Hulu (livingRoomRoku-2285)

dev:3162019-07-07 08:45:07.294 pm debugCreated child device: Lifetime (livingRoomRoku-35058)

Thank you for the information. I will see if I accidentally introduced a logic error. I assume the child devices did get created, and that the issue is just that the device is being created twice — once it works and once it reports the error?

I bet they did. There was a lot of them and I don't even remember having that many installed on my Roku. LOL.

armand,

Any way to make this so I can dim the lights when Hulu or Netflix is activated? Kinda like what @jebbett did with plex webhooks media scene app?

I've been trying to get it to work by setting channel = Hulu or application = Hulu to no avail... I even tried the numeric channel value that the child app represents in the device ID, but that didn't work neither.

1 Like

yes. This is why I converted the child devices to standard toggle switches. If you set the refresh to every 1 minute, you can use the Roku remote to launch an app, and the child device will turn on within the 1 minute refresh interval (note you can get more aggressive, but it might be a bit much to ping the status of the roku every 20 seconds or so. Because of this, I made this a value in minutes but I can adjust this so that another toggle can determine if the refreshInterval is in minutes or seconds). Then just create a simple lighting rule to turn on and set level your light whenever the Hulu child device is turned on. If you use Hubitat to command it, the rule will trigger immediately, and if you use the roku remote, it will trigger at the next refresh interval.

1 Like

This has been addressed. There are times when the refresh interval and the commanded load can overlap. The child devices do get created, but the log is polluted with erroneous errors. I changed the logging for this to generate a warning level log, and to perform an additional check. I was able to reproduce, and after making my changes, the issue went away.

Please update and see if the issue is resolved. To update, just open the device hander for
Roku TV and click the import button to import the latest version.

I added a new preference item for refresh units. Use this to set the refresh units to Seconds or Minutes. The default is Minutes, and any value other than Seconds assumes Minutes. This ensures that updating the DTH will not result in changing the refresh interval.

I set my Bar TV to refresh every 15 Seconds. I then created a Smart Lighting rule to turn-on Dining Room Light when "Bar TV - HBO Now" turns on, and I set the "Turn off lights when turned off". This works. When I turn on HBO Now, the light turns on. When I go back to the home screen, or any other app, the light turns off.

However, there is a current issue in the Smart Lighting app that is causing each of my Roku-App switches to appear twice, even though there is only one.

Notice: Is is not advisable to refresh more than every 30 seconds. In my test I set the refresh to every 15 seconds, and it worked okay, but this will impose more of a strain on the network stack, and the system (though parsing the current app is not too intensive)

Update: I have also added the option to poll the current Application status vs the current TV status separately. Current application status is considerably less chatty. And I disable the application status schedule when the TV is in the Off state.

Recommendation: Update to new DTH, and set refresh interval to 1 minute, and application refresh interval to 5 seconds. Then you can create rules that are somewhat responsive to remote control triggered events.

Armand, I wanted to let you know that there may be a bug in the "set volume* code.

Here is my error.

groovy.lang.MissingMethodException: No signature of method: user_driver_apwelsh_Roku_TV_290.setVolume() is applicable for argument types: (java.math.BigDecimal) values: [12] Possible solutions: setVolume() (setVolume

You are correct. The function is not supported by Roku. only volume up & down are, so I never actually clicked it and looked at the logs. I fixed the function prototype, and added a simple trace level log to indicate that the function is not supported.

They also do not report the current volume level back through their API. So, I have no way of even faking it with several up/down button presses. To press 100 downs, then the setVolume value's up button presses would take a substantial amount of time, and would not necessarily be correct since packets can get lost/dropped.

I do have an active feature request filed with Roku to add the command to their API for Roku TV devices. Roku players don't have a fixed volume option, so it was probably an oversight when they started integrating into TVs since they do have other TV only features in their API.

1 Like

Armand, it works perfectly. You're a life saver and my wife will be pretty happy with me, which means I score points and if I ever see you, you get free beer... :wink: And not that Bud Light crap neither...

1 Like

I still have some more work I need to do on it before I am completely happy, But it I think I am finally happy with too. Now if Incan just figure out how to make the iSmartLife stuff work. Things shouldn’t be this complicated

So Tried this out and I think its great. Been having one issue though. nearly every time I tell it to turn on or off the tv via alexa it says the device is not responding. The action is still completed, so still completely usable but just a bit annoying. The 2 TV's I've set up so far are Hard Wired Roku Ultras.

Question: Since my "tv" is just an Ultra what would the preferred quickest refresh rate be? It sounded like it could be faster based on whats above.

My instinct is to say this is an issue with the link between Alexa and the Hubitat. Device not responding happens when Alexa sends the call to the device (in this case Hubitat) but the device did not respond to acknowledge receiving the message. We can try changing the status values from powering-on to just not showing the status of in until confirmed. I have doubts this is the issue though, because it has been solid on my system.

What Alexa app are you using on the Hubitat?