Soma blind control via MQTT

mqtt
Tags: #<Tag:0x00007f47f94fd420>

#1

I have a few of these Soma blind control units which you just attach to your blind cord and it pulls them up or down.
It comes with a smartphone app for manual or scheduled control (you talk to the devices with Bluetooth low energy), but to integrate with other systems (Alexa, Google Assistant & HomeKit), they have a separate $100 bridge.

I’d rather that they just worked with Home Assistant though, and then bridge them over to HomeKit etc., via hass, so I created this project to bridge controlling them with MQTT; it’s written in node and the bluetooth control library I’m using works on the Mac, and on Raspberry Pi’s
I’m pushing the right topics into MQTT so that the cover devices are discovered automatically, all you need to have in your hass config is:

mqtt:
  discovery: true

You should end up with cover devices for each blind controller that was discovered, and a sensor to keep track of their battery levels:

Project links:



#2

Was wondering if there was a way to do this, as connecting into the much more expensive controller based electric style blinds seemed a bit over kill. Will have to see where I can find some of these units.

Whats the reliability like with opening and closing? Had any jam up?


#3

In general very good. They’re not super fast, but they get the job done.
For one blind I’ve had to reset the calibration of where the top and bottom is a couple of times as it’s drifted and opened too far or not fully closed, but it’s isloated to 1 out of the 4 I have and I think it’s the blind itself that needs tightening up on either side to avoid this going forward.


#4

I wish I can use this, but somehow I can’t npm install bluetooth-hci-socket, which is required to run your tool. Do you mind share your setup like the OS version and node version?


#5

I’ve only really tested it on the Mac where that dependency isn’t needed, but I just tried installing it on an older Raspberry Pi – without BTLE, so can’t actually test if it fully works – but the install did complete.

Are you using node 10.x? I’ve seen some incompatibilities with some of the dependencies and node 10.x… so I’d downgrade to an older major version of node for now if that’s the case.
Otherwise let me know what the error is and I can look into it; probably best to open up an issue on the GitHub for that


#6

After using node 9.11 and installing some build essentials(I completely missed this since I was doing this in a container), I was able to make somactrl working. However, I can’t detect my device.

[email protected]:/# somactrl --url mqtt://192.168.31.165
soma* No device names supplied, will stop scanning after 30 seconds +0ms
soma* scanning for as many devices until timeout +11ms
soma* stopping scan after timeout +30s

Sorry, I just received this device so I am new to it. What exactly should I do to make it discovered by somactrl. Shall I run somactrl and press the device(as described in the manual)? Shall I use the app to calibrate it first and re-connect with the raspberry pi where somactrl was running at?


#7

Calibrate it with the app first. I think that may be why it’s not picking up any devices.
After that’s done, close the app on your phone/tablet so it disconnects and it should then be discoverable for your pi.


#8

I’m trying to run this on a Raspberry Pi Zero and I’m getting:
-bash: somactrl: command not found

I installed noble as well.

Any ideas what I’m missing? Thanks!


#9

Hmm… did you install globally with “npm install -g”? If not I think it will get installed to whichever folder you ran the command in, at node_modules/.bin/somactrl
Maybe run a find on your pi to see if there exists a ‘somactrl’ file anywhere?

Otherwise, we should probably look over the output from the npm install to see what went wrong.


#10

Hi @andersonshatch this is the message I get when I install it:
/opt/nodejs/bin/somactrl -> /opt/nodejs/lib/node_modules/soma-ctrl/index.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/soma-ctrl/node_modules/xpc-connection):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“arm”})

Then when I do a find somactrl I get this:
find: ‘somactrl’: No such file or directory


#11

No errors there… maybe where it is being installed is just not on your PATH variable?

Does it start ok if you use the full path? e.g.
/opt/nodejs/bin/somactrl,
or
node /opt/nodejs/lib/node_modules/soma-ctrl/index.js


#12

Awesome thanks, I think that’s the issue it’s running when I do /opt/nodejs/bin/somactrl

I have home assistant running on one raspberry pi, and somactrl running on another. I’m still not seeing the controls in Home Assistant, do I have to setup a MQTT broker on one of them? Sorry, I haven’t used MQTT before.

Thanks for your help, I’m really looking forward to this, I had it setup with homekit before with homebridge and python and it was really slow.


#13

Actually it’s asking me to run under sudo and then this is the error I get:

[email protected]:~ $ sudo /opt/nodejs/bin/somactrl --url mqtt://raspberrypi.local
soma* No device names supplied, will stop scanning after 30 seconds +0ms
soma* scanning for as many devices until timeout +38ms
soma* connected to RISE62 +2s
/opt/nodejs/lib/node_modules/soma-ctrl/src/SomaShade.js:147
this.positionCharacteristic.subscribe();
^

TypeError: Cannot read property ‘subscribe’ of undefined
at peripheral.discoverSomeServicesAndCharacteristics (/opt/nodejs/lib/node_modules/soma-ctrl/src/SomaShade.js:147:45)
at Peripheral. (/opt/nodejs/lib/node_modules/soma-ctrl/node_modules/noble/lib/peripheral.js:101:13)
at Service. (/opt/nodejs/lib/node_modules/soma-ctrl/node_modules/noble/lib/service.js:53:7)
at Object.onceWrapper (events.js:324:30)
at emitOne (events.js:125:13)
at Service.emit (events.js:221:7)
at Noble.onCharacteristicsDiscover (/opt/nodejs/lib/node_modules/soma-ctrl/node_modules/noble/lib/noble.js:302:13)
at emitThree (events.js:145:13)
at NobleBindings.emit (events.js:227:7)
at NobleBindings.onCharacteristicsDiscovered (/opt/nodejs/lib/node_modules/soma-ctrl/node_modules/noble/lib/hci-socket/bindings.js:339:8)


#14

Ah :frowning:
Looks like it couldn’t find a move characteristic on the device it connected to, which is rather odd; does that happen every time?
I wonder if maybe you have a different version of the device/firmware.
Probably best to continue this discussion as an issue on the github project, I can at least generate a version with more logging to see how your device differs if the issue persists.

In answer to your earlier question, yeah, you’ll need an MQTT broker somewhere and home assistant hooked up to that broker with discovery turned on. You can just use the built-in hass MQTT broker.


#15

Couple of questions for you here. Was considering purchasing a couple of these soma units however my current shades have connector pieces that are used to prevent the shade from raising to high (a clip that connects the two ends together that is larger then the chain itself). Would that piece work with the units? Second any plans on making this available as an install for hassio?


#16

I don’t think the connector piece would fit through the soma; the devices come with a white beaded cord that has no joins which I’ve put on my blinds. Once you’ve installed them, you don’t really need to have the piece to stop the blind rising too high as you calibrate the top and bottom position when setting them up with the app.

Regarding the hassio add-on… I’ve not yet tried hassio at all myself, I am running hass and the soma-ctrl utility on a Mac, I don’t have a pi with BTLE to test either, so I’m not sure what is involved, or whether it is possible to access bluetooth devices directly whilst in that environment. So, not a no, but maybe someone else would know better about it.


#17

Ohh thank you so much didn’t realize it came with its own cord. That’s a pretty smart idea keeps things consistent for their design. I will probably order one and see how it works. As for hassio that’s totally understandable. I come from a programming background but hass is a bit new to me I will check into what would be involved, no promises lol but gives me a good excuse to dive deeper into the environment. Thanks!


#18

Finally got it! I installed soma-ctrl and mosquitto on a Raspberry Pi Zero W. Ran this command:
sudo /opt/nodejs/bin/somactrl RISEXX --url mqtt://brokerIP

brokerIP is the IP of my Raspberry Pi Zero W.

Then in my Home Assistant config I did this:

mqtt:
broker: brokerIP
discovery: true
discovery_prefix: homeassistant

So far so good!


#19

Do I need the soma connect device or I just need the smart shade device and connect them directly to home assistant?


#20

No need for the soma connect this way. Just the smart shade device and some device (like a recent Raspberry Pi) with Bluetooth LE support where you can run a node app.