Ideas on turning off TV

Yeah, i have a logitec harmony remote, and i use those activities for turning on and off devices through a smart power strip. So the TV goes off completly after the Oled refresh is done (after an hour or so), xbox, switch are only powered if used, and the amplifier goes off as said when you turn off the TV.
You could do something similar with an IR blaster through HA.
I just love it that i have an actual remote control, that keeps things easy for the wife and daughter.

I got a cheap $3 ir receiver that I’ll flash with Tasmota and then I’ll be able to automate everything - make it learn the power button from the 3 remotes I’m using. Whenever it detects them, turns off or on the power plug in which TV, soundbar and xbox are plugged.
It’s just going to require two power button presses for ON, but other than that no changes to our habits.

Love that! I use an ESP8266 with IR and Tasmota. I don’t have the IR codes on the board. I send MQTT commands to it instead. It’s probably easier the way you are doing it(assuming I understand what you are doing). Let us know which board you decided on. I’d like to check it out.

EDIT: I’m assuming you are using an IR transceiver. I just used an IR emitter I soldered on with a transistor and a couple resistors.

Tuya WiFi IR Remote Control which looks to be the Tuya UFO-R1. Don’t think it’s a transceiver, it’s supposed to learn your IR signals and then fire user defined events to smart devices based on those codes. I don’t have XP with this so I’ll see how it goes, probably has to be integrated with MQTT to get it working after I flash Tasmota. Getting it to learn the codes is what I think will be trickiest.
I’m really hoping I don’t have to spend >1hr working on it :smiley:

That is a cool idea! I may grab one if I can flash Tasmota on it.

Why not work around this. Assuming you can know if your TV is on or off, use an outlet plug to manage the soundbar. and simple automation if tv==off then soundbar outlet off ?

The TV turning on more than once a day for updates sounds like settings thing that might be possible to turn off (auto search for updates)?

His soundbar already turns on automatically. That’s part of the problem. Now that updates are blocked his TV wants to stay on all the time. Presumably he couldn’t find a setting to make the TV behave because he was asked if he could turn off the auto updates that cause the issue.

1 Like

Yup I posted a picture earlier with the setting not being available.
In the end I decided I want the whole thing completely off when I am not using it, not just the sound bar. Just waiting for the parts to arrive.

1 Like

I got my IR thingy today unfortunately it’s not an ESP chip so can’t use tasmota on it. It’s CB3S which according to this guy Flashing TUYA CB3S BK7231N with Openbeken alternative firmware - YouTube can be flashed with Openbeken, but it requires way too much fiddling and I can’t be bothered with it :frowning:
I’ll try to get a Zigbee device, at least then I can use it with ZHA without any extra steps.

What device did you buy?

Tuya is generally not ESP based and because of that not something you should buy.

https://www.aliexpress.us/item/3256803170449830.html

I bit the bullet and flashed the device I already bought and is working nicely, it captures the signals from the remotes and also fires the signals to turn off/on the TV. I have it pushing events to MQTT, but I’m stuck at integrating this with HASS.
The idea is:
Press Remote power button → IR Blaster captures event and pushes to MQTT → HASS looks at the MQTT topic and (only) when the power event is received, triggers a turn_on for the relay controlling the TV power, and also tells the IR Blaster to turn on the TV.

I should set it up in configuration.yaml but how do I read only this specific MQTT message? And should it be a binary_sensor?

Disregard this, my brain shuts down after a long period of not fiddling with HASS - I now have a test case working. It was as simple as creating a new automation:

alias: IRBlaster
description: ''
trigger:
  - platform: mqtt
    topic: irblaster/ir/get
    payload: IR_Samsung 0x707 0x2 1
condition: []
action:
  - type: turn_on
    entity_id: switch.shelly1_68c63afb5603
    domain: switch
  - service: mqtt.publish
    data:
      topic: irblaster/ir/get
      payload: '0'
mode: single

Now to build my shelly1 based smart plug and put everything in place! :smiley:

Finally, I have everything functional.

First, as per Flashing TUYA CB3S BK7231N with Openbeken alternative firmware - YouTube I flashed my tuya BK7231N based IR blaster. Looks like this is the new norm for Tuya devices, no more ESP, so I’m sure this FW will get more and more traction.

It required a bit of soldering:

Flashing:

  1. Download https://github.com/OpenBekenIOT/hid_download_py (you need the uartprogram file)
  2. I got the UART Flash .bin from Release 1.15.217 · openshwprojects/OpenBK7231T_App · GitHub
  3. I already had python installed so the command was:
    python uartprogram OpenBK7231N_QIO_1.15.217.bin --unprotect -d com10 -w --startaddr 0x0
    Be sure to be in the directory of the zip you download from 1), so that python can access uartprogram file.

Reset the irblaster and it will come up with an open access point, connect to it and access its ip (I don’t remember if it was 192.168.1.1 or something else).

OpenBeken configuration:

  1. Configure module:
    P7 PWM1: IRRecv
    P8 PWM2: WifiLED
    P26 PWM5: IRSend
  2. Configure General/Flags
    I activated flags: 14, 19, 22 (they concern MQTT publishing)
  3. Configure WIFI - put your ssid
  4. Configure MQTT - put your mqtt server
  5. Configure name: - some friendly name
  6. Press return to menu and Launch Web application and go to Logs

Now if you press remotes around it you will see the IR codes and it should also publish to MQTT. Also if you want to Send an IR code, you do it from this Logs page.

Smart plug - I made myself one smart plug by adding a shelly1 relay to a dumb socket extender, to which I connected my TV, soundbar, Xbox.

Finally, the HASS configuration:

alias: IRBlaster TV On
trigger:
  - platform: mqtt
    topic: irblaster/ir/get
    payload: IR_Samsung 0x707 0x2 1  # listen for the power_on IR code from remote
condition:
  - condition: state
    entity_id: switch.shelly1plug_tv   # my "smart" plug
    state: 'off'
action:
  - type: turn_on
    entity_id: switch.shelly1plug_tv
    domain: switch
  - service: mqtt.publish
    data:
      topic: irblaster/ir/get
      payload: '0'         # reset the message so the automation doesn't loop
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: shell_command.irblaster_turnon   # this is a shell command, see below
mode: single

In configuration.yaml I have this shell command defined because OpenBeken does not do IRSend via MQTT, but can do with a HTTP command.:

irblaster_turnon: '/usr/bin/curl "http://192.168.2.7/cm?cmnd=IRSend%20Samsung%200x707%200x2%201"'

And the final automation:

alias: IRBlaster TV Off
trigger:
  - platform: state
    entity_id: media_player.samsung_ue46f6500
    from: 'on'
    to: unavailable
    for:
      hours: 0
      minutes: 0
      seconds: 15
condition:
  - condition: state
    entity_id: switch.shelly1plug_tv
    state: 'on'
action:
  - type: turn_off
    entity_id: switch.shelly1plug_tv
    domain: switch
mode: single

Logic: if I press the power button on the remote, the IR blaster will intercept it, will publish it to MQTT, HASS will then turn on my smart plug and make the IR Blaster send the turn on IR code which will turn on my TV.
If I turn off the TV, HASS will see the TV has become unavailable and will turn off the smart plug.
In case my HASS system is not working, then I have the shelly relay set to always power on when power is re-established to the relay, just as a fallback.

1 Like