Bonjour à tous,
Comme d’autres, je suis propriétaire d’un KLF200 en remplacement d’une tahoma pour lequel les serveurs somfy avec leur limitation d’appels API et leurs indisponibilités récurrentes m’ont tourné vers une solution locale. Verdict temporaire: C’est pire. La connexion vers l’API de la KLF200 tombe plusieurs fois par jour et le smart plug situé sur son alim la redémarre n’y change rien.
Voilà ce que j’obtiens en fermant tous mes volets somfy(9) et velux(3) AVEC SUCCES via l’équipement « All RollerShutter »:
[2021-01-25 17:53:26][DEBUG] : Action /set/5/0
[2021-01-25 17:53:26][DEBUG] : Send http://localhost:9123/set/5/0
[2021-01-25 17:53:26][DEBUG] : Result {"result": "ok", "device": 5, "position": "100 %"}
[2021-01-25 17:53:26][DEBUG] : Action /set/11/0
[2021-01-25 17:53:26][DEBUG] : Send http://localhost:9123/set/11/0
[2021-01-25 17:53:26][DEBUG] : Result {"result": "ok", "device": 11, "position": "100 %"}
[2021-01-25 17:53:26][DEBUG] : Action /set/3/0
[2021-01-25 17:53:26][DEBUG] : Send http://localhost:9123/set/3/0
[2021-01-25 17:53:27][DEBUG] : Result {"result": "ok", "device": 3, "position": "100 %"}
[2021-01-25 17:53:27][DEBUG] : Action /set/4/0
[2021-01-25 17:53:27][DEBUG] : Send http://localhost:9123/set/4/0
[2021-01-25 17:53:27][DEBUG] : Result {"result": "ok", "device": 4, "position": "100 %"}
[2021-01-25 17:53:27][DEBUG] : Action /set/6/0
[2021-01-25 17:53:27][DEBUG] : Send http://localhost:9123/set/6/0
[2021-01-25 17:53:27][DEBUG] : Result {"result": "ok", "device": 6, "position": "99 %"}
[2021-01-25 17:53:27][DEBUG] : Action /set/7/0
[2021-01-25 17:53:27][DEBUG] : Send http://localhost:9123/set/7/0
[2021-01-25 17:53:28][DEBUG] : Result {"result": "ok", "device": 7, "position": "100 %"}
[2021-01-25 17:53:28][DEBUG] : Action /set/10/0
[2021-01-25 17:53:28][DEBUG] : Send http://localhost:9123/set/10/0
[2021-01-25 17:53:28][DEBUG] : Result {"result": "ok", "device": 10, "position": "99 %"}
[2021-01-25 17:53:28][DEBUG] : Action /set/9/0
[2021-01-25 17:53:28][DEBUG] : Send http://localhost:9123/set/9/0
[2021-01-25 17:53:28][DEBUG] : Result {"result": "ok", "device": 9, "position": "100 %"}
[2021-01-25 17:53:28][DEBUG] : Action /set/0/0
[2021-01-25 17:53:28][DEBUG] : Send http://localhost:9123/set/0/0
[2021-01-25 17:53:29][DEBUG] : Result {"result": "ok", "device": 0, "position": "99 %"}
[2021-01-25 17:53:29][DEBUG] : Action /set/8/0
[2021-01-25 17:53:29][DEBUG] : Send http://localhost:9123/set/8/0
[2021-01-25 17:53:29][DEBUG] : Result {"result": "ok", "device": 8, "position": "100 %"}
[2021-01-25 17:53:29][DEBUG] : Action /set/1/0
[2021-01-25 17:53:29][DEBUG] : Send http://localhost:9123/set/1/0
[2021-01-25 17:53:29][DEBUG] : Result {"result": "ok", "device": 1, "position": "100 %"}
[2021-01-25 17:53:29][DEBUG] : Action /set/2/0
[2021-01-25 17:53:29][DEBUG] : Send http://localhost:9123/set/2/0
[2021-01-25 17:53:30][DEBUG] : Result {"result": "ok", "device": 2, "position": "100 %"}
[2021-01-25 17:54:03][DEBUG] : Send http://localhost:9123/devices
[2021-01-25 17:54:03][DEBUG] : Result {"result": "ok", "devices": [{"id": 0, "name": "Palier", "type": "RollerShutter", "position": 0}, {"id": 1, "name": "S\u00e9jour-chemin\u00e9e", "type": "RollerShutter", "position": 0}, {"id": 2, "name": "S\u00e9jour-entr\u00e9e", "type": "RollerShutter", "position": 0}, {"id": 3, "name": "Bureau-C\u00e9cile", "type": "RollerShutter", "position": 0}, {"id": 4, "name": "Cellier", "type": "RollerShutter", "position": 0}, {"id": 5, "name": "Bureau-Cyrille-Fen\u00eatre", "type": "RollerShutter", "position": 0}, {"id": 6, "name": "Chambre-Jos\u00e9phine", "type": "RollerShutter", "position": 0}, {"id": 7, "name": "Chambre-parents", "type": "RollerShutter", "position": 0}, {"id": 8, "name": "Salon", "type": "RollerShutter", "position": 0}, {"id": 9, "name": "Cuisine", "type": "RollerShutter", "position": 0}, {"id": 10, "name": "Chambre-Timoth\u00e9e", "type": "RollerShutter", "position": 0}, {"id": 11, "name": "Bureau-Cyrille-porte-fen\u00eatre", "type": "RollerShutter", "position": 0}]}
[2021-01-25 17:54:03][DEBUG] : Update Palier at 0%
[2021-01-25 17:54:03][DEBUG] : Update Séjour cheminée at 0%
[2021-01-25 17:54:03][DEBUG] : Update Séjour entrée at 0%
[2021-01-25 17:54:03][DEBUG] : Update Bureau at 0%
[2021-01-25 17:54:03][DEBUG] : Update Cellier at 0%
[2021-01-25 17:54:04][DEBUG] : Update Atelier Fenêtre at 0%
[2021-01-25 17:54:04][DEBUG] : Update Chambre Joséphine at 0%
[2021-01-25 17:54:04][DEBUG] : Update Chambre parentale at 0%
[2021-01-25 17:54:04][DEBUG] : Update Salon at 0%
[2021-01-25 17:54:04][DEBUG] : Update Cuisine at 0%
[2021-01-25 17:54:04][DEBUG] : Update Chambre Timothée at 0%
[2021-01-25 17:54:04][DEBUG] : Update Atelier porte-fenêtre at 0%
Voici maintenant ce que j’obtiens AVEC 3 ECHECS en changeant de mode quand je passe par le plugin volets qui pilotent individuellement chaque volet:
[2021-01-25 17:56:16][DEBUG] : Action /set/3/100
[2021-01-25 17:56:16][DEBUG] : Send http://localhost:9123/set/3/100
[2021-01-25 17:56:16][DEBUG] : Action /set/9/100
[2021-01-25 17:56:16][DEBUG] : Result {"result": "ok", "device": 3, "position": "0 %"}
[2021-01-25 17:56:16][DEBUG] : Send http://localhost:9123/set/9/100
[2021-01-25 17:56:16][DEBUG] : Result {"result": "ok", "device": 9, "position": "0 %"}
[2021-01-25 17:56:16][DEBUG] : Action /set/2/100
[2021-01-25 17:56:16][DEBUG] : Send http://localhost:9123/set/2/100
[2021-01-25 17:56:16][DEBUG] : Action /set/6/100
[2021-01-25 17:56:16][DEBUG] : Action /set/8/100
[2021-01-25 17:56:16][DEBUG] : Action /set/7/100
[2021-01-25 17:56:16][DEBUG] : Action /set/10/100
[2021-01-25 17:56:16][DEBUG] : Action /set/1/100
[2021-01-25 17:56:16][DEBUG] : Action /set/5/100
[2021-01-25 17:56:16][DEBUG] : Result {"result": "ok", "device": 2, "position": "0 %"}
[2021-01-25 17:56:16][DEBUG] : Send http://localhost:9123/set/6/100
[2021-01-25 17:56:16][DEBUG] : Send http://localhost:9123/set/7/100
[2021-01-25 17:56:17][DEBUG] : Send http://localhost:9123/set/10/100
[2021-01-25 17:56:17][DEBUG] : Send http://localhost:9123/set/8/100
[2021-01-25 17:56:17][DEBUG] : Send http://localhost:9123/set/5/100
[2021-01-25 17:56:17][DEBUG] : Action /set/11/100
[2021-01-25 17:56:17][DEBUG] : Send http://localhost:9123/set/1/100
[2021-01-25 17:56:17][DEBUG] : Action /set/0/100
[2021-01-25 17:56:17][DEBUG] : Send http://localhost:9123/set/0/100
[2021-01-25 17:56:17][DEBUG] : Action /set/4/100
[2021-01-25 17:56:17][DEBUG] : Send http://localhost:9123/set/11/100
[2021-01-25 17:56:17][DEBUG] : Send http://localhost:9123/set/4/100
[2021-01-25 17:56:17][DEBUG] : Result {"result": "ok", "device": 7, "position": "0 %"}
[2021-01-25 17:56:25][DEBUG] : Result {"result": "ok", "device": 6, "position": "0 %"}
[2021-01-25 17:56:25][DEBUG] : Result {"result": "ok", "device": 10, "position": "0 %"}
[2021-01-25 17:56:26][DEBUG] : Result {"result": "ok", "device": 8, "position": "0 %"}
[2021-01-25 17:56:34][DEBUG] : Result {"result": "ok", "device": 5, "position": "0 %"}
[2021-01-25 17:56:34][DEBUG] : Result {"result": "ok", "device": 1, "position": "0 %"}
[2021-01-25 17:56:42][DEBUG] : Result
[2021-01-25 17:56:42][DEBUG] : Result
[2021-01-25 17:56:42][DEBUG] : Result
[2021-01-25 17:57:04][DEBUG] : Send http://localhost:9123/devices
[2021-01-25 17:57:04][DEBUG] : Result {"result": "ok", "devices": [{"id": 0, "name": "Palier", "type": "RollerShutter", "position": 0}, {"id": 1, "name": "S\u00e9jour-chemin\u00e9e", "type": "RollerShutter", "position": 100}, {"id": 2, "name": "S\u00e9jour-entr\u00e9e", "type": "RollerShutter", "position": 100}, {"id": 3, "name": "Bureau-C\u00e9cile", "type": "RollerShutter", "position": 100}, {"id": 4, "name": "Cellier", "type": "RollerShutter", "position": 0}, {"id": 5, "name": "Bureau-Cyrille-Fen\u00eatre", "type": "RollerShutter", "position": 100}, {"id": 6, "name": "Chambre-Jos\u00e9phine", "type": "RollerShutter", "position": 99}, {"id": 7, "name": "Chambre-parents", "type": "RollerShutter", "position": 100}, {"id": 8, "name": "Salon", "type": "RollerShutter", "position": 100}, {"id": 9, "name": "Cuisine", "type": "RollerShutter", "position": 100}, {"id": 10, "name": "Chambre-Timoth\u00e9e", "type": "RollerShutter", "position": 99}, {"id": 11, "name": "Bureau-Cyrille-porte-fen\u00eatre", "type": "RollerShutter", "position": 0}]}
[2021-01-25 17:57:04][DEBUG] : Update Palier at 0%
[2021-01-25 17:57:04][DEBUG] : Update Séjour cheminée at 100%
[2021-01-25 17:57:04][DEBUG] : Update Séjour entrée at 100%
[2021-01-25 17:57:04][DEBUG] : Update Bureau at 100%
[2021-01-25 17:57:04][DEBUG] : Update Cellier at 0%
[2021-01-25 17:57:04][DEBUG] : Update Atelier Fenêtre at 100%
[2021-01-25 17:57:04][DEBUG] : Update Chambre Joséphine at 99%
[2021-01-25 17:57:04][DEBUG] : Update Chambre parentale at 100%
[2021-01-25 17:57:04][DEBUG] : Update Salon at 100%
[2021-01-25 17:57:04][DEBUG] : Update Cuisine at 100%
[2021-01-25 17:57:04][DEBUG] : Update Chambre Timothée at 99%
[2021-01-25 17:57:04][DEBUG] : Update Atelier porte-fenêtre at 0%
Premières conclusions: Les dernières commandes transmises sont mal gérées car seuls les 7 premiers volets sont en action. Les suivantes répondent uniquement par « Result ». On note aussi que l’envoi des commandes est moins bien ordonnancé, ce qui conduit à des échecs puis à des plantages de ce type:
[2021-01-25 18:09:03][DEBUG] : Send http://localhost:9123/devices
[2021-01-25 18:09:04][DEBUG] : Result
Traceback (most recent call last):
File "/var/www/html/plugins/klf200/resources/klf200d.py", line 233, in <module>
LOOP.run_until_complete(init_pyvlx_connection(LOOP))
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/var/www/html/plugins/klf200/resources/klf200d.py", line 22, in init_pyvlx_connection
await pyvlx.load_nodes()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/pyvlx.py", line 76, in load_nodes
await self.nodes.load(node_id)
File "/usr/local/lib/python3.7/dist-packages/pyvlx/nodes.py", line 69, in load
await self._load_all_nodes()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/nodes.py", line 85, in _load_all_nodes
await get_all_nodes_information.do_api_call()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/api/api_event.py", line 21, in do_api_call
await self.send_frame()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/api/api_event.py", line 33, in send_frame
await self.pyvlx.send_frame(self.request_frame())
File "/usr/local/lib/python3.7/dist-packages/pyvlx/pyvlx.py", line 66, in send_frame
await self.connect()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/pyvlx.py", line 43, in connect
await self.connection.connect()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/connection.py", line 91, in connect
ssl=self.create_ssl_context(),
File "/usr/lib/python3.7/asyncio/base_events.py", line 959, in create_connection
raise exceptions[0]
File "/usr/lib/python3.7/asyncio/base_events.py", line 946, in create_connection
await self.sock_connect(sock, address)
File "/usr/lib/python3.7/asyncio/selector_events.py", line 464, in sock_connect
return await fut
File "/usr/lib/python3.7/asyncio/selector_events.py", line 494, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('x.x.x.x', 51200)
[2021-01-25 18:09:25][INFO] : Arrêt du service klf200
[2021-01-25 18:09:25][INFO] : Lancement démon klf200 : /usr/bin/python3 /var/www/html/plugins/klf200/resources/klf200d.py x.x.x.x 9XXXXXb4h
[2021-01-25 18:09:25][ERROR] : KLF200 has been restarted after found not responding
[2021-01-25 18:09:29][INFO] : Arrêt du service klf200
[2021-01-25 18:09:29][INFO] : Lancement démon klf200 : /usr/bin/python3 /var/www/html/plugins/klf200/resources/klf200d.py x.x.x.x 9XXXXXb4h
[2021-01-25 18:09:29][ERROR] : KLF200 has been restarted after found not responding
[2021-01-25 18:09:44][INFO] : Arrêt du service klf200
[2021-01-25 18:09:45][INFO] : Lancement démon klf200 : /usr/bin/python3 /var/www/html/plugins/klf200/resources/klf200d.py x.x.x.x 9XXXXXb4h
[2021-01-25 18:09:45][ERROR] : KLF200 has been restarted after found not responding
Traceback (most recent call last):
File "/var/www/html/plugins/klf200/resources/klf200d.py", line 233, in <module>
LOOP.run_until_complete(init_pyvlx_connection(LOOP))
File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
return future.result()
File "/var/www/html/plugins/klf200/resources/klf200d.py", line 22, in init_pyvlx_connection
await pyvlx.load_nodes()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/pyvlx.py", line 76, in load_nodes
await self.nodes.load(node_id)
File "/usr/local/lib/python3.7/dist-packages/pyvlx/nodes.py", line 69, in load
await self._load_all_nodes()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/nodes.py", line 85, in _load_all_nodes
await get_all_nodes_information.do_api_call()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/api/api_event.py", line 21, in do_api_call
await self.send_frame()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/api/api_event.py", line 33, in send_frame
await self.pyvlx.send_frame(self.request_frame())
File "/usr/local/lib/python3.7/dist-packages/pyvlx/pyvlx.py", line 66, in send_frame
await self.connect()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/pyvlx.py", line 43, in connect
await self.connection.connect()
File "/usr/local/lib/python3.7/dist-packages/pyvlx/connection.py", line 91, in connect
ssl=self.create_ssl_context(),
File "/usr/lib/python3.7/asyncio/base_events.py", line 959, in create_connection
raise exceptions[0]
File "/usr/lib/python3.7/asyncio/base_events.py", line 946, in create_connection
await self.sock_connect(sock, address)
File "/usr/lib/python3.7/asyncio/selector_events.py", line 464, in sock_connect
return await fut
File "/usr/lib/python3.7/asyncio/selector_events.py", line 494, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('x.x.x.x', 51200)
[2021-01-25 18:10:03][INFO] : Arrêt du service klf200
[2021-01-25 18:10:04][INFO] : Lancement démon klf200 : /usr/bin/python3 /var/www/html/plugins/klf200/resources/klf200d.py x.x.x.x 9XXXXXb4h
[2021-01-25 18:10:05][DEBUG] : Send http://localhost:9123/devices
[2021-01-25 18:10:06][DEBUG] : Result
[2021-01-25 18:10:46][INFO] : Arrêt du service klf200
[2021-01-25 18:10:48][INFO] : Lancement démon klf200 : /usr/bin/python3 /var/www/html/plugins/klf200/resources/klf200d.py x.x.x.x 9XXXXXb4h
[2021-01-25 18:10:48][ERROR] : KLF200 has been restarted after found not responding
[2021-01-25 18:11:03][DEBUG] : Send http://localhost:9123/devices
J’ai noté également dans la doc de l’API velux:
4 Gateway interface
4.1 TCP/IP interface
The Ethernet module establishes a TCP/IP server listening at port 51200. Up to two
sockets can be established at the same time on wired ethernet.
TCP/IP socket will be closed after 15 min, with no communication. The command
GW_GET_STATE_REQ can be used to ping KLF200 from time to time, to keep the socked
established.
TLS is used to encrypt communication. For now, the certificate is self-signed.
Je me pose la question si le klf ne se met pas en standby durant 15 min car trop de connexions. Je vais tenter de jeter un œil sur le plugin et faire des tests avec les scripts python proposés par velux pour reproduire le pb ou bien le contourner.
@lunarok, si tu as des éléments de réponse ou si cette piste te semble intéressante, je suis preneur de ton retour, cela m’évitera de creuser au mauvais endroit.