Skip to content

Commit 2898a66

Browse files
committed
Merge branch 'develop'
2 parents 7cced20 + 37e3ccf commit 2898a66

33 files changed

+1393
-794
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
9+
[*.js]
10+
indent_style = space
11+
indent_size = 2
12+
13+
# Matches the exact files either package.json or .travis.yml
14+
[{package.json,.travis.yml}]
15+
indent_style = space
16+
indent_size = 2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,4 @@ $RECYCLE.BIN/
142142
*.lnk
143143

144144
# End of https://www.gitignore.io/api/osx,git,node,linux,macos,windows
145+
dist/

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js:
3+
- lts/*
4+
script:
5+
- "npm run lint"
6+
- "npm run build"

CHANGELOG.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [2.0.0] - 2020-03-01
5+
6+
****
7+
🚨 **This release is a major version and contains some breaking changes. Please read the list below.**
8+
****
9+
10+
### Changed
11+
12+
- Implementation of Somfy Open API, replacing unofficial TahomaLink API
13+
- Migration of the network layer from deprecated [request](https://www.npmjs.com/package/request) to [axios](https://www.npmjs.com/package/axios)
14+
- `tahoma-read` node now returns the raw response from the [Somfy Open API](https://developer.somfy.com/somfy-open-api/apis/get/site/%7BsiteId%7D/device}) (a remapping of your flows might be needed)
15+
16+
### Added
17+
18+
- New code quality control using TSLint
19+
20+
## [1.0.1] - 2019-08-21
21+
22+
### Changed
23+
24+
- Added door handle state support, contributed by [@matthub](https://github.com/matthub)
25+
426
## [1.0.0] - 2018-12-13
527

628
### Changed
@@ -16,7 +38,6 @@ All notable changes to this project will be documented in this file.
1638
- New `stop` action to immediatly stop the current action on the devices (See [#5](https://github.com/nikkow/node-red-contrib-tahoma/pull/5), thanks to [@Genosse274](https://github.com/Genosse274))
1739
- New CHANGELOG.md file to keep track of all updates.
1840

19-
2041
### Changed
2142

22-
- Fix path in getSetup() (See [#7](https://github.com/nikkow/node-red-contrib-tahoma/pull/7), thanks to [@hobbyquaker](https://github.com/hobbyquaker))
43+
- Fix path in getSetup() (See [#7](https://github.com/nikkow/node-red-contrib-tahoma/pull/7), thanks to [@hobbyquaker](https://github.com/hobbyquaker))

README.md

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,48 @@
1+
<p align="center">
2+
<img src="docs/images/somfy-logo.png">
3+
</p>
4+
15
# Somfy Tahoma for Node-RED
26

3-
![npm](https://img.shields.io/npm/v/node-red-contrib-tahoma.svg)
4-
![npm](https://img.shields.io/npm/dt/node-red-contrib-tahoma.svg)
7+
8+
[![npm](https://img.shields.io/npm/v/node-red-contrib-tahoma.svg)](https://www.npmjs.com/package/node-red-contrib-tahoma)
9+
[![Build Status](https://travis-ci.org/nikkow/node-red-contrib-tahoma.svg?branch=develop-v2)](https://travis-ci.org/nikkow/node-red-contrib-tahoma)
10+
[![npm](https://img.shields.io/npm/dt/node-red-contrib-tahoma.svg)](https://www.npmjs.com/package/node-red-contrib-tahoma)
511
![license](https://img.shields.io/github/license/nikkow/node-red-contrib-tahoma.svg)
12+
![code size](https://img.shields.io/github/languages/code-size/nikkow/node-red-contrib-tahoma)
13+
14+
## 🚨 Important Note vor v1.x users
15+
16+
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** :)
17+
18+
This new v2.0 version implements the Somfy Open API, which is officially available for third-party software as this one.
19+
20+
Even though your flows should not be modified, the [config-node](https://nodered.org/docs/user-guide/editor/workspace/nodes#configuration-nodes) must be reconfigured using this new API.
21+
22+
**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**.
623

724
## Setup
825

926
You can read this [guide](https://nodered.org/docs/getting-started/adding-nodes) from Node-RED official portal. This will help you install this node. Typically, the command are as follows:
1027

1128
cd $HOME/.node-red
12-
npm install node-red-contrib-tahoma
29+
npm install node-red-contrib-tahoma
1330

1431
## Disclaimer
15-
This software is provided as-is. Be careful: your devices can be totally controlled via API actions. I am not responsible of any mis-usage or corruption of the devices configuration.
32+
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.
1633

1734
## Configuration
1835

19-
In order to use this node, you need to have a Tahoma Link account. If you already use the Tahoma Box and the mobile apps, you should have one.
36+
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.
37+
38+
You will also need to create an app on the developer portal in order to retrieve a set of required credentials. This [guide](https://github.com/nikkow/node-red-contrib-tahoma/wiki/How-to-create-an-Somfy-Open-API-app%3F) will walk you through this process.
2039

21-
When creating your first node, you will be asked to provide your e-mail and password used to login to your Tahoma Link account. These will be used to connect to the API (of course, they will only be used locally, they are not forwarded to me :)).
40+
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 :)).
2241

2342
## Usage
2443

44+
### Node `tahoma`
45+
2546
This node accepts an object as input. The following properties will be parsed:
2647

2748
| Property | Type | Required? | Description |
@@ -30,7 +51,7 @@ This node accepts an object as input. The following properties will be parsed:
3051
| `position` | int (0-100) | *No* | The position you want to set your blinds/door to |
3152
| `lowspeed` | boolean | *No* | Should the action be triggered in low-speed mode? |
3253

33-
### Actions
54+
#### Actions
3455

3556
Currently, only a few commands are understood by this node. The possible values for the `action` property are:
3657

@@ -39,17 +60,25 @@ Currently, only a few commands are understood by this node. The possible values
3960
* `stop`: This will stop all running actions
4061
* `customPosition`: This will set the device to a custom position. The position is passed using the `position` property, which is required in this mode.
4162

42-
### Output
63+
#### Output
4364

4465
The node will output its original `msg.payload` enriched with the result of the expected action. `msg.payload.output` will contain 2 properties:
4566

4667
* `open`: a boolean. Set to true if the device is open, or false otherwise
4768
* `position`: an integer (0-100). Set to the position returned by the Tahoma box.
4869
* `luminance`: in case of a Sun Sensor, returns the current value of core:LuminanceState (See issue [#6](https://github.com/nikkow/node-red-contrib-tahoma/issues/6))
4970

71+
### Node `tahoma-read`
72+
73+
This node does not accept any input. You can specify the desired device by editing the node properties.
74+
75+
#### Output
76+
77+
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](https://developer.somfy.com/somfy-open-api/apis/get/site/%7BsiteId%7D/device).
78+
5079
## Example flow
5180

52-
![Example Flow](docs/example-flow.png)
81+
![Example Flow](docs/images/example-flow.png)
5382

5483
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.
5584

@@ -63,9 +92,28 @@ This was tested with the following devices:
6392

6493
Feel free to send any feedback of any other compatible items or known limitations :)
6594

66-
## To-do
95+
## FAQ / Troubleshooting
96+
97+
### I received a "Session expired" error, what happned?
98+
99+
![Session expired error](docs/images/ts-session-expired-node.png)
100+
101+
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](https://oauth.net/2/) protocol).
102+
103+
Both these tokens expire at some point.
104+
105+
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.
106+
107+
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.
108+
109+
#### What should I do?
110+
111+
This error is also described in the "Debug" tab of your node:
112+
113+
![Session expired error](docs/images/ts-session-expired-log.png)
114+
115+
All you need to do is open your node configuration, edit your account and follow the instructions on the yellow box:
67116

68-
These are the things that should be updated (and will be later) on this module:
117+
![Yellow box](docs/images/ts-session-expires-tip.png)
69118

70-
* Filter elements that can actually be controlled (e.g. do not display the "Active Button")
71-
* Find a way to properly handle "my" position
119+
**Note:** do not forget to **deploy** your flow, so the new credentials are properly saved.

core/tahomalink.js

Lines changed: 0 additions & 146 deletions
This file was deleted.
File renamed without changes.

docs/images/somfy-logo.png

11.7 KB
Loading
17.7 KB
Loading
10.7 KB
Loading
17.1 KB
Loading

0 commit comments

Comments
 (0)