Add power on/off support for Roku TV (Enhancement)
See original GitHub issueI 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:
- Created 7 years ago
- Comments:14 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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.
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.