MadPatrick / somfy

Tahoma/Conexoon plugin for IO blinds, this plugin require internet connexion and a Somfy account
GNU General Public License v3.0
14 stars 3 forks source link

Local API support available for Conexxoon boxes #47

Closed JanJaapKo closed 1 year ago

JanJaapKo commented 1 year ago

Hey all,

According to Tweakers (Dutch tech site) and this issue Somfy-Developers/Connexxoon support the local API should now also be available for Conexxoon boxes.

@jcbraem, @Chaussette23 @Abidos14 @Tatroxitum I believe you guys own these boxes, could you test this?

jcbraem commented 1 year ago

Hello, Not OK for me but I'm not shure of my config !

somfy.log

2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Name':'Connexoon Somfy Vélux' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Port':'8443' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Username':'j*@.' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Password':'****' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Key':'tahomaIO' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Mode1':'False' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Mode2':'20' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Mode3':'0828--' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Mode4':'Local' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'Mode6':'Debug' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'DomoticzVersion':'2022.2' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'DomoticzHash':'eea9db734' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Parameter: 'DomoticzBuildTime':'2022-11-05 13:05:35' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Configuration count: 5 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Configuration 'MajorVersion':'4' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Configuration 'MinorVersion':'2' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Configuration 'patchVersion':'16' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Configuration 'plugin version':'4.2.16' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Configuration 'token':'63cbb7faba0fadc12784' 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Device count: 6 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Device: internal://0828-8553-9093/pod/0 - DeviceID: 'internal://0828-8553-9093/pod/0', Units: 1 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Device: io://0828-8553-9093/13219150 - DeviceID: 'io://0828-8553-9093/13219150', Units: 1 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Device: io://0828-8553-9093/15363054 - DeviceID: 'io://0828-8553-9093/15363054', Units: 1 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Device: io://0828-8553-9093/6070825 - DeviceID: 'io://0828-8553-9093/6070825', Units: 1 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Device: io://0828-8553-9093/7444963 - DeviceID: 'io://0828-8553-9093/7444963', Units: 1 2023-01-21 11:05:04.423 Connexoon Somfy Vélux: Device: io://0828-8553-9093/8877583 - DeviceID: 'io://0828-8553-9093/8877583', Units: 1 2023-01-21 11:05:04.424 Connexoon Somfy Vélux: os.path.exists(Parameters['Mode5']) = False 2023-01-21 11:05:04.424 Connexoon Somfy Vélux: Starting version: 4.2.16 2023-01-21 11:05:04.190 Status: Connexoon Somfy Vélux: Started. 2023-01-21 11:05:04.190 Status: Connexoon Somfy Vélux: Entering work loop. 2023-01-21 11:05:04.421 Status: Connexoon Somfy Vélux: Initialized version 4.2.16, author 'MadPatrick' 2023-01-21 11:05:04.423 Status: Connexoon Somfy Vélux: Location does not exist, logging to default location 2023-01-21 11:05:04.423 Status: Connexoon Somfy Vélux: Starting Tahoma blind plugin, logging to file somfy.log 2023-01-21 11:05:05.511 Error: Connexoon Somfy Vélux: Call to function 'onStart' failed, exception details: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: Traceback (most recent call last): 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: conn = connection.create_connection( 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 73, in create_connection 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3.9/socket.py", line 953, in getaddrinfo 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: for res in _socket.getaddrinfo(host, port, family, type, proto, flags): 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: socket.gaierror: [Errno -2] Name or service not known 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: During handling of the above exception, another exception occurred: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: Traceback (most recent call last): 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: httplib_response = self._make_request( 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 382, in _make_request 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: self._validate_conn(conn) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 1012, in _validate_conn 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: conn.connect() 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 353, in connect 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: conn = self._new_conn() 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 181, in _new_conn 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: raise NewConnectionError( 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f53501e8400>: Failed to establish a new connection: [Errno -2] Name or service not known 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: During handling of the above exception, another exception occurred: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: Traceback (most recent call last): 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: resp = conn.urlopen( 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: retries = retries.increment( 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 574, in increment 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: raise MaxRetryError(_pool, url, error or ResponseError(cause)) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='0828-8553-9093.local', port=8443): Max retries exceeded with url: /enduser-mobile-web/1/enduserAPI/events/register (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f53501e8400>: Failed to establish a new connection: [Errno -2] Name or service not known')) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: During handling of the above exception, another exception occurred: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: Traceback (most recent call last): 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/home/jcb/domoticz/plugins/somfy/plugin.py", line 575, in onStart 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: _plugin.onStart() 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/home/jcb/domoticz/plugins/somfy/plugin.py", line 171, in onStart 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: self.tahoma.register_listener() 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/home/jcb/domoticz/plugins/somfy/tahoma_local.py", line 254, in register_listener 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: response = self.listener.register_listener(self.base_url_local + "/events/register", headers=self.headers_with_token, verify=False) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/home/jcb/domoticz/plugins/somfy/listener.py", line 42, in register_listener 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: response = requests.post(url, headers=headers, verify=verify, timeout=timeout) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/requests/api.py", line 119, in post 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: return request('post', url, data=data, json=json, kwargs) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/requests/api.py", line 61, in request 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: return session.request(method=method, url=url, kwargs) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: resp = self.send(prep, send_kwargs) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: r = adapter.send(request, kwargs) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: raise ConnectionError(e, request=request) 2023-01-21 11:05:05.514 Error: Connexoon Somfy Vélux: requests.exceptions.ConnectionError: HTTPSConnectionPool(host='0828-8553-9093.local', port=8443): Max retries exceeded with url: /enduser-mobile-web/1/enduserAPI/events/register (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f53501e8400>: Failed to establish a new connection: [Errno -2] Name or service not known')) 2023-01-21 11:05:24.070 Error: Connexoon Somfy Vélux: Failed to request data: HTTPSConnectionPool(host='0828-8553-9093.local', port=8443): Max retries exceeded with url: /enduser-mobile-web/1/enduserAPI/setup/devices (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f53501e8730>: Failed to establish a new connection: [Errno -2] Name or service not known'))

Tatroxitum commented 1 year ago

I confirme I can now activate developper mode on my connexoon. I'll try local tonight

Le sam. 21 janv. 2023, 10:52, Jan-Jaap Kostelijk @.***> a écrit :

Hey all,

According to Tweakers (Dutch tech site) and this issue Somfy-Developers/Connexxoon support https://github.com/Somfy-Developer/Somfy-TaHoma-Developer-Mode/issues/9 the local API should now also be available for Conexxoon boxes.

@jcbraem https://github.com/jcbraem, @Chaussette23 https://github.com/Chaussette23 could you test this?

— Reply to this email directly, view it on GitHub https://github.com/MadPatrick/somfy/issues/47, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGVKL74DMKO45WFUML2FO7DWTOWUPANCNFSM6AAAAAAUCJ5FIY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

JanJaapKo commented 1 year ago

@jcbraem You need to take some steps like enable the developer mode in your account and make sure the DNS of the hub is known on the machine you run Domoticz on (see the readme of this plugin)

jcbraem commented 1 year ago

OK I have found the dev button in "my Somfy" ... I check others points ... Thanks.

vspamn commented 1 year ago

I can confirm local mode works on my Connexoon.

Tatroxitum commented 1 year ago

I can confirm too ! Status is OK at Plugin Startup, commands are OK, updates are then correctly done when changed outside of domoticz 😊.

Le sam. 21 janv. 2023, 16:54, vspamn @.***> a écrit :

I can confirm local mode works on my Connexoon.

— Reply to this email directly, view it on GitHub https://github.com/MadPatrick/somfy/issues/47#issuecomment-1399277370, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGVKL75YAJOJCKZWFG2FZ23WTQBBRANCNFSM6AAAAAAUCJ5FIY . You are receiving this because you were mentioned.Message ID: @.***>

jcbraem commented 1 year ago

Hello, For me also the local mode with Connexoon is available ! Great news : cloud independant and for Somfy many server request not necessary.

I have folowing the Somfy GIT to have one new token and honesty it is not simply for an no web developper. But with https://reqbin.com/ it is possible to call all requests API with all complex goods parameters in a little bit more than 2 hours for me ... and many Google to 'read and understand' HTTP language. This step is mandatory ? I have now 3 tokens, one new with API call from Solfy GIT and 2 olds for Domoticz already created but I don't remember why and when ... but shure not with web API call !

Probably you can change the sentences about Connexoon not supported in local mode :

In plugin Domoticz device : image

In your Git Readme : image

Many thanks for this important update.

MadPatrick commented 1 year ago

@jcbraem Thanks. Readme updated

Tatroxitum commented 1 year ago

Hi, For me I didn't have to request a new token to enable local mode. I' ve just changed Web to local, put the adress in etc/hosts and put the box id in the Plugin then enable it (without reseting token). In less than 2 minutes it was working. I don't know why you had all these difficulties ?

Le dim. 22 janv. 2023, 05:23, jcbraem @.***> a écrit :

Hello, For me also the local mode with Connexoon is available ! Great news : cloud independant and for Somfy many server request not necessary.

I have folowing the Somfy GIT to have one new token and honesty it is not simply for an no web developper. But with https://reqbin.com/ it is possible to call all requests API with all complex goods parameters in a little bit more than 2 hours for me ... and many Google to 'read and understand' HTTP language. This step is mandatory ? I have now 3 tokens, one new with API call from Solfy GIT and 2 olds for Domoticz already created but I don't remember why and when ... but shure not with web API call !

Probably you can change the sentences about Connexoon not supported in local mode :

In plugin Domoticz device : [image: image] https://user-images.githubusercontent.com/103622420/213900383-ee2f401f-d8f5-448c-bec0-cbb955a19ed8.png

In your Git Readme : [image: image] https://user-images.githubusercontent.com/103622420/213900429-84f384b7-910f-4525-b8bb-872e24540bfd.png

Many thanks for this important update.

— Reply to this email directly, view it on GitHub https://github.com/MadPatrick/somfy/issues/47#issuecomment-1399401410, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGVKL72SPBPOL7JDGW3KRBDWTSY2LANCNFSM6AAAAAAUCJ5FIY . You are receiving this because you were mentioned.Message ID: @.***>

jcbraem commented 1 year ago

I don't know why you had all these difficulties ?

Because I am very newbie in HTTP :) And now I think also these steps are not necessary. Only activate devmod in Somfy web is probably sufficient for last firmware version.

But I have read and following stupidly the Readme all steps and one is Somfy GIT page dev to get and activate token.

Abidos14 commented 1 year ago

Hello,

I'll try as soon as possible. But I'm stuck with a strange problem: each time I wont to connect to Somfy's site, I'm logged out after a few seconds... And therefore, impossible to make any change in my account.

I'll post back to tell if local API works for me. But if it's OK for others, I guess it should be the same on my side.

jcbraem commented 1 year ago

I'll try as soon as possible.

Hello, Could you check if for you also it OK without need a new token from Somfy website ? If it is not mandatory, probably an adaptation of Readme for simplify if possible :)

Chaussette23 commented 1 year ago

Hello !

First : I'm sorry for the delay in my response. I started some weeks ago to make my connexoon working and had some troubles, so I was a little active here but I had to do others things.

Thanks for having highlighted me here, and indeed, I have a connexoon so I will try this as soon as possible.

jcbraem commented 1 year ago

Hello, After 2 days and all Lua scripts I have only one remark, it is too many perfect. All call inside and outside Domoticz are very quickly retrieve with 20 seconds of delay ... and too many quickly, into log I have 3 lines for one open/close of Velux screen ... I have changed for 1 minute. When I have an restart/cut of my modem/connection web no error in log. I am happy with this version !

Your opignion, is this necessary for make the futur update of this box ? (nerver I use the Somfy apps) This Connexoon box have always need an web acces ? Honnesty I desire never an update with an bug or regression ...

Thanks for this great job!

JanJaapKo commented 1 year ago

So that all sounds very good! @MadPatrick perhaps we should make a baseline that people can refer back to when they really still want web acces, and after that remove it completely?

On the tokens: The plugin will, on first time, always ask for a token. Once it gets it, it will store it locally in Domoticz so it doesn't have to ask each time again (unless forced from the config of the plugin).

Should you want to clean up the tokens, you can do so with the command line tool test_tahoma.py. Unfortunately, the API does not display the token itself, so you cannot see which one is the latest one (I can make an improvement to put datetime into the name which is free text anyway). But lots of tokens don't really hurt anyway.

Abidos14 commented 1 year ago

Hello,

Yessssssss! Local mode is working great. Nothing special to do: I just switched to local mode, and on we go!! Simply do not forget to modify hosts file: I forgot to do so when I switched to local mode and ended with errors in Domoticz. Everything went back to normal after hosts file was modified to link box ip to box pin. Commands are OK and updates are very fast in Domoticz.

I'm really happy to get rid off Somfy's servers...

Thank you very much to all the people working on this plugin for your work and help here!! I'm really greatfull.

MadPatrick commented 1 year ago

So that all sounds very good! @MadPatrick perhaps we should make a baseline that people can refer back to when they really still want web acces, and after that remove it completely?

On the tokens: The plugin will, on first time, always ask for a token. Once it gets it, it will store it locally in Domoticz so it doesn't have to ask each time again (unless forced from the config of the plugin).

Should you want to clean up the tokens, you can do so with the command line tool test_tahoma.py. Unfortunately, the API does not display the token itself, so you cannot see which one is the latest one (I can make an improvement to put datetime into the name which is free text anyway). But lots of tokens don't really hurt anyway.

We can make a release of the current script make a reference to it in readme with a instruction how to pull this release.

Since Somfy is closing the support for web connection and people are having issue it agree to make only new developments for Local API and remove the web part. Both Connexoon and Tahoma boxes are working with Local API now

Chaussette23 commented 1 year ago

I confirm it works perfectly in local with the Connexoon.

At the beginning, I couldn't enable developper mode on Somfy website. I had to install the "TaHoma" application on my mobile, to trigger a Connexoon update. Then, the application wanted to switch my installation on a Tahoma box (?!) so I canceled and uninstalled the application. Then, the "local" mode of this plugin worked perfectly. I enable "create new token" just to be sure. Everything works perfectly and everything is updating accordingly.