Roku Connect: deterministic TV power state

@armand first up, thanks for the great work on Roku Connect!

Based on what I've read and tinkered with, I should be able to properly reflect the attached TV's power state and deterministically trigger actions based on it... but Roku isn't properly reflecting said state. It's attached to a ~2-year old Sony Bravia TV that the Roku can control perfectly without any quirks--volume, power, etc. all work. I enabled experimental controls on this Roku's Hubitat instance to try and force it to return the proper TV state and further adjusted the power ON/OFF radio buttons to ensure ON meant on, etc. That all worked perfectly and corrected the default toggle behavior.

Nonetheless, I can't get the TV's object to reflect its current state--it always reports on. Perhaps I've misunderstood something?

Thanks in advance!

Roku media players always report on. You can control the TV to turn on/off, but there isn’t anything that reports back that the TV is off.

How would a toggle work for you, that if enable, when the Roku is on the Home Screen, it reports as off?

2 Likes

Ugh, I figured you'd say that but my optimism knows no bounds.

Using the NOT 'HomeScreen' mediaInputsource is what I've currently got and that solves 1 of my 2 scenarios:

  1. Scheduled + restricted button throws a virtual switch on my Hubitat dashboard and shuts down my sons' Rokus' TVs (they're good kids... most of the time)
  2. Sync TV back lights when TV turned on/off

#1 works well enough. #2 I've yet to solve.

My optimistic TV.powerState(ON|OFF) approach solved for both but alas. Is there perhaps an 'in use' event that fires following remote input after an idle period?

Any thoughts?

Thanks again!

Why not put your TVs on outlets that measure power? I do that for the TV in my exercise room - so lighting/music automations know when the TV is on or off.

2 Likes

LOL: got another thread ongoing on that one--can't get it to work (clearly, there's a common component here... me :frowning: ) for my smart plugs or smart outlets.

Built In Minoston Mini Power Meter Plug Driver reporting power draw every second! - :toolbox: Built-In Apps and Drivers - Hubitat

I am using the ECP protocol. this is the external control protocol, and allows apps to work as a remote control.
I see Roku has recently updated to a new major version 6.x from 5.x. Let me re-review this, but ultimately, I get what I need to querying the roku device's status report page. If there is new data, I can incorporate it.

I have a Roku Premier+ setup in this same scenario to an LG TV in our guest room, so I do have a test unit to tinker with. Let me see what I can find out. I am doubtful there have been any update in the ECP protocol (I have had a few features enhancements requests out there for several years now that they haven't addressed, so I really doubt it).

The other option is to use an energy monitoring outlet. Determine the power draw when the TV is on, versus when it is off. Then you can control the ambient LED strip's power state based on the current power consumption, and control the colors based on your rules, it the LED strip is in the on state.

I have one of there on my fridge to know if the fridge loses power, and fails, or if my ice maker freezes up because of the behavior change in power draw when it does freeze up.

2 Likes

I guess I should have read farther down the thread.

I use zwave+ outlets from Neo Coolcam. They work really well for this purpose.

These ones here, except I got them for about $10 apiece on AliExpress:

https://a.co/d/eTgkJNu

1 Like

That's awesome--thanks so much!

Love the idea on the fridge--a very clever use case.

With a 2-3 year old Sony, have you looked at bringing the TV into Hubitat via [Release] Sony Bravia TV Rest Control? You could poll the Sony's on/off state rather than the Roku.

1 Like

I'm still tinkering and noticed that, regardless of how you turn off the TV off (including using its native remote or power button), the Roku detects this and immediately pauses the selected mediaInputSource (immediately equates to within 2 seconds)--presumably this uses HDMI's CEC protocol. I guess the question is whether or not the Roku exposes that via the ECP interface you mentioned you're using. It could also be an HDMI-local, 1-way & transient event from the TV to the Roku rendering it useless in this case but I figured I'd throw that out there in case it helps...

The Roku does expose this and my code does report if a show is paused. But there is no telling if a show is paused because you paused it, or because the TV was turned off.

I have this same issue in my guest room and my RV. In both places where I have Roku players instead of Roku TVs. I just deal with it as a known limitation.

I was referring to the event that the Roku picks up on when the TV is powered off that triggers the pause as opposed to the pause action itself.

It's resolved now, though--the power meter solution began working after I had to reboot the Huitat to fix the Echo skill issue. :man_shrugging:

Thanks again!

As I mentioned, this is now working using the Minoston power metering plug. However, it's emitting events every 100ms or so and firing various power-related rules. I've tried everything to slow this down ranging from switching between old|new drivers and setting the time report internal to an hour--nothing affects the event rate. On the events is 'Acceleration' which seems odd, too. I assume I must be missing something--any pointers?

Thx!

None. I don't have those devices. I have Neo Coolcam outlets that are well-behaved. I have the meter reporting interval (where there's no change in current) as 5 minutes, and that's when they report. They will also report when there’s a 5% or greater change in current draw.

They are CE certified (not UL). I have had no issues having loads as high as 7-9 Amps on them. They have worked well on Hubitat and Home Assistant for the last several years.

Thanks... that's still helpful since it confirms it's not expected behavior. I'll keep digging...

Quick follow-up: grabbed another plug since I bought a pair of them; included it and it's logged only 18 events so far many of which were initial bootstrapping-related events. I'll factory-reset the other plug and see if we've got any residual settings our of supported range.

Roku ECP has a few web page endpoints. I publish them for those that want to tinker more. They appear in the data section of the Roku TV driver pages.
image

I have to poll each of these pages to detect changes. For pause, I poll the media-player web address, and parse it. If it fails to parse the results, then it checks active-app, and if the active app is Home (like shown here), then I set
transportStatus to stopped (instead of paused).

For power state, I query and parse the device-info page. I look for anything I can but mostly the "power" state, which I report as a current state.
image

I then translate that into the "switch" state of on or off. So if we can find something, I can change the switch state to off, regardless of the power state.

image

So, feel free to play around. you can't hurt the roku system with these ECP queries, but you may find something of interest that can assist with implementing some better integrations. As one person, I cannot think of all the different ways people will use these features, so I try to make the system as versatile as possible, within the limits of a remote control app anyways..

1 Like