A few hours of installing and deleting NPM packages later, I’ve got it working on Debian Buster (10). The steps below are the ones I have determined to work on my hardware and software, your mileage may vary.
Step 1: Install the pre-requisites for bluetooth to work:
apt-get install bluetooth bluez libbluetooth-dev libudev-dev
Step 2: Download the correct version of node,js from NodeSource (I went with 8.9.4 x64 because it’s still supported as v8 was an LTSR release)
THIS DOES NOT WORK WITH NODE 10x
cd /tmp
wget https://deb.nodesource.com/node_8.x/pool/main/n/nodejs/nodejs_8.9.4-1nodesource1_amd64.deb
Step 3: install the aforementioned package:
sudo dpkg -i nodejs_8.9.4-1nodesource1_amd64.deb
Step 4: install soma control with the necessary elevation to install the package globally (for all users):
sudo npm install --unsafe-perm -g [email protected]
Note: I went with 1.4.0 as I couldn’t get 1.4.1 to work
Step 5: check soma control works:
somactrl
If you seen an error message here, best of luck. It took me ~6 hours of digging around and learning about npm to get this bastard working. I had the most trouble with bluetooth-hci-socket when installing 1.4.1. Installing with 1.4.0 got me past this issue.
Step 5: Set somactrl to connect to your MQTT server
somactrl --mqtt-url mqtt://192.168.1.X -u homeassistant -p pAs$w0Rd
Step 6: Watch as your devices turn up in the integrations page in HomeAssistant! You should be seeing output similar to this to indicate successfully connecting to Soma blind motors:
soma* No device names supplied, will stop scanning after 30 seconds +0ms
soma* scanning for as many devices until timeout +4ms
soma* discovered c6######### +129ms
soma* discovered ef######### +87ms
soma* stopping scan after timeout +30s
As for how to get somactrl to start when the server starts? I don’t know yet. I’m thinking about a cron job that executes the command above using cron’s @reboot
timing. I’ll update my post when I have a working solution.
a few moments later
Autostarting Soma Control
Yep, crontab works!
Swap to an elevated user - you want this to run as root, otherwise you start encountering issues with some of the dependencies and whether they see your BT hardware as “authorised” or not.
Step 1: change directory to where you want to keep the script that the system is going to execute - I chose the home directory for the root account, which also hosts my backup scripts.
cd ~
Step 2: Use a text editor to create the script
nano soma-control.sh
Step 3: Add in the line you used to test somactrl in Step 5 in the section above:
somactrl --mqtt-url mqtt://192.168.1.X -u homeassistant -p pAs$w0Rd
Step 4: Save and close the file. Control+X usually does this.
Step 5: Make the file executable
chmod +x soma-control.sh
Step 6: Edit your crontab file to run the script soon after reboot
crontab -e
Add this at the bottom. Edit the sleep value to change how long after boot to wait to execute the script:
@reboot sleep 60 && /root/somactrl.sh
Step 7: Save and close the file. Control+X usually does this.
You’re done!
Miscellaneous related stuff:
- The bluetooth adapter I’m using is this one from Amazon UK, £11 at time of writing
- After this you’ll want to mark nodejs to not get upgraded, or you’ll lose the ability to use soma-ctrl until it works with Node 10.x
echo "nodejs hold" | sudo dpkg --set-selections
or
apt-mark hold nodejs
- Support for bluetooth hardware varies between kernels. If you’re having difficulties after following the steps above, a kernel upgrade may help. It may also break other things. You know your system better than I do, exercise caution.