This gem is a Ruby library for interacting with Somfy RS-485 motorized shades, primarily ST/Sonesse 30 DC models. There is very little documentation on the protocol, and it has been further reverse engineered by various individuals, and by capturing traffic from a Somfy UAI+, and referencing the output of the Somfy SDN Frame Builder tool.
An MQTT Bridge is provided to allow easy integration with other systems. You
will need a separate MQTT server running (Mosquitto is
a relatively easy and robust one). The MQTT topics follow the Homie
convention, making them self-describing. If you're
using a systemd Linux distribution, an example unit file is provided in
contrib/sdn_mqtt_bridge.service
. So a full example would be (once you have
Ruby installed):
gem install somfy_sdn
sudo curl https://github.com/ccutrer/somfy_sdn/raw/master/contrib/sdn_mqtt_bridge.service -L -o /etc/systemd/system/sdn_mqtt_bridge.service
<modify the file to pass the correct URI to your MQTT server, and path to RS-485 device>
sudo systemctl enable sdn_mqtt_bridge
sudo systemctl start sdn_mqtt_bridge
Serial ports over the network are also supported. Just give a URI like tcp://192.168.1.10:2217/ instead of a local device. Be sure to set up your server (like ser2net) to use 4800 baud, ODD.
Once you have it connected and running, you'll like want to Publish true
to
homie/sdn/discovery/discover/set
to kick off the discovery process and find
existing motors. When motors are commanded to move, it will automatically poll
their status and position until they stop. This also works for groups.
Note that several properties support additional value payloads than Homie would otherwise define in order to access additional features:
- /positionpercent: UP, DOWN, and STOP are supported to allow directly connecting a single OpenHAB Rollershutter item to it.
- /downlimit and /uplimit also support
delete
,current_position
,jog_ms
, andjog_pulses
in addition to a specified position in pulses. For the two jog options, an distance of 10 (ms/pulses) is assumed. - /ippulses and /ippercent also support
delete
andcurrent_position
.
Other properties of note:
- /groups is a comma separated list of group addresses. Groups have addresses from 01.01.01 to 01.01.FF. A motor can be a member of up to 16 groups. Be aware that if you have a UAI+ also on the network, it does NOT query group membership from motors, and instead keeps everything cached locally, so will not reflect any changes you make outside its control. Groups also don't have names.
If you're going to integrate with OpenHAB, you'll need to install the
MQTT Binding
in Add-ons
. Then go to Inbox, click +
, select MQTT Binding
and click ADD MANUALLY
near the bottom. First create a Thing for the
MQTT Broker
and configure it to point to your MQTT server. At this point you
can create a Homie MQTT Device
, but I don't recommend it because OpenHAB
Homie nodes as channel groups instead of individual things, and this can become
quite cluttered if you have many shades. Instead, you go for generic MQTT
things, and configure them manually.
Example Things file:
Thing mqtt:topic:072608 "Master Bedroom Shade" (mqtt:broker:hiome) @ "Master Bedroom"
{
Channels:
Type rollershutter : shade "Shade"
[
stateTopic = "homie/somfy/072608/positionpercent",
commandTopic = "homie/somfy/072608/positionpercent/set"
]
}
Example Items file (including configuration for exposing to HomeKit):
Rollershutter MasterShade_Rollershutter "Master Bedroom Shade" [ "WindowCovering" ] { channel="mqtt:topic:072608:shade", autoupdate="false" }
Example Rules file for maintaining HomeKit state:
Example sitemap snippet:
Text label="Master Bedroom" icon=bedroom {
Frame {
Default item=MasterShade_Rollershutter label="Shade"
}
}
This gem supports using an RS-485 direct connection. It is possible to directly connect to the GPIO on a Raspberry Pi, or to use a USB RS-485 dongle such as this one from Amazon. The key is identifying the correct wires as RS-485+ and RS-485-. It's easiest to connect to the Data Pass-through port of the Bus Power Supply using an ethernet patch cable. You'll cut off the other end, and connect pins 1 and 2 (white/orange and orange for a TIA-568-B configured cable) to + and - on your dongle:
These projects are all in various states, and may be more or less developed than this one in varying aspects.