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

Thanks!

By the way, I am tinkering with the new ping feature. If I detect a failure, try to ping the TV and it doesn't respond, then I will assume it is off, and resort to pings to test for on state. This is new, and very alpha code, so I am not releasing yet. If it works as intended on my TVs, I will release it. For TVs that return these timeouts, it is usually because the TV is not set to fast start mode, or because of too much network congestion and the timeout needs to be increased. 5 to 10 seconds is usually enough.

2 Likes

I have the driver updated to use ping when the TV is powered off, and cannot respond to network requests. If the TV is connected via ethernet, I can wake it back up too using WakeOnLAN. Unfortunately, I cannot find a way to implement WakeOnWirelessLAN. I cannot seem to locate how the WoWLAN protocol works, and Hubitat does not seem to support the one-off protocol.
Additionally, there is about a 3 seconds period of time where the app is under heavy load when issuing a ping packet. Therefore, I am not releasing my update at this time. I will tinker with it some more to fine tune it.
As it is now, when I detect a network failure, I issue a single ping packet to see if the device is offline or not. If the ping fails, then I disable all refresh operations, and enter the ping monitor. The ping monitor will submit a single ping packet, every ping interval. The ping interval is the smallest not-zero refresh interval defined in the driver, but it cannot be any less than every 20 seconds. I am thinking of changing this to 30 seconds, because even 1 ping packet every 20 seconds adds a noticeable load on the system. In the end, I may cap the ping interval to once per minute. Once the ping succeeds, the driver returns back to normal refresh checked based on the state of the TV.

This seems like it should not be an issue, but when I had it set to 1 ping packet every 2 seconds, it crashed the hub with just one TV being powered off. I then increased the interval to 1 ping every 5 seconds, and it did not crash, but was very unresponsive. When I put it at 10 seconds, I could use the system ok, but the runtime statistics showed the one TV was using 11% of the cpu. With it at 20 seconds, it's down to about 6% of the CPU. So, if I extend this to once a minute, it should be down to 1% or less per Powered off TV. This is measure over a window of time, and I am looking at total % of total cpu, not % of busy.

One thing that is blatantly obvious is that I can support leaving the Roku TVs with Fast-Start turned off, but I cannot turn those TVs on unless they are wired to the network. And when they are powered down, it will be a use at your own risk setting. Perhaps I will add a toggle setting to allow the user to choose to turn on the feature.

Hello, I am seeing failures when I try to set the volume of my Roku TV using the driver. However, the failures are different depending on how I attempt to set the volume.

For example, the failures are different when I attempt to set the volume via RM-4.1 actions vs. when I try to set the volume directly from the driver itself. Please consider this table (the TV is on for all these tests and its volume at the time was set to 50):

What I did Logged Error
(same as above)

Please take a look in case something may be wrong. Please note that other volume options including "Volume Up/Down" and "[un]Mute" all work as expected.

SetVolume is not Implemented because Roku does not support it. I have submitted more than one feature request to support this. It is stupid that they don’t.

hello this is a very long thread and it took me a while to get to the bottom :laughing:

anyways I just installed this app last night for the first time and was able to install my two TCL Roku TVs with zero issues. all works well at the device level power on/off, mute/unmute, pause/unpause, etc.

forgive me if this has been raised earlier but what template do I use to get the full device functionality on the Dashboard? Currently, I am using a switch that is limited to on/off.

I don't want to get too fancy but it would be great if I could get the aforementioned commands on the Dashboard.

P.S: armand, you are one heck of a dedicated person..I really commend your effort and commitment on this - Thank you!

There is not dashboard support for televisions, or media players. You will need to create several tiles for different things. Some people use a remote control layout. Others follow the Logitech Harmony style of creating buttons for actions/activities, that trigger various actions. I only use on/off on my Sharptools.io dashboards, where I treat them like lights, but use a custom icon for the TV image. I made the applications available as child switches, so you can add them too. And if the TV is on, and you press the Hulu app (for instance) it will turn on the Tv and launch the Hulu app, so you don't need too many rules for this. Just don't expect things like volume control to be very helpful, since Roku cripples the interface by not allowing setVolume. It is possible to simulate a set volume, but that would require 100% automation for volume control, and it would grow annoyingly cumbersome as you soon would learn how fickle complications like that are.

ok that interesting..

for my use case (a wall-mounted control tablet) I would only ever need power on/off, mute/unmute, pause/unpause purely from a device control management perspective.

I would leave more interactive functionality like channel selection, etc for the Roku app itself.

Any idea if there are any plans for dashboard support for basic TV control as mentioned above?

In the meantime, I will just use the switch template to be able to turn on/off the Roku from my dashboard.

Thanks for your response.

Hubitat doesn't release its product plans. They may or may not be working on this, hard to tell.

thanks..

Hubitat has had support for a TV capability for years but has not implemented into anything as of yet. I have. I idea where they are going with all their recent changes, and quite frankly, I would openly allow them to take over my driver. I don’t make any money on it, a lot of people use it, and I seem to be chasing integration issues frequently, because I don’t have the inside Information on the systems. Most recently I added a standardized method for switching inputs in an effort to be as standardized as possible, but there is still no public information if there are any plans from them to actually support this.
For now, I fix and enhance what I can in my spare time, and try to handle every issue in the most professional way I can. Some day, I might make $5 or $10. :joy:

Just have fun with it. Figure out what you can, and let me know if you would like an enhancement or need a bug fixed.

1 Like

much appreciated!

Are you seeing the stats of the Roku's showing abnormally high? My two Roku's are always the highest stats...

It depends on what you are looking at in the stats. Total ms will be high, because the Roku sends a lot of data on the query/device-info call, which is used to determine if the TV is on or off. That is why you should try to keep the refresh interval for that rather high. I use mine at 10 seconds in the Office which is extremely aggressive, and I have 3,140 Avg ms. The total ms give you an idea of how busy the driver is. Avg ms gives you an idea of how much time it takes to cary out a command. Since the commands are blocking call (synchronous) this is the total round-trip time from sending the command to receiving confirmation the command was successful.

The ms timings do not negatively impact the hub performance. While the system is idle, and waiting for the response from the TV to come back, other things are still going on. To know how much of the CPU the driver is consuming, you need to look at % of busy, and % of total. % of busy should always total 100%. It tells you that of all the devices, which devices is the hub using it's compute time for. in my case, the Office TV is 42.6% (but that is because I have a special test version of my driver and TV setup running. All my other TVs are in the negative, because of an anomaly in the metrics monitoring logic.
The one of most importance is % of total. my Office TV, which is 42% of the CPU busy only uses 0.782% of the total CPU. This tell me that the CPU is mostly idle. Life360 has an avg ms of 2.5seconds, and is 15% of busy and 0.286 % of total.

Again, the reason my TV rates with this high of numbers is because I have it physically turning off which is not supported in your driver and results in a lot of heavy usage due to network timeout errors.

Make sure you have the latest drivers, and reset the metrics and monitor it more over time. Be sure to add % of busy and % of total to you statistics to get a better view of what is happening.

1 Like

Thanks for that detailed reply. The 3.7's in my pic are % of Total. Doesn't that seem high, almost 7.5% of the cpu usage is these two Rokus? I'm on the latest from HPM.

That is high.

What are your refresh times?
Is the roku in Fast-Start mode?
When did you last reset the metrics? (I updated the code to improve performance a while back)

@armand Since upgrading to version 2.7.12, I'm no longer getting updates for transportStatus. In looking through the code, I don't think callback methods can be defined as private:

private void parseMediaPlayer(response, data) {

I added some debugging lines to parseMediaPlayer to test it. When it is defined as private, I get this in the logs:
image

When I remove the private, I get this:
image
And then transportStatus is updated correctly.

thanks for reporting this. I am back from Cancun and have fixed it. Looks like this was the only parser I made this mistake on.

1 Like

Is there a way to call the "Query Media Player" command from within a rule? I've noticed that sometimes the transport status does not update automatically and I want to force an update. Using Rule 4 for now.

EDIT: Found it...Had to select "Run Custom Action" and select "Switch" as the capability.

Just make a call to custom command. Any button in the device view is a function and the function names appear in small text on the button. But the refresh is managed by the driver if you have refresh enabled, pulling each refresh interval.