Note: I have a couple of Amazon links in here, but these aren't going to track you - I just have them to document the components I used.
I'm trying to get rid of my Amazon FireTV Cube. The last remaining feature I use is saying "Computer, turn off the TV" before I go to bed. I'd like to switch this over to "Hey Mycroft, turn off the TV". This documents my journey.
The first step was building a Mycroft AI. I've been waiting a few years for this; then finally I realized they had open source software and people are already using it on raspberry pi. I used https://pishop.us since it was a bit cheaper than buying a pre-assembled kit, but I could still buy all the components.
The key other feature was a nice speaker. I went expensive with the Jabra Speak 410 but probably any USB speakerphone would have worked. The Picroft setup script tried to scare me off from using a USB speakerphone but it's been working fine once I did a bit of configuration on the
Installing mycroft was fairly easy using their documentation.
So I had all this working but my next major step was getting the remote control working. This is where I made a mistake - I bought a random IR transmitter off of Amazon: IR Transmitter Infrared Remote Hat Expansion Board 38KHz Transceiver Shield for Raspberry Pi. If you check out the Amazon page, this is a super confusing component and the documentation is pretty incomplete.
I found a few tutorials online, but once I got back around to the Amazon page I found their documentation worked (once I found it): https://m.media-amazon.com/images/I/71MHFPQWhuL.pdf. Apparently LIRC recently did a big upgrade and so the /etc/init.d commands didn't work for me. I needed to use
sudo systemctl stop lircd and
sudo systemctl start lircd while doing my various tests.
Some highlights: I didn't need any changes to /etc/modules, but I did need changes to /boot/config.txt. I did add a /etc/lirc/hardware.conf, although I'm not sure what it's doing yet.
mode2 -d /dev/lirc0 worked well for me, but
irrecord did not.
For whatever reason, every time I tried using
irrecord to record my TV's remote's signals, it seemed to work fine the whole way, but then it would give me output like:
KEY_POWER 0x0 KEY_INFO 0x0 KEY_MODE 0x0
i.e. it wasn't able to detect the codes. Online, it said I needed to apply a patch to the LIRC software to make this work... but I was already using buster, which includes said patch. So I don't know what went wrong.
I was able to get it working once I found an existing config file for my remote. For some reason, I couldn't find any sceptre remotes in the main lirc database (http://lirc-remotes.sourceforge.net/remotes-table.html). When I googled, I was able to find a very-incomplete file that worked for some buttons on my remote: https://github.com/msarahan/unified-lirc-remote/blob/master/remote_confs/sceptre-u507.conf.
This cracked the case open. I added 16 buttons I found using
irrecord --list-namespaces and put them in with arbitrary codes (0x010, 0x020, 0x030...) tagged with BUTTON_TRIGGERHAPPY...BUTTON_TRIGGERHAPPY15. I have no idea what these BUTTON codes mean, but they conveniently had 16 alternatives I could use to map the hexidecimal space. I ran through 0x000 to 0xFF0 using this strategy and after two passes of pushing every button on my remote I had it mapped out.
I'm going to submit this remote config file to the main LIRC database, but I need a bit of prep work first to map the remote. For now I'm happily turning my TV on and off with a little shell script I wrote:
#!/bin/bash KEY=$1 irsend send_start sceptre-e505bv $KEY sleep .1 irsend send_stop sceptre-e505bv $KEY
which I can use like
sendkey.sh KEY_POWER. I had to make sure my pi was placed at just the right spot near my TV, but right now it's working even with the little case mostly covering the LED on the board.
My next step is to figure out why the systemd lirc doesn't work - it seems like the
--nodaemon option breaks the functionality somehow. Then it's on to making a Mycroft skill! I'll try to remember to update here when I do.