The roku component works great for the roku stick, and pretty darn well with the roku tv. It would be great though if there could be more functionality with the roku tv. For example it is possible to turn on/off the tv from a companion app, it would be nice to get that funtionality here as well. I have looked around and it seems that there is already a python/roku with a power function. I tried to integrate it with my own HA instance but lack of time and expertise has stopped me.
Just wanted to bump this thread and mention that these Roku TVs are very popular on Amazon these days, and are often featured deals around holidays or âPrime Dayâ, so I imagine there are many other users who could benefit from expanded support.
I actually logged into the Forum tonight specifically to see if I could find whether the Roku TV is supported by the component, and if so, if power on/off is a supported function, since obviously thatâs not a thing for the set top boxes. It would be great to see that addition here.
This looks great. I will give it a try and let you know how it works. So if the tv is past the 15 min rest period which mine usually is. I will have to run a WOL command right?
Yeah, I just send it every time I turn on the switch - itâs quick and doesnât seem to have an impact if the TV is already awake. I donât even need a delay between the WOL packet and the power command.
One thing to note is that WOL only works on wired connections. If your TV is connected via wifi, Iâm pretty sure youâre out of luck once it goes into suspend. Youâd need to look at waking it up over IR or RF at that point.
If you are using wifi for the TV, it might be possible to keep it awake by having HA submit a rest command to it every 10 minutes after power off. I have no idea what that would do to your energy bill though.
@Valdorama This does work without the âFast TV Startâ but itâs kind of awkward and this could be because Iâm definitely not an expert. The WOL switch appears in the interface. If you turn it on while the TV is in deep sleep, the TV will turn on. Turning off the switch however does nothing. I didnât really like the automation route either.
My though would be to use the RESTful Switch to create a power toggle for the Roku TV.
The problem is that if you use the url: âhttp://tv_ip_address:8060/keypress/Powerâ The switch doesnât get added because it canât preform a GET on that address. Also the switch could get itâs status from: âhttp://tv_ip_address:8060/query/device-infoâ Result will show the tag power-mode as either PowerOn or DisplayOff indicating status.
My guess is that there is probably a way to set this up using template or booleans but again, Iâm no expert so any help on getting this up would be appreciated.
Here are the results of device info from command line in case that helps:
> curl -X GET http://roku_ip:8060/query/device-info | grep power-mode
> % Total % Received % Xferd Average Speed Time Time Time Current
> Dload Upload Total Spent Left Speed
> 100 2077 100 2077 0 0 51993 0 --:--:-- --:--:-- --:--:-- 53256
> <power-mode>DisplayOff</power-mode>
and:
curl -X GET http://roku_ip:8060/query/device-info | grep power-mode
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2074 100 2074 0 0 68759 0 --:--:-- --:--:-- --:--:-- 71517
<power-mode>PowerOn</power-mode>
OK, So after wasting a bunch of time trying to do this as a REST switch it was much simpler to just write a command line switch. Here is the code I used, it doesnât have the WOL so you should enable fast TV start if you want this to work as is (it should be pretty simple to include this though).
Tested on TCL roku TV, the switch turns the TV on and off and the position is grabbed based on the info grabbed from roku api.
switch:
platform: command_line
switches:
tv_power:
command_on: 'curl -X POST http://roku_ip:8060/keypress/PowerOn'
command_off: 'curl -X POST http://roku_ip:8060/keypress/PowerOff'
command_state: 'curl -s GET http://roku_ip:8060/query/device-info | grep power-mode | sed -e "s:<power-mode>DisplayOff</power-mode>:OFF:" -e "s:<power-mode>PowerOn</power-mode>:ON:"'
value_template: '{{ value == "ON" }}'
Finally managed to get it working using rest_command in conjunction with WOL, thanks to @natabatâs source. I can successfully turn the TV on (without Fast Start enabled) and then off again.
turn_on_roku_tv:
alias: Turn On Living Room TV
sequence:
- service: switch.turn_on
entity_id: switch.roku_tv_wol
- service: rest_command.roku_tv_power_toggle
turn_off_roku_tv:
alias: Turn Off Living Room TV
sequence:
- service: rest_command.roku_tv_power_toggle
Few things:
Iâd prefer to use the distinct PowerOn and PowerOff keypress commands but just canât seem to be able to define two rest_commands.
My TV is connected via ethernet so WOL works.
TV has been allocated a fixed IP address so I donât need to worry about that.
Next step is to trigger the on/off from a Google Home (via IFTTT)
@Omri_Asta: Have you noticed your TV turning on by itself? I tried to do the same thing you did, and I found that if HA ran the state check while the TV was suspended but not fully powered down, it would come back on again.
@Valdorama: You should be able to define a second command just like you did the first:
I also ended up just calling wake_on_lan.send_magic_packet in my on automation, cause the wol switch was also causing the TV to randomly wake up while monitoring its state. Iâll have to try it again if no one else is seeing that behavior⌠I believe thereâs a setting on the TV to skip the suspend state and go straight to a full power downâŚthat would probably fix my problem.
@natabat I have the TV set to âFast Startâ so it doesnât go into âdeep sleepâ and no, the âcommand stateâ doesnât turn the TV on for me. The reason I didnât go with the automations and scripts is I just wanted a simple toggle switch in the UI which I donât really get with the others unless I trigger an automationâŚI wanted something similar to a light switch in the UI for the TV.
Still not quite sure what I got wrong that caused that odd behavior, but I shifted to using the command line switch from @Omri_Asta (with the fix suggested by @cwhits), and that seems to be working. For anyone who doesnât want to use the Fast Start setting, hereâs the power on command Iâm using:
command_on: 'wakeonlan roku_mac; sleep .25; curl -X POST http://roku_ip:8060/keypress/PowerOn'
You also need to sudo apt get install wakeonlan. The sleep is there just to give the TV a little time to wake up before sending the PowerOn command.
I just got a Roku TCL tv and for the most part it works in hass.io, but I canât turn the TV on from hass.io. Has anyone fully figured this out? Whatâs the easiest solution to make this work? Iâm also surprised this hasnât been fixed in the Roku integration. Thanks!