mrwiwi / tydom2mqtt

Link between a Delta Dore's Tydom Hub and and a MQTT broker, unofficial of course.
MIT License
28 stars 17 forks source link

Addon don't start, exceptions #33

Closed cvermot closed 3 years ago

cvermot commented 3 years ago

Hi every body,

My addon was working fine. But after updating the addon from 0.99 to 1.01, it didn't work anymore... I get this erros in the addon log : ` File "/opt/tydom2mqtt/tydomConnector.py", line 120, in connect self.connection = await websockets.client.connect('wss://{}:443/mediation/client?mac={}&appli=1'.format(self.host, self.mac), File "/usr/lib/python3.8/site-packages/websockets/imports.py", line 96, in getattr raise AttributeError(f"module {package!r} has no attribute {name!r}") AttributeError: module 'websockets' has no attribute 'client'


STARTING TYDOM2MQTT
Dectecting environnement......
/data/options.json detected ! Hassio Addons Environnement : parsing options.json....
{'TYDOM_MAC': 'myTydomMac', 'TYDOM_IP': '192.168.1.116', 'TYDOM_PASSWORD': 'MyTydomPassword', 'TYDOM_ALARM_PIN': 123456, 'TYDOM_ALARM_HOME_ZONE': 1, 'TYDOM_ALARM_NIGHT_ZONE': 2, 'MQTT_HOST': 'localhost', 'MQTT_USER': 'mqttuser', 'MQTT_PASSWORD': 'myMqttPassword', 'MQTT_PORT': 1883, 'MQTT_SSL': False, 'log_level': 'debug'}
Initialising TydomClient Class
Setting local mode context.
Starting main loop_task
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Attempting MQTT connection...
MQTT host :  localhost
MQTT user :  mqtt
##################################
Subscribing to :  +/tydom/#
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
TYDOM WEBSOCKET CONNECTION INITIALISING....                     
Building headers, getting 1st handshake and authentication....
Upgrading http connection to websocket....
Attempting websocket connection with tydom hub.......................
Host Target :
192.168.1.116
Starting /opt/tydom2mqtt/main.py
Task exception was never retrieved
future: <Task finished name='Task-7' coro=<listen_tydom_forever() done, defined at /opt/tydom2mqtt/main.py:104> exception=AttributeError("module 'websockets' has no attribute 'client'")>
Traceback (most recent call last):
  File "/opt/tydom2mqtt/main.py", line 113, in listen_tydom_forever
    await tydom_client.connect()
  File "/opt/tydom2mqtt/tydomConnector.py", line 120, in connect
    self.connection = await websockets.client.connect('wss://{}:443/mediation/client?mac={}&appli=1'.format(self.host, self.mac),
  File "/usr/lib/python3.8/site-packages/websockets/imports.py", line 96, in __getattr__
    raise AttributeError(f"module {package!r} has no attribute {name!r}")
AttributeError: module 'websockets' has no attribute 'client'`

Addon version : 1.01
Mosquito Broker : 5.5.1
HA Core : core-2021.4.6
HA Supervisor : supervisor-2021.04.0
HA OS : Home Assistant OS 5.13

Thank you for your advices !
cvermot commented 3 years ago

Hi,

I looked about websockets. I think that some python dependencies have been updated to websockets 8.x to 9.0. I found here : https://websockets.readthedocs.io/en/stable/changelog.html

9.0 May 1, 2021

Note Version 9.0 moves or deprecates several APIs.

Aliases provide backwards compatibility for all previously public APIs.

Headers and MultipleValuesError were moved from websockets.http to websockets.datastructures. If you’re using them, you should adjust the import path.

The client, server, protocol, and auth modules were moved from the websockets package to websockets.legacy sub-package, as part of an upcoming refactoring. Despite the name, they’re still fully supported. The refactoring should be a transparent upgrade for most uses when it’s available. The legacy implementation will be preserved according to the backwards-compatibility policy.

So, I think we would have some impact on the code...

mrwiwi commented 3 years ago

Thanks for reporting, i've just commited a quick fix on addon base, could you try a rebuild pls ? (refresh addon store just to be sure)

mrwiwi commented 3 years ago

Found the issue, will post a fix soon

mrwiwi commented 3 years ago

Fixed, easy peasy lemon squeezy for that one ^^

cvermot commented 3 years ago

Thank you for the quick fix ! It's work !