This is a small Python script that waits for keyboard input at the console. Keyboard inputs trigger calls to the Sonos HTTP API [1], which controls various Sonos functions.
The script is especially useful with a FLIRC [2], a USB dongle that is programmed to recognise infrared (IR) codes from arbitrary IR remotes, and then translates them into keyboard key-presses. Using the script with a FLIRC enables IR control of Sonos systems.
The script can also be used with anything else that presents as a keyboard connected directly to the computer on which the script is running. Note that since the script runs as a console program, it's only really suitably hosted on headless hosts. I run it on a Raspberry Pi near the Sonos CONNECT that it controls.
A working Python environment running on a suitable host, and a working installation of Sonos HTTP API [1] running either on the same host or elsewhere on the local network. The script should work under Python 2 or 3.
The script is intended to run as a console program in order to accept keyboard input from a directly attached keyboard, FLIRC, etc.
The script is tested on Linux but includes untested support for Windows.
The file config.py needs to be edited for your needs. See the steps within the file. The script is run using python sonoskeycontroller.py.
[1] https://github.com/jishi/node-sonos-http-api
[2] https://flirc.tv/more/flirc-usb