2020-11-25
Last year Sarah and I bought a Regal Flame Spectrum Modern Linear Electric 3 Sided Wall Mounted Built-in Recessed Fireplace (50") and installed it under our TV. One problem is that it comes with an annoying little remote that we keep losing track of, so I decided to hook up a Raspberry Pi to allow us to control it with our phones.
First I set up a Raspberry Pi Zero W with Void Linux, and connected a 38kHz Vishay TSOP38238 receiver to one of its GPIO pins. These IR receivers are well supported on Raspberry Pi, and all I needed to do was add these line to /boot/config.txt:
dtoverlay=gpio-ir,gpio_pin=17
dtoverlay=gpio-ir-tx,gpio_pin=4
I needed to know what type of codes were being sent by the remote (Sony, Philips, NEC). I looked at the waveform with an oscilloscope and figured out that it was sending NEC codes. Then I used the program ir-ctl from v4l-utils to figure out which codes were sent for which buttons.
Then I breadboarded a small circuit to drive an LED with a transistor, and I went to my parts bin and found a bunch of IR LEDs tried each of them until I found an LED that transmitted at the correct IR wavelength to be picked up by the fireplace. I soldered the LED and the transistor to a piece of protoboard and mounted it tucked under the mantel aiming at the IR receiver.
The heater temperature needs to be set every time the unit is turned on. I wrote a shell script that simulates the sequence of button presses that turns on the heater to full strength and sets the temperature cutoff to 82°F.
#!/bin/sh
TIMER=0x8006
BG_BRIGHTNESS=0x800a
ON=0x8012
LOG_BRIGHTNESS=0x8019
STRENGTH=0x801e
TEMP=0x801f
press () {
ir-ctl -S nec:$1
}
press $ON
press $STRENGTH
press $STRENGTH
press $STRENGTH
press $TEMP
press $TEMP
press $TEMP
press $TEMP
press $TEMP
press $TEMP
press $TEMP
I would prefer to have some way of explicitly turning the fireplace on or off, rather than just toggling the power state. I found that if I quickly send a sequence like TEMP-POWER, the fireplace will skip processing the POWER keypress if it's already on, which can be used as a "turn the fireplace on, or leave the fireplace on" primitive. However it's not very reliable and I haven't found a more reliable method yet, so for now I just have a single "toggle" control that switches it from off->on or vice versa. The fireplace beeps after every button press so we can hear when it's toggled on because it beeps a bunch of times, whereas when it's toggled off it only beeps once for the initial POWER button press.
I use Homeassistant to control some things in my house, so I added these lines to configuration.yaml to allow us to toggle the fireplace from our phones:
configuration.yaml:
shell_command:
fireplace_toggle: ssh -i /config/fireplace_ssh -o UserKnownHostsFile=/config/ssh_known_hosts root@fireplace toggle
light:
- platform: template
lights:
fireplace:
turn_on:
service: shell_command.fireplace_toggle
turn_off:
service: shell_command.fireplace_toggle
And then I'm using ssh_command
as described in another post to only allow the fireplace_ssh key to run the toggle
command.