fmartinou / tydom2mqtt

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

Tydom Password not used in the container while correctly setup as environment #209

Open BilayKhan opened 1 month ago

BilayKhan commented 1 month ago

Hi, I am using docker and portainer to launch tydom2mqtt.

Here is my compose (latest=3.5.2):

version: '3'
services:
  tydom2mqtt:
    image: fmartinou/tydom2mqtt:latest
    container_name: tydom2mqtt
    environment:
      - TYDOM_MAC=0**********4
      - TYDOM_PASSWORD=0****4
      - TYDOM_IP=192.168.1.9
      - DELTADORE_LOGIN=g****@********.com
      - DELTADORE_PASSWORD=p******************s
      - TYDOM_POLLING_INTERVAL=300
      - MQTT_HOST=homeassistant
      - MQTT_PORT=1883
      - MQTT_USER=MQTTUser
      - MQTT_PASSWORD=8************************************************d
      - MQTT_SSL=false
      - LOG_LEVEL=DEBUG

But the containers failed with an "exited - code1" error. And here is the log:

2024-08-09T16:31:00.155499208Z 2024-08-09 16:31:00,155 - Starting tydom2mqtt
2024-08-09T16:31:00.710078945Z 2024-08-09 16:31:00,709 - Validating configuration ({
2024-08-09T16:31:00.710299924Z     "deltadore_login": "g****@********.com",
2024-08-09T16:31:00.710401176Z     "deltadore_password": "p******************s",
2024-08-09T16:31:00.710468002Z     "log_level": "DEBUG",
2024-08-09T16:31:00.710532328Z     "mqtt_host": "homeassistant",
2024-08-09T16:31:00.710606967Z     "mqtt_password": "8************************************************d",
2024-08-09T16:31:00.710676681Z     "mqtt_port": "1883",
2024-08-09T16:31:00.710741757Z     "mqtt_ssl": "false",
2024-08-09T16:31:00.710808296Z     "mqtt_user": "MQTTUser",
2024-08-09T16:31:00.710878485Z     "thermostat_cool_mode_temp_default": 26,
2024-08-09T16:31:00.710943198Z     "thermostat_custom_presets": null,
2024-08-09T16:31:00.711009437Z     "thermostat_heat_mode_temp_default": 16,
2024-08-09T16:31:00.711075976Z     "tydom_alarm_home_zone": 1,
2024-08-09T16:31:00.711156140Z     "tydom_alarm_night_zone": 2,
2024-08-09T16:31:00.711225566Z     "tydom_alarm_pin": "",
2024-08-09T16:31:00.711289017Z     "tydom_ip": "192.168.1.9",
2024-08-09T16:31:00.711357331Z     "tydom_mac": "0**********4",
2024-08-09T16:31:00.711421107Z     "tydom_password": "",
2024-08-09T16:31:00.711483921Z     "tydom_polling_interval": "300"
2024-08-09T16:31:00.711550972Z }
2024-08-09T16:31:00.711614386Z 2024-08-09 16:31:00,710 - Tydom password must be defined

We can see that the tydom_password environment is not well setup and is null ("") where it is required by the system.

Just to test, I also try with the release 3.4.3 and the issue remain the same.

Would you have an idea of what happen? I must miss something as it seems that everyone succeed to create the container correctly.

Many thanks for your help !

BlacKTM1190 commented 1 month ago

Hello Did you try without DD credentials in your compose, as you know your tydom_password ? In readme, since DD account support was added : Please note that only one of DELTADORE_LOGIN + DELTADORE_PASSWORD or TYDOM_PASSWORD is needed as your Delta Dore account is used to retrieve the Tydom password

BilayKhan commented 3 weeks ago

Hello Did you try without DD credentials in your compose, as you know your tydom_password ? In readme, since DD account support was added : Please note that only one of DELTADORE_LOGIN + DELTADORE_PASSWORD or TYDOM_PASSWORD is needed as your Delta Dore account is used to retrieve the Tydom password

Many thanks for your answer, and sorry for my very late answer, I was on holidays. Indeed, when I comment my DD login/pwd it seems better. But It still not run correctly and I am stuck with an error I can share with this log (and I really do not understand what it means...

2024-08-22T15:29:59.856970343Z 2024-08-22 15:29:59,856 - Starting tydom2mqtt
2024-08-22T15:30:12.811040844Z 2024-08-22 15:29:59,857 - Validating configuration ({
2024-08-22T15:30:12.811223822Z     "deltadore_login": null,
2024-08-22T15:30:12.811299486Z     "deltadore_password": "",
2024-08-22T15:30:12.811366188Z     "log_level": "DEBUG",
2024-08-22T15:30:12.811438439Z     "mqtt_host": "192.168.1.3",
2024-08-22T15:30:12.811506203Z     "mqtt_password": "8************************************************d",
2024-08-22T15:30:12.811582091Z     "mqtt_port": "1883",
2024-08-22T15:30:12.811646968Z     "mqtt_ssl": "false",
2024-08-22T15:30:12.811715344Z     "mqtt_user": "MQTTUser",
2024-08-22T15:30:12.811782470Z     "thermostat_cool_mode_temp_default": 26,
2024-08-22T15:30:12.811852684Z     "thermostat_custom_presets": null,
2024-08-22T15:30:12.811944411Z     "thermostat_heat_mode_temp_default": 16,
2024-08-22T15:30:12.812202015Z     "tydom_alarm_home_zone": 1,
2024-08-22T15:30:12.812351993Z     "tydom_alarm_night_zone": 2,
2024-08-22T15:30:12.812424757Z     "tydom_alarm_pin": "",
2024-08-22T15:30:12.812493133Z     "tydom_ip": "192.168.1.9",
2024-08-22T15:30:12.812562697Z     "tydom_mac": « 0**********4 »,
2024-08-22T15:30:12.812629761Z     "tydom_password": "0****4",
2024-08-22T15:30:12.812697124Z     "tydom_polling_interval": 300
2024-08-22T15:30:12.812762938Z }
2024-08-22T15:30:12.812858927Z 2024-08-22 15:29:59,857 - The configuration is valid
2024-08-22T15:30:12.812973904Z 2024-08-22 15:29:59,858 - tydom.TydomClient    - DEBUG   - Initializing TydomClient Class
2024-08-22T15:30:12.813070269Z 2024-08-22 15:29:59,858 - tydom.TydomClient    - INFO    - Configure local mode (192.168.1.9)
2024-08-22T15:30:12.813187333Z 2024-08-22 15:29:59,861 - asyncio              - DEBUG   - Using selector: EpollSelector
2024-08-22T15:30:12.813273060Z 2024-08-22 15:29:59,864 - mqtt.MqttClient      - INFO    - Connecting to mqtt broker (host=192.168.1.3, port=1883, user=MQTTUser, ssl=false)
2024-08-22T15:30:12.813375624Z 2024-08-22 15:29:59,865 - tydom.TydomClient    - INFO    - Connecting to tydom
2024-08-22T15:30:12.813448413Z 2024-08-22 15:30:02,395 - tydom.TydomClient    - DEBUG   - Response headers
2024-08-22T15:30:12.813526702Z 2024-08-22 15:30:02,396 - tydom.TydomClient    - DEBUG   - Connection: close
2024-08-22T15:30:12.813599003Z WWW-Authenticate: Digest realm="Protected Area", qop="auth", nonce="e******************************6", opaque="5******************************5"
2024-08-22T15:30:12.813691855Z Content-Type: text/html
2024-08-22T15:30:12.813760869Z 
2024-08-22T15:30:12.813850820Z 
2024-08-22T15:30:12.813910209Z 2024-08-22 15:30:02,401 - tydom.TydomClient    - DEBUG   - Response code
2024-08-22T15:30:12.814015673Z 2024-08-22 15:30:02,401 - tydom.TydomClient    - DEBUG   - 401
2024-08-22T15:30:12.814089175Z 2024-08-22 15:30:02,401 - tydom.TydomClient    - DEBUG   - response
2024-08-22T15:30:12.814499532Z 2024-08-22 15:30:02,402 - tydom.TydomClient    - DEBUG   - b'<!doctype html>\r\n<html>\r\n<head><title>Error 401</title></head>\r\n<body>\r\n<h2>Error 401</h2>\r\n<p>Authorization required</p>\r\n</body>\r\n</html>\r\n'
2024-08-22T15:30:16.090466971Z 2024-08-22 15:30:02,403 - tydom.TydomClient    - DEBUG   - Upgrading http connection to websocket....
2024-08-22T15:30:16.090632636Z 2024-08-22 15:30:02,403 - tydom.TydomClient    - DEBUG   - Attempting websocket connection with Tydom hub
2024-08-22T15:30:16.090722563Z 2024-08-22 15:30:02,683 - mqtt.MqttClient      - WARNING - MQTT connection error : 'str' object has no attribute 'wrap_bio'
2024-08-22T15:30:16.090824015Z 2024-08-22 15:30:02,684 - websockets.client    - DEBUG   - = connection is CONNECTING
2024-08-22T15:30:17.539038452Z 2024-08-22 15:30:05,217 - websockets.client    - DEBUG   - > GET /mediation/client?mac=0**********4&appli=1 HTTP/1.1
2024-08-22T15:30:17.539238818Z 2024-08-22 15:30:05,218 - websockets.client    - DEBUG   - > Host: 192.168.1.9
2024-08-22T15:30:17.539356108Z 2024-08-22 15:30:05,218 - websockets.client    - DEBUG   - > Upgrade: websocket
2024-08-22T15:30:17.539450134Z 2024-08-22 15:30:05,218 - websockets.client    - DEBUG   - > Connection: Upgrade
2024-08-22T15:30:17.539546699Z 2024-08-22 15:30:05,218 - websockets.client    - DEBUG   - > Sec-WebSocket-Key: j**********************=
2024-08-22T15:30:17.539665451Z 2024-08-22 15:30:05,218 - websockets.client    - DEBUG   - > Sec-WebSocket-Version: 13
2024-08-22T15:30:17.539957831Z 2024-08-22 15:30:05,218 - websockets.client    - DEBUG   - > Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
2024-08-22T15:30:17.540093221Z 2024-08-22 15:30:05,218 - websockets.client    - DEBUG   - > Authorization: Digest username="0**********4", realm="protected area", nonce="e******************************6", uri="/mediation/client?mac=0**********4&appli=1", response="f******************************e", qop="auth", nc=00000001, cnonce="d**************5"
2024-08-22T15:30:17.540240624Z 2024-08-22 15:30:05,219 - websockets.client    - DEBUG   - > User-Agent: Python/3.11 websockets/12.0
2024-08-22T15:30:17.540345038Z 2024-08-22 15:30:05,230 - websockets.client    - DEBUG   - < HTTP/1.1 401 Unauthorized
2024-08-22T15:30:17.540447777Z 2024-08-22 15:30:05,230 - websockets.client    - DEBUG   - < Connection: close
2024-08-22T15:30:17.540551917Z 2024-08-22 15:30:05,230 - websockets.client    - DEBUG   - < WWW-Authenticate: Digest realm="Protected Area", qop="auth", nonce="a******************************a", opaque="f******************************7"
2024-08-22T15:30:17.540825684Z 2024-08-22 15:30:05,230 - websockets.client    - DEBUG   - < Content-Type: text/html
2024-08-22T15:30:17.541004375Z 2024-08-22 15:30:05,231 - websockets.client    - DEBUG   - ! failing connection with code 1006
2024-08-22T15:30:17.541105964Z 2024-08-22 15:30:05,231 - websockets.client    - DEBUG   - x closing TCP connection
2024-08-22T15:30:17.541195204Z 2024-08-22 15:30:05,233 - websockets.client    - DEBUG   - = connection is CLOSED
2024-08-22T15:30:17.541283180Z 2024-08-22 15:30:05,233 - tydom.TydomClient    - ERROR   - Exception when trying to connect with websocket (server rejected WebSocket connection: HTTP 401)
2024-08-22T15:30:17.541396607Z 2024-08-22 15:30:05,260 - asyncio              - ERROR   - Task was destroyed but it is pending!
2024-08-22T15:30:17.541493021Z task: <Task pending name='Task-5' coro=<WebSocketCommonProtocol.close_connection() done, defined at /usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py:1285> wait_for=<Future finished result=None>>
2024-08-22T15:30:17.541632224Z 2024-08-22 15:30:05,260 - asyncio              - ERROR   - Task exception was never retrieved
2024-08-22T15:30:17.541721613Z future: <Task finished name='Task-2' coro=<listen_tydom() done, defined at /app/main.py:42> exception=SystemExit(1)>
2024-08-22T15:30:17.541851965Z Traceback (most recent call last):
2024-08-22T15:30:17.541952980Z   File "/app/tydom/TydomClient.py", line 194, in connect
2024-08-22T15:30:17.542042256Z     self.connection = await websockets.connect(
2024-08-22T15:30:17.542124933Z                       ^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-22T15:30:17.542198634Z   File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 647, in __await_impl_timeout__
2024-08-22T15:30:17.542295886Z     return await self.__await_impl__()
2024-08-22T15:30:17.542383163Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-22T15:30:17.542457727Z   File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 654, in __await_impl__
2024-08-22T15:30:17.542547516Z     await protocol.handshake(
2024-08-22T15:30:17.542612354Z   File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 325, in handshake
2024-08-22T15:30:17.542705106Z     raise InvalidStatusCode(status_code, response_headers)
2024-08-22T15:30:17.542773882Z websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 401
2024-08-22T15:30:17.542853446Z 
2024-08-22T15:30:17.542950461Z During handling of the above exception, another exception occurred:
2024-08-22T15:30:17.543036850Z 
2024-08-22T15:30:17.543096313Z Traceback (most recent call last):
2024-08-22T15:30:17.543164364Z   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
2024-08-22T15:30:17.543258629Z     self._run_once()
2024-08-22T15:30:17.543325380Z   File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1922, in _run_once
2024-08-22T15:30:17.543396031Z     handle._run()
2024-08-22T15:30:17.543460357Z   File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
2024-08-22T15:30:17.543531634Z     self._context.run(self._callback, *self._args)
2024-08-22T15:30:17.543601010Z   File "/app/main.py", line 46, in listen_tydom
2024-08-22T15:30:17.543673436Z     await tydom_client.connect()
2024-08-22T15:30:17.543738212Z   File "/app/tydom/TydomClient.py", line 205, in connect
2024-08-22T15:30:17.543807389Z     sys.exit(1)
2024-08-22T15:30:17.543871865Z SystemExit: 1
2024-08-22T15:30:17.543967054Z 2024-08-22 15:30:05,343 - asyncio              - ERROR   - Task was destroyed but it is pending!
2024-08-22T15:30:17.544044980Z task: <Task pending name='Task-3' coro=<poll_device_tydom() running at /app/main.py:76> wait_for=<Future pending cb=[Task.task_wakeup()]>>
2024-08-22T15:30:17.544127719Z 2024-08-22 15:30:05,343 - asyncio              - ERROR   - Task was destroyed but it is pending!
2024-08-22T15:30:17.544202071Z task: <Task pending name='Task-4' coro=<Client._resend_qos_messages() running at /usr/local/lib/python3.11/site-packages/gmqtt/client.py:177> wait_for=<Future pending cb=[Task.task_wakeup()]>>

If, by any chance, you have any clue on how to solve it, I am very interested ;)

BlacKTM1190 commented 3 weeks ago

Hello Is your tydom pwd contain special char ? Tydom allow this but none of Tydom integrations.

BilayKhan commented 3 weeks ago

Hello Is your tydom pwd contain special char ? Tydom allow this but none of Tydom integrations.

Nope, no special char.