nikkow / node-red-contrib-tahoma

Node-RED module to control a Somfy Tahoma box (Roller shutters...). Used for home automation flows.
Apache License 2.0
19 stars 11 forks source link

Authentication #9

Closed Palcooky closed 5 years ago

Palcooky commented 5 years ago

I seem to be having an issue since yesterday. I believe its related to authentication.

The module only works every now and then. It seems to no longer authenticate my requests.

For example this morning i opened the blinds and now a few mins later i am unable do open or close anything else. When i check the config no devices are listed in the drop down.

I checked the JavaScript used and created a python script (i don't really know JavaScript) to authenticate.

I found that the first run of the code i get a 200 response, if i run it again i get 401 responses. I am curious if tahome have changed something, or if we should be using some kind of authentication tokens or such.

taucher4000 commented 5 years ago

any update?

nikkow commented 5 years ago

It seems indeed that Somfy changed the API a bit. It is unfortunately a major risk when using undocumented APIs. I am currently investigating and trying to find a workaround.

OK, this is confirmed. Somfy implemented a request limit to its login API. The logic of the module must be reviewed so it doesn't trigger a new login before every call. I will work on that.

nikkow commented 5 years ago

I have pushed a fix for that "Too many requests" error. This is also published on NPM. Please update the plugin.

FrodoVDR commented 5 years ago

I still get this error (Too many requests, try again later : login with) after the update. In particular, the problem occurs when you want to query the light sensors regularly. In my case every 10 minutes.

I think the login of a node like this must now be done as follows (Somfy API Docs):

AUTHENTICATION

This section will detail how to authenticate to the Somfy API in order to get an access token that will allow you to perform actions through the Somfy API.

First step is to create your own client application of the Somfy API providing a name and valid Redirect URIs.

Then, you can use the following section to generate a valid access token using the Consumer key and Consumer secret generated.