fmartinou / tydom2mqtt

Deltadore Tydom to MQTT Bridge
https://fmartinou.github.io/tydom2mqtt/
MIT License
98 stars 57 forks source link

Error on parsing tydom response ('NoneType' object has no attribute 'publish') #138

Closed 1rabbit closed 12 months ago

1rabbit commented 1 year ago

Using k-line shutters (they work fine from the delta dore app)

tydom2mqtt    | 2023-10-02 11:51:39,898 - websockets.client    - DEBUG   - % sending keepalive ping
tydom2mqtt    | 2023-10-02 11:51:39,898 - websockets.client    - DEBUG   - > PING 9b b5 87 02 [binary, 4 bytes]
tydom2mqtt    | 2023-10-02 11:51:39,987 - websockets.client    - DEBUG   - < PONG '' [0 bytes]
tydom2mqtt    | 2023-10-02 11:51:59,919 - websockets.client    - DEBUG   - % sending keepalive ping
tydom2mqtt    | 2023-10-02 11:51:59,920 - websockets.client    - DEBUG   - > PING e1 86 13 43 [binary, 4 bytes]
tydom2mqtt    | 2023-10-02 11:51:59,996 - websockets.client    - DEBUG   - < PONG '' [0 bytes]
tydom2mqtt    | 2023-10-02 11:52:17,448 - websockets.client    - DEBUG   - < BINARY 50 55 54 20 2f 64 65 76 69 63 65 73 2f 64 61 74 ... 0a 0d 0a 30 0d 0a 0d 0a [255 bytes]
tydom2mqtt    | 2023-10-02 11:52:17,451 - tydom.MessageHandler - DEBUG   - PUT /devices/data or /areas/data message detected !
tydom2mqtt    | 2023-10-02 11:52:17,454 - tydom.MessageHandler - DEBUG   - Message received detected as (msg_data)
tydom2mqtt    | 2023-10-02 11:52:17,455 - tydom.MessageHandler - INFO    - Device update (id=1694678874, endpoint=1694678874, name=Bureau, type=shutter)
tydom2mqtt    | 2023-10-02 11:52:17,456 - tydom.MessageHandler - ERROR   - Error on parsing tydom response ('NoneType' object has no attribute 'publish')
tydom2mqtt    | 2023-10-02 11:52:17,457 - tydom.MessageHandler - ERROR   - Incoming data ([{"id": 1694678874, "endpoints": [{"id": 1694678874, "error": 0, "data": [{"name": "position", "validity": "upToDate", "value": 100}]}]}])
tydom2mqtt    | 2023-10-02 11:52:17,459 - tydom.MessageHandler - ERROR   - 'NoneType' object has no attribute 'publish'
tydom2mqtt    | Traceback (most recent call last):
tydom2mqtt    |   File "/app/tydom/MessageHandler.py", line 360, in parse_response
tydom2mqtt    |     await self.parse_devices_data(parsed=parsed)
tydom2mqtt    |   File "/app/tydom/MessageHandler.py", line 470, in parse_devices_data
tydom2mqtt    |     await self.parse_endpoint_data(endpoint, i["id"])
tydom2mqtt    |   File "/app/tydom/MessageHandler.py", line 684, in parse_endpoint_data
tydom2mqtt    |     await new_cover.update()
tydom2mqtt    |   File "/app/sensors/Cover.py", line 73, in update
tydom2mqtt    |     await self.setup()
tydom2mqtt    |   File "/app/sensors/Cover.py", line 68, in setup
tydom2mqtt    |     self.mqtt.mqtt_client.publish(
tydom2mqtt    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tydom2mqtt    | AttributeError: 'NoneType' object has no attribute 'publish'
tydom2mqtt    | 2023-10-02 11:52:17,472 - tydom.MessageHandler - DEBUG   - Incoming data parsed with success
tydom2mqtt    | 2023-10-02 11:52:19,923 - websockets.client    - DEBUG   - % sending keepalive ping
tydom2mqtt    | 2023-10-02 11:52:19,923 - websockets.client    - DEBUG   - > PING '(8Ѷ' [text, 4 bytes]
tydom2mqtt    | 2023-10-02 11:52:19,987 - websockets.client    - DEBUG   - < PONG '' [0 bytes]
simskimz commented 1 year ago

Hello, same issue for me.

jbkempf commented 1 year ago

I have the same issue here.

jbkempf commented 1 year ago

I have the same issue here.

So I solved it, by checking my configuration.

self.mqtt.mqtt_client.publish crashes if mqtt_client is null, which means that the mqtt connection was not done.

I changed and checked that my HA mosquitto was with the right username and password (it wasn't) and now I don't have the issue anymore displaying this publish error.

(However, I still have no devices created in MQTT, but that's another story/bug, unrelated to this one.)

1rabbit commented 1 year ago

@jbkempf thank you, it was indeed the mqtt connection. Turns out rabbitmq could not handle the "unparseable payload" thus closing connection abruptly on tydom2mqtt. I tried it on mosquitto mqtt server and it now runs fine.

jbkempf commented 1 year ago

@jbkempf thank you, it was indeed the mqtt connection.

😎 cool

fmartinou commented 12 months ago

If everything's fine, I can close the issue.