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
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.
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
That sounds like a solid solution indeed. 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.
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.
One possible side effect is it loses the events that have occurred.
The system seems works as follows:
App logs in,
App registers for events,
App polls for events,
Any events that occurred since the last poll are returned.
App waits for the sync period to elapse.
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ā 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.
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
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:
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
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: