Adding to the ever-growing list of IoT devices in my home, I recently purchased a Tuya Universal IR Remote. This device is a small IR blaster that can be controlled via the Tuya Smart Life app. It can be used to control a wide range of IR devices such as TVs, air conditioners, and more. The device is powered by a BK7231N chip, which can be flashed with OpenBeken firmware to enable local control and integration with Home Assistant.
Flashing OpenBeken Firmware
I forgot to get photos of the process, but the process was pretty simple. Using my Tigard FTDI adapter and a BDM frame, I probed the +3.3v, GND, RX, TX and BOOT pins on the device. I then used the ltchiptool
to read the current firmware from the device, and then flashed the OpenBeken firmware to the device.
1 | # Read the current firmware from the device. Multiple times to ensure a good read. |
Configuring OpenBeken
- Set up the Wifi credentials
- Set up MQTT
Configure module pins:
1 | { |
Reading IR
Reading signals from the IR remote control is pretty simple. Just point the remote at the IR receiver and press a button. The signal will be printed in the OpenBeken log output. Now would be a good time to sniff the IR codes from the remote you plan on using.
example:
1 | Info:IR:IR IR_NEC 0x38 0x54 1 (0 bits) |
Sending IR
This can be done several ways…
Via HTTP
Using the cm
command in the URL, you can directly ask the module to send an IR signal.
1 | http://192.168.1.162/cm?cmnd=IRsend+NEC-0x38-0x18 |
Via MQTT
OpenBeken supports sending commands via MQTT. This is the preferred method IMO, as I don’t need to assign a static IP to the device.
1 | Topic: `cmnd/obk50BC34A0/IRsend` |
Automation
I went the route of building a Node-RED Dashboard to control the device. Initially I set up a button per IR code, but this quickly became a hassle to manage, so when it came to building a fully exhaustive remove, I rewrote everything into a UI Template node, which iterates over a JS Object, describing the remote control buttons. To simplfiy the buttons and template, I created a JS function to map the button to the IR code. This wasn’t necessary, but it made the template much cleaner, and I can choose to omit buttons from a remote if I don’t use them without losing the IR code.
Function: “SanyoTV to IR payload”
1 | // Map key press to IR code |
Template node: “Sanyo TV Full”
1 | <template> |
Results
Ref: