Turning On an Xbox With a Chain of Infrared
My television came from the United States. I live in a country with 230 V mains.
This meant that turning on the television began with turning on a 230-to-110 V transformer. By the time I had made the whole media setup convenient, one button involved a smart plug, two infrared receivers, two infrared transmitters and an Xbox.
The easy Xbox solution
In March 2020 I powered on the Xbox over the local network.
xbox-remote-power sent the wake packet, retried and confirmed success with a ping.
I wrapped xbox-on in node-red-contrib-xbox-on, a small Node-RED node which accepted the console address and Xbox Live device ID, then called powerOn() with configurable retries.
That worked. It was also only one link in the eventual living-room problem.
The Xbox was the media center. The Panasonic television needed its transformer energized before it could wake, and a Logitech Z906 handled audio. I wanted one physical remote action rather than a small distributed-systems exercise every time I watched something.
Infrared in both directions
In October 2024 I switched to infrared.
The Xbox One accepts commands from its media remote over IR, and using Arduino-IRremote, an Arduino Nano could send its power command in loop() after configuring SLEEP_MODE_PWR_DOWN in setup():
IrSender.sendOnkyo(0xD880, 0xD02F, 1);
sleep_mode();
The short program booted, transmitted one power command and put the AVR into power-down sleep. It was a one-shot appliance: apply power, wake the Xbox, become inert.
The Xbox could then send infrared in the other direction.
Its Device Control settings knew about the Panasonic TV (remote code T1480) and the Logitech audio receiver (M3561).
I configured it to send toggle commands to both when the Xbox turned on or off.
So the Xbox was both an IR-controlled device and the IR controller for the rest of the media stack.
The transformer switch
The television’s 230-to-110 V transformer was connected through a metering smart plug. If you copy this, check that the plug is rated for the transformer’s switch-on surge, not just its running load. At first I controlled Tuya plugs with cloud-derived local keys and TinyTuya. Later I flashed the plug with OpenBeken, giving it a local HTTP interface under my control.
In February 2025 I also converted a Tuya S18 universal IR remote based on a CB3S/BK7231N module.
Its IR receiver worked with the inexpensive Xbox media remote I had bought from AliExpress.
Rather than overload the remote’s power button, I chose an otherwise unused button next to fast-forward.
OpenBeken saw it as an NEC-family frame with address 0xD880 and command 0xFF.
The device’s startup script attached that frame to a local request which toggled the smart plug:
startDriver IR
IREnable RXTX 1
addEventHandler3 IR_NEC 0xD880 0xFF 0 sendGet http://POWER_PLUG/index?tgl=0
The whole chain looked like this:
AliExpress Xbox remote
|
| unused IR button
v
OpenBeken IR receiver
|
| local HTTP
v
OpenBeken smart plug
|
v
230-to-110 V transformer
|
+-- 110 V output --> US Panasonic TV
|
+-- 220 V output + USB charger --> one-shot Nano IR sender --> Xbox power
|
+-- IR toggle --> TV
+-- IR toggle --> Logitech Z906
The Nano ran from a USB charger on the transformer’s spare 220 V outlet, so switching the smart plug brought up the TV and fired the one-shot Xbox power command together.
A held button is not one button press
The setup found an OpenBeken IR bug.
NEC remotes send an ordinary frame followed by repeat frames while a button is held.
OpenBeken’s own IR log printed IR_NEC 0xD880 0xFF 0 for the initial press and IR_NEC 0xD880 0xFF 1 for repeats, so I registered a three-argument event handler expecting it to match only when the repeat argument was zero.
OpenBeken still ran the handler for repeat frames.
The IR driver (drv_ir.cpp) always called EventHandlers_FireEvent2, and the event machinery allowed that two-argument event to match a three-argument registration without checking the missing repeat value.
For a command named “toggle”, this matters. One long press can become on, then off, then on again.
I reported it as issue #1541, which is still open. Debouncing the local script would have hidden the symptom, but the event arity belongs fixed upstream.
Knowing when the TV is off
The smart plug also measured power. That suggested a final automation: when the TV dropped below 20 W for long enough, cut power to the transformer rather than leave the conversion chain idling.
addChangeHandler Power < 20 never fired, even though Power > 20 worked.
I drafted timer-based alternatives which polled $power, started a delayed shutdown below the threshold and cancelled it if consumption rose again.
After I reported issue #1543, another contributor, xjikka, found the real cause: power-change events were only checked when MQTT was enabled, and I had MQTT disabled.
xjikka fixed it in PR #1578, which I tested on the real outlet.
A Rube Goldberg power button
There were simpler-looking alternatives. The Xbox could wake over Ethernet. The television had its own remote. The transformer could remain powered. The Tuya application could toggle the plug.
None of those was the same as picking up one familiar remote in the dark and pressing one button.
The final path was objectively elaborate. An IR command caused a local HTTP request which energized a voltage transformer and a tiny computer, which sent another IR command to a game console, which sent more IR commands to the television and speakers.
But every stage was local, observable and replaceable, and using it took one button.