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 #38

Open Zatowa opened 2 years ago

Zatowa commented 2 years ago

Hello !

I have the same issue as ticket #33

STARTING TYDOM2MQTT
Dectecting environnement......
/data/options.json detected ! Hassio Addons Environnement : parsing options.json....
{'TYDOM_MAC': '001A2505839E', 'TYDOM_IP': '192.168.1.43', 'TYDOM_PASSWORD': 'MyPassword', 'TYDOM_ALARM_PIN': 123456, 'TYDOM_ALARM_HOME_ZONE': 1, 'TYDOM_ALARM_NIGHT_ZONE': 2, 'MQTT_HOST': '192.168.1.42', 'MQTT_USER': 'myuser', 'MQTT_PASSWORD': 'myPassword', 'MQTT_PORT': 1883, 'MQTT_SSL': False, 'log_level': 'info'}
Initialising TydomClient Class
Setting local mode context.
Starting main loop_task
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Attempting MQTT connection...
MQTT host :  192.168.1.42
MQTT user :  mqtt-user
##################################
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.43
Task exception was never retrieved
future: <Task finished name='Task-5' coro=<listen_tydom_forever() done, defined at /opt/tydom2mqtt/main.py:104> exception=InvalidMessage('did not receive a valid HTTP response')>
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/websockets/legacy/client.py", line 134, in read_http_response
    status_code, reason, headers = await read_response(self.reader)
  File "/usr/lib/python3.8/site-packages/websockets/legacy/http.py", line 141, in read_response
    headers = await read_headers(stream)
  File "/usr/lib/python3.8/site-packages/websockets/legacy/http.py", line 169, in read_headers
    raise ValueError(f"invalid HTTP header line: {d(line)}") from None
ValueError: invalid HTTP header line:   realm="Protected Area",
The above exception was the direct cause of the following exception:
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 121, in connect
    self.connection = await websockets.connect('wss://{}:443/mediation/client?mac={}&appli=1'.format(self.host, self.mac),
  File "/usr/lib/python3.8/site-packages/websockets/legacy/client.py", line 649, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "/usr/lib/python3.8/asyncio/tasks.py", line 494, in wait_for
    return fut.result()
  File "/usr/lib/python3.8/site-packages/websockets/legacy/client.py", line 660, in __await_impl__
    await protocol.handshake(
  File "/usr/lib/python3.8/site-packages/websockets/legacy/client.py", line 321, in handshake
    status_code, response_headers = await self.read_http_response()
  File "/usr/lib/python3.8/site-packages/websockets/legacy/client.py", line 140, in read_http_response
    raise InvalidMessage("did not receive a valid HTTP response") from exc
websockets.exceptions.InvalidMessage: did not receive a valid HTTP response
Starting /opt/tydom2mqtt/main.py

in the system logs :

21-11-08 20:00:42 WARNING (MainThread) [supervisor.api.middleware.security] 70812686_tydom2mqtt_hassio missing API permission for /host/info
21-11-08 20:00:42 ERROR (MainThread) [supervisor.api.middleware.security] Invalid token for access /host/info
21-11-08 20:00:44 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'mqtt-user'
21-11-08 20:00:45 INFO (MainThread) [supervisor.auth] Successful login for 'mqtt-user'
21-11-08 20:05:45 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'mqtt-user'
21-11-08 20:05:45 INFO (MainThread) [supervisor.auth] Successful login for 'mqtt-user'

Addon version : release_1.2.1 Mosquito Broker : 6.0.1 HA Core : core-2021.11.1 HA Supervisor : supervisor-2021.10.8 HA OS : Home Assistant OS 5.10.17-v8

Thank you for your advices !

mrwiwi commented 2 years ago

Ok, seems like a new version of websockets 10 poped out with API changes... I've locked dependencies to 9.1 to try fixing, could you try rebuild after refreshing add-on store please ?

Zatowa commented 2 years ago

Thank you for your quick reply.

I have rebuild after refreshing add-on and i have this error :

21-11-08 22:52:53 INFO (SyncWorker_5) [supervisor.docker.addon] Starting build for 70812686/aarch64-addon-tydom2mqtt_hassio:release_1.2.1
21-11-08 22:53:00 ERROR (SyncWorker_5) [supervisor.docker.addon] Can't build 70812686/aarch64-addon-tydom2mqtt_hassio:release_1.2.1: The command '/bin/ash -o pipefail -c pip3 install --requirement /tmp/requirements.txt' returned a non-zero code: 1
21-11-08 22:53:00 ERROR (SyncWorker_5) [supervisor.docker.addon] Build log: 
Step 1/17 : ARG BUILD_FROM=hassioaddons/base:latest
Step 2/17 : FROM ${BUILD_FROM}
 ---> f672d4f04e01
Step 3/17 : ENV LANG C.UTF-8
 ---> Using cache
 ---> f6b7fb158ecb
Step 4/17 : COPY . /
 ---> Using cache
 ---> dda0a1fab23e
Step 5/17 : COPY requirements.txt /tmp/
 ---> Using cache
 ---> 1e2d4c3d0c06
Step 6/17 : RUN apk add --no-cache python3
 ---> Using cache
 ---> 702c331d6d26
Step 7/17 : RUN pip3 install --requirement /tmp/requirements.txt
 ---> Running in dcb2f312e741
ERROR: Invalid requirement: 'websockets=9.1' (from line 1 of /tmp/requirements.txt)
Hint: = is not a valid operator. Did you mean == ?

WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/bin/python3.8 -m pip install --upgrade pip' command.

Removing intermediate container dcb2f312e741

The command "/usr/bin/python3.8 -m pip install --upgrade pip" doesn't work because I don't have a pythonX.X folder ...

mrwiwi commented 2 years ago

Ok should be fixed

mrwiwi commented 2 years ago

Mmh tried with lastest version of websockets, no issues... That's strange.

mrwiwi commented 2 years ago

Could you try to connect remotely with the default mediation.tydom.com as Tydom IP please ?

mrwiwi commented 2 years ago

I've made changes and new release, i still don't understand... you didn't got a password before ? It mandadory even on local

mrwiwi commented 2 years ago

But your password is non blank ? Try with the remote address please

mrwiwi commented 2 years ago

I've deleted your last answer, you need to remove the MAC address before posting ;)

mrwiwi commented 2 years ago

I've just reinstalled from scratch, no issues with a complex passwd... but it guess there's something with that new Delta Dore way.. maybe doing something with the button on the box to initiate...?

mrwiwi commented 2 years ago

Is that a new box ? New installation ?

Zatowa commented 2 years ago

Yes I bought it a few days ago

I started all over again:

When I access https://192.168.1.xx/mediation/client?Mac=001A25xxxxxx&appli=1 :

We can chat on Discord if you have time (I'm French) --> Zatow#1817

Zatowa commented 2 years ago

This is exactly my configuration, I cannot recover the TYDOM password

https://www.youtube.com/watch?v=Vg0zOK7FeZY (FR) https://www.youtube.com/watch?v=3aAbQzCyqnE (EN)

mrwiwi commented 2 years ago

Ok, this is what you could try : download a previous version of the tydom app (before 4.1 I guess), and retry. Otherwise we need to wireshark the entire onboarding, which means a probable full refactor...

Zatow commented 2 years ago

I was finally able to reset the password from an Android smartphone with a version older than 4.x !

On the other hand, i notice that my heating does not go up in mqtt. Tydom2MQTT logs :

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Incoming message type : data detected
1637617832_1637617832 not in dic device_name
1637617832_1637617832 not in dic device_type
Incoming data parsed successfully !
>>>>>>>>>> Sending to tydom client..... POST /refresh/all
<<<<<<<<<< Receiving from tydom_client...
>>>>>>>>>> Sending to tydom client..... POST /refresh/all
<<<<<<<<<< Receiving from tydom_client...
>>>>>>>>>> Sending to tydom client..... POST /refresh/all
<<<<<<<<<< Receiving from tydom_client...
<<<<<<<<<< Receiving from tydom_client...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Incoming message type : data detected
Cannot parse response !
Error :  'data'
[{'id': 1637617832, 'endpoints': [{'id': 1637617832, 'error': 0, 'access': {'protocol': 'X3D', 'profile': 'rt2012', 'type': 'x3d_pp', 'addr': {'MSB': '0x00', 'ISB': '0x94', 'LSB': '0x68', 'index': '0xC1'}, 'subAddr': 2}}, {'id': 1637617833, 'error': 0, 'access': {'protocol': 'X3D', 'profile': 'temperature', 'type': 'x3d_pp', 'addr': {'MSB': '0x00', 'ISB': '0x94', 'LSB': '0x68', 'index': '0xC1'}, 'subAddr': 254}}, {'id': 1637617834, 'error': 0, 'access': {'protocol': 'X3D', 'profile': 'rt2012_meas', 'type': 'x3d_pp', 'addr': {'MSB': '0x00', 'ISB': '0x94', 'LSB': '0x68', 'index': '0xC1'}, 'subAddr': 255}}]}]
Incoming data parsed successfully !
POST message processed !
<<<<<<<<<< Receiving from tydom_client...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
receiveMessage error
RAW :
b'PUT /devices/install HTTP/1.1\r\nServer: Tydom-001A25xxxxxx\r\ncontent-type: application/json\r\nTransfer-Encoding: chunked\r\n\r\n2C\r\n{"protocol":"X3D","installStatus":"running"}\r\n0\r\n\r\n'
Incoming payload :
None
Error :
PUT /devices/install HTTP/1.1
Exiting to ensure systemd restart....
Starting /opt/tydom2mqtt/main.py