[APP][Cloud & Pro] Somfy Tahoma & Connexoon (v4.0.37, test v4.0.75)

The app is still marked as compatibility >-2.0.0. So I ether have to support that or change it. I will probably increase that soon. But at the moment I just want users to update the app to relieve the Somfy servers so they hopefully go back to sleep and ignore us :wink:

Iā€™m not sure. The 401 means not authenticated. These will occur naturally as the server will end the session every so often. OAuth session last a maximum of 1 hour. The old method last much longer but I donā€™t know how long.
When you change the Sync Speed it just stops the polling timer and starts it again with the new value. So no logging in or out, etc.so I canā€™t think why that would cause the problem.
Maybe the old session length is based on the time of the last communication. So polling every 10 seconds keeps the session alive but a quiet period of 600 seconds allows the session to terminate.
It should recover from those automatically so even though one appears in the log it should just trigger a new login.

1 Like

I use the old method and indeed I think with 10 seconds it keeps the session alive and with 600 seconds not. I do get the error already after a few minutes when sync is set to 600.
But is there a solution? Cause right now, the moment I press for example a tile of a device (roller shutter) I receive this 401 error. When I press the same tile a 2nd time (within 1 sec) then the device does react.
So somehow the app should authenticate (open the session) first and then it should send a request to the servers. Right now itā€™s apparently the opposite and because of that I receive this message?

What it should do is assume the session is authenticated once logged in but if it gets one 401 it should login again and then retry the command.
If a session is already authenticated then the app has to log out first before it can authenticate again. Logging in and out puts quite a load on the server so I try to keep that to a minimum.

Obviously if it fails to send the command then something is not as it should be. I will set my sync speed to 600 and see what happens. Obviously my door sensors and Sunis are not very useful at that speed though :slight_smile:

That sounds like a solid solution indeed. :smiley: And the first time itā€™s not needed to show an error (it scares people), cause probably after logging in and a retry of the command the device will work.

Correct, but in my case, nothing is wrong. Cause within 1 second the device does work.
So of course when the 401 remain then indeed the error is valid and not because of some timeout of the previous session. If I could help to debug something, then please let me know and I will try that.

Iā€™m getting a certificate error when trying to login. Iā€™m on v2.1.0. Is anyone else getting this? Any ideas for a workaround?

I think I have found the problem.
I have withdrawn the request to publish 2.1.1 and will have 2.1.2 ready soon.

Try with the Use new OAuth method not ticked.

Cool, when itā€™s there I will test it :slight_smile:

Works, thanks. Simple enough, shouldā€™ve tried that but thought that was what got Somfy up in arms the first time around. Thanks for all your patience and endurance on this Adrian. Really appreciate it.

No problem. The OAuth feature was added for some users that seem to have different accounts that canā€™t login with the old method.

Itā€™s ready :slight_smile:

I installed it and no error so far. I will try it once in a while with sync speed set at 600 :slight_smile:
Thanks! With 2.1.0 it was quite easy to reproduce so.

Edit:
Seem to work fine, I do see the token expired message in the log, but I donā€™t see an error and directly after that the app logs in:

  {
    "time": "2020-10-13T17:18:55.630Z",
    "source": "post",
    "data": {
      "message": "Access token expired -> logging in again",
      "stack": ""
    }
  },
  {
    "time": "2020-10-13T17:18:55.634Z",
    "source": "Tahoma Login",
    "data": {
      "message": "Start",
      "stack": ""
    }
  },
  {
    "time": "2020-10-13T17:18:56.362Z",
    "source": "Tahoma Simple Login",
    "data": {
      "message": "Successful",
      "stack": {
        "success": true,
        "roles": [
          {
            "name": "ENDUSER"
          }
        ]
      }
    }
  }
]

One possible side effect is it loses the events that have occurred.

The system seems works as follows:

  1. App logs in,
  2. App registers for events,
  3. App polls for events,
  4. Any events that occurred since the last poll are returned.
  5. App waits for the sync period to elapse.
  6. Repeat from step 3.

However, if the session is closed before the sync period has elapsed, it forgets all the events and cancels the registration.

So I will probably have to do some more work on that if users are going to have long sync times.
At the very least I will need to fetch all the state values again when the login is done.

Ok clear, in the meantime I will try to find the ā€˜sweet spotā€™ :slight_smile: to figure out the time span when a session is closed. I was a long time on 30sec without errors. So somewhere between 30 and 600 seconds.

1 Like

Great Thanks work, all mā€™y blindĆ©s and Velux integrated (over 40) and updated all flows.

1 Like

I tried it with 2.1.0, cause then I could clearly see the 401 error that have been fixed in 2.1.2.

Sync speed at 250 gave no errors, sync speed at 275 did. Then I tried 265 and I got no errors, but when I wanted to try it again it was automatically updated to 2.1.2. So my backup plan would be to check the log and so far no issue. I think I will set it to 240, then I have a poll ratio of 15x hour (360x per day). Enough for just roller shutters :slight_smile:

The weird part is that during my tests I suddenly had to switch to OAuth on, while I was always on the old method. So maybe Somfy is upgrading accounts to force OAuth? If I didnā€™t use OAuth I received:

1 Like

On the new version you should see the status message ā€œToken expired - Login Againā€, or something like that, instead of the Error: ā€¦ 401

I have a feeling Somfy are switching accounts to OAuth to tray and block others from using their API.
I am think I might make a change to automatically try each method and remove the option.

But does the introduction of OAuth really block people using their API? Cause once you knew, you managed to build OAuth support and people could use it again. Or is it a way from Somfy to makes things just more difficult.

Good to know :slight_smile:

For a lot of people that would be much easier and prevents a lot of questions.

It certainly does make it more difficult and it is very easy for them to change some things again.
Also it forces the integrators to review their methods, some of which might not bother.

The three developers of the Home Assistant plugins and myself are still in contact with Somfy. The main issue Somfy has is the constant access to the API required for the automations to work.
It seems they might be happy if we were to use it purely for control where we login, move a cover, logout. But that would mean Homey has no state information when a cover is moved by something else, like a remote or Tahoma. Their main argument is that Tahoma / Connexoon should be the automation controller and not a connection point for something else.

Thatā€™s probably why there is no local API and everything needs to go to through their servers. They should be happy people bought a connexoon or Tahoma in the first place.

They need to grow up and listen to their customers who are right now happy with somfy in combination with Homey. Like you said some posts ago, they should invest in a better api, to reduce the load. Like this:

3 Likes