To control some connected electronics (soundbar, turntable, preamp, printer, etc) from a physical mini keyboard.
- Turn on/off printer
- Turn on/off soundbar + turntable
- Turn on/off soundbar + select mode for movie watching or music streaming
- Expose to HomeAssistant as MQTT device(s) to eventually control it via intents.
- Raspberry Pi 2B
- Relays controller with 4 relays
- YSP-4000 soundbar (see ysp4000 repository)
- Dumb but solid Dell 1700 printer (CUPS + Lexmark E234 PPD)
- Turntable and preamp
Inspired by this blog post
cat /proc/bus/input/devices
Take vendor id and product id and created udev rule
sudo bash -c 'cat > /etc/udev/rules.d/KeyPad.rules << EOF
ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="06b0", SYMLINK+="input/keypad"
EOF'
sudo udevadm control --reload
Now the keyboard can be opened as /dev/input/keypad
device:
keypad = InputDevice('/dev/input/keypad')
python3 -m build
On the device
pip3 install --upgrade --user git+https://github.com/pzbitskiy/media_center_kb
# Run in foreground with verbose logging to ensure it works as intended
mediackb -v
Create systemd service
sudo bash -c 'cat > /etc/systemd/system/media-center-kb.service <<EOF
[Unit]
Description=Media center keyboard daemon
[Install]
WantedBy=multi-user.target
[Service]
User=pi
ExecStart=mediackb
Type=idle
RemainAfterExit=no
Restart=on-failure
EOF'
sudo systemctl daemon-reload
sudo systemctl start media-center-kb
sudo systemctl enable media-center-kb
Ensure it is running
sudo systemctl --type=service --state=running
python3 -m venv .venv
source .venv/bin/activate
pip install -e '.[tests]'
# or pip3 install -e -r requirements.txt
pytest