Control a Somfy Tahoma box from Node RED
Somfy Tahoma for Node-RED
🚨 Important Note vor v1.x users
Due to a recent change in the API used in v1, most of you were encountering issues during the configuration of your node (e.g. empty device list...). This API was unofficial and we had no control over it :)
This new v2.0 version implements the Somfy Open API, which is officially available for third-party software as this one.
Even though your flows should not be modified, the config-node must be reconfigured using this new API.
However, please note that even though this release was tested before being published, you might encounter unexpected issues. Please backup your flow before proceeding with this major release.
You can read this guide from Node-RED official portal. This will help you install this node. Typically, the command are as follows:
cd $HOME/.node-red npm install node-red-contrib-tahoma
This software is provided as-is. Be careful: your devices can be fully controlled via API actions. I am not responsible of any mis-usage or corruption of the devices configuration.
In order to use this node, you need to have a Somfy account. If you already use the Tahoma Box and the mobile apps, you should have one.
You will also need to create an app on the developer portal in order to retrieve a set of required credentials. This guide will walk you through this process.
When creating your first node, you will be asked to provide your e-mail and password used to login to your Somfy account. These will be used to connect to the API (of course, they will only be used locally, they are not forwarded to me :)).
This node accepts an object as input. The following properties will be parsed:
||enum (see below)||Yes||The action to perform|
||int (0-100)||No||The position you want to set your blinds/door to|
||boolean||No||Should the action be triggered in low-speed mode?|
Currently, only a few commands are understood by this node. The possible values for the
action property are:
open: This will open the device (door, blind...)
close: This will close the device
stop: This will stop all running actions
customPosition: This will set the device to a custom position. The position is passed using the
positionproperty, which is required in this mode.
The node will output its original
msg.payload enriched with the result of the expected action.
msg.payload.output will contain 2 properties:
open: a boolean. Set to true if the device is open, or false otherwise
position: an integer (0-100). Set to the position returned by the Tahoma box.
luminance: in case of a Sun Sensor, returns the current value of core:LuminanceState (See issue #6)
This node does not accept any input. You can specify the desired device by editing the node properties.
The node will output its original
msg.payload enriched with the selected device information. A full example can be found on the Somfy Open API documentation.
An example flow can be found in the docs/ folder. Basically, all it does is close and open shutters based on manual triggers. Those can be replaced by some logic (e.g. a node calculating the sunset and sunrise times). The output is sent to a local MQTT broker.
This was tested with the following devices:
- IO-HomeControl Roller Shutters
- IO-HomeControl Garage Door
- Sunea IO Awning (thanks to @xeor)
Feel free to send any feedback of any other compatible items or known limitations :)
FAQ / Troubleshooting
I received a "Session expired" error, what happned?
During the login process, Somfy generates a set of credentials composed of two tokens: the first is called an access token and the second a refresh token (following the OAuth2 protocol).
Both these tokens expire at some point.
The access token (used to authenticate each request sent to Somfy API) has a very short lifetime (1 hour) and needs to be regenerated afterwards. To prevent you from entering your e-mail/password each hour, the refresh token handles this new authentication. Whenever the access token expires, a new authentication request is sent and Somfy generates a brand-new set of tokens.
However, the refresh token has not an infinite lifetime. It expires after 14 days. Basically, it means that if node-red hasn't reached the Somfy API for 14 days + 1 hour, both your token have expired and you need to login again.
What should I do?
This error is also described in the "Debug" tab of your node:
All you need to do is open your node configuration, edit your account and follow the instructions on the yellow box:
Note: do not forget to deploy your flow, so the new credentials are properly saved.