question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add power on/off support for Roku TV (Enhancement)

See original GitHub issue

I have a Roku TV (TCL brand) and I’m trying to find a way to turn the power on/off remotely from Home Assistant.

I didn’t see a way to do this in the Roku External Control Guide, but I noticed that the Roku App for iPhone can do this.

I decided to do a packet capture while pressing the key on the Roku App, and here’s what I was able to capture:

......{"request":"key-press","request-id":"12","param-key":"Power"}.M{"response":"key-press","response-id":"12","status":"200","status-msg":"OK"}
.W{"notify":"power-mode-changed","param-power-mode":"power-on","timestamp":"843087.742"}
......{"request":"key-press","request-id":"13","param-key":"Power"}.M{"response":"key-press","response-id":"13","status":"200","status-msg":"OK"}
.Z{"notify":"power-mode-changed","param-power-mode":"display-off","timestamp":"843094.468"}
..%CO.......%CO.......{"request":"key-press","request-id":"14","param-key":"Power"}.M{"response":"key-press","response-id":"14","status":"200","status-msg":"OK"}
.W{"notify":"power-mode-changed","param-power-mode":"power-on","timestamp":"843296.953"}
......{"request":"key-press","request-id":"15","param-key":"Power"}.M{"response":"key-press","response-id":"15","status":"200","status-msg":"OK"}
.Z{"notify":"power-mode-changed","param-power-mode":"display-off","timestamp":"843300.429"}
......{"request":"key-press","request-id":"16","param-key":"Power"}.M{"response":"key-press","response-id":"16","status":"200","status-msg":"OK"}
.W{"notify":"power-mode-changed","param-power-mode":"power-on","timestamp":"843305.781"}
......{"request":"key-press","request-id":"17","param-key":"Power"}.M{"response":"key-press","response-id":"17","status":"200","status-msg":"OK"}
.Z{"notify":"power-mode-changed","param-power-mode":"display-off","timestamp":"843309.832"}
......{"request":"key-press","request-id":"18","param-key":"Power"}.S{"response":"key-press","response-id":"18","status":"202","status-msg":"Accepted"}
......{"request":"key-press","request-id":"19","param-key":"Power"}.M{"response":"key-press","response-id":"19","status":"200","status-msg":"OK"}
.W{"notify":"power-mode-changed","param-power-mode":"power-on","timestamp":"843316.327"}

Is this a function that could be added to the library? Would it help if I did another kind of capture?

Thanks! Roddie

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
jcarbaughcommented, Nov 20, 2016

Hello! Could you run this command either right in the root of the project or in a virtualenv with roku installed? Replace X.X.X.X with the IP address of your Roku TV.

python -c "from roku import Roku; Roku('X.X.X.X')._post('/keypress/Power')"

Did that work? Did that power the TV on/off? If so then we can just add Power to the supported methods, otherwise it’s something definitely not available through ECP.

1reaction
ghostcommented, Nov 25, 2017

As the user above said, you can power the TV on when it hits that low power state by sending a WOL magic packet to it’s MAC address. Unfortunately, there doesn’t seem to be a great way of doing that without somehow storing the device’s MAC address in a configuration file. I’ve written some scripts for controlling my TV which I plan to publish at some point, if you need some code to look at, but basically what I do to turn the TV on is attempt to send a POST to /keypress/PowerOn with a short timeout (only one second, if the TV is online it will respond almost instantly), and if it times out, I send a WOL packet instead. It’s also worth noting that /keypress/Power is a toggle, while /keypress/PowerOn and /keypress/PowerOff are nifty little functions which will do nothing if the TV is already on or off, respectively.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Roku Ultra: No way to power off my TV? - Remotes
Help with Roku remotes and accessories, including pairing a remote, setting up TV power & volume control, using voice commands, power adapters, cables, ......
Read more >
How to enable dialog enhancement on your Roku TV
Enable dialog enhancement during playback · Begin streaming content or switch the active input to a connected device (e.g., cable set-top box, ...
Read more >
How to set up your Roku® voice remote to control your TV
Press Home home button on Roku remote · Scroll and select Settings · Select Remotes & devices · Select Remote · Choose your...
Read more >
How to set up your Roku Express 4K+
If desired, attach your Roku player using the adhesive strip. Use your TV remote to power on your television and select the input...
Read more >
How to use the 'TV Off' shortcut on your Roku® streaming player
Press Home home button on Roku remote on your Roku remote · Scroll and select Settings · Select System · Select Control other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found