How to handle power on/off of TV with Roku Ultra?

Hi - I was wondering if anyone with a Roku Ultra could explain how they are handling power on and off of the connected TV? For some reason I’m struggling big time with this - currently I have a input_boolean which just turns the media_player on or off, but it’s very inconsistent, and since it isn’t aware of state, it fails if for example you turn the tv on with the roku remote, but then try and turn it off via the toggle switch.

I’m guessing I’m missing something simple here.

When you say power on/off do you mean actually turning off the power, or going to standby?

Standby causes issues with any smart TV integration because HA can no longer communicate with the device. The “off” button in media_player sends it to standby, and it can’t be turned on again. The only way to turn it on is with an IR command from the remote, or from some kind of IR blaster.

With my Android TV, I have a smart wall socket and a dashboard switch to control it. When I turn the power on, it triggers an automation which sends the standby IR code to the TV. Once it is on, it can be controlled with media_player.

Ok I think that makes sense. So for example, I have the roku remote card from HACS which works perfectly to turn the TV on and off. What you’re saying I think is that is sending an IR code directly to the TV, not to the roku. Same I assume with the volume.

One of the GitHub posts talks about not being able to turn the TV on if “fast startup” is not enabled. Do you have that setting on your TV? It was some time ago…

I believe the fast startup issue is only related to Roku tv’s (I actually had this issue on a roku tv). The current issue I’m having is related to the Roku Ultra specifically.

I got it finally. I ended up using a button instead of an input_boolean. Instead of powering on/off the media player, the button triggers a remote.send_command of “power”. This doesn’t care about state, and seems to work well.

Code:

alias: living_room_tv_power
description: ""
triggers:
  - trigger: state
    entity_id:
      - input_button.living_room_tv
conditions: []
actions:
  - action: remote.send_command
    target:
      entity_id: remote.roku_ultra
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      command: power
mode: single