sinseman44 / koolnova-BMS-Integration

Koolnova air conditioning support for Home Assistant via BMS
MIT License
8 stars 2 forks source link

ModbusConnexionError: Client Modbus not connected` #18

Open ChrysMa opened 6 days ago

ChrysMa commented 6 days ago

Hello AFAIK since the release 0.2.0, the below error is reported in HA logs. I experience now often unreadable zone status never noticed before....

`Enregistreur: custom_components.koolnova_bms.coordinator Source: helpers/update_coordinator.py:382 intégration: Koolnova BMS (documentation, problèmes) S'est produit pour la première fois: 19 novembre 2024 à 20:39:02 (374 occurrences) Dernier enregistrement: 22:15:47 Unexpected error fetching koolnova_bms data

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 382, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 279, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/koolnova_bms/koolnova/device.py", line 431, in async_update_all_areas _ret, _vals = await self._client.async_areas_registered() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/koolnova_bms/koolnova/operations.py", line 212, in async_areas_registered regs, ret = await self.__async_read_registers(start_reg = const.REG_START_ZONE, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/koolnova_bms/koolnova/operations.py", line 101, in __async_read_registers raise ModbusConnexionError('Client Modbus not connected') custom_components.koolnova_bms.koolnova.operations.ModbusConnexionError: Client Modbus not connected`

sinseman44 commented 6 days ago

Hi,

Nothing has changed in the operation of RTU mode between version 0.1.3 and the latest version 0.2.0. You can try to change default extra parameters (reconnect_delay, reconnect_delay_max and retries) in the initialisation of ModbusClient in the file koolnova/operations.py (line 49)

ChrysMa commented 4 days ago

Hi, Thanks. Code updated... Got immediate result (after reboot)

` Cette erreur provient d'une intégration personnalisée

Enregistreur: custom_components.koolnova_bms.koolnova.operations Source: custom_components/koolnova_bms/koolnova/operations.py:89 intégration: Koolnova BMS (documentation, problèmes) S'est produit pour la première fois: 11:35:55 (29 occurrences) Dernier enregistrement: 11:40:03

Modbus Error: Modbus Error: [Connection] Connection lost during request Modbus Error: 'NoneType' object has no attribute 'close' Modbus Error: Modbus Error: [Input/Output] ERROR: No response received after 5 retries `

Doesn't seem better...

ChrysMa commented 6 hours ago

OK after a while and many tests . Tried to restart / modify USB port and so on : no better result

Then I plugged the USB dongle directly onto a desktop ran many tests :

` --- /dev/ttyUSB0 poll statistics --- 605 frames transmitted, 605 received, 0 errors, 0.0% frame loss

everything was closed. Have a nice day ! `

highest error reported was less than 0.3% over more than 10000 requests

So I keep searchin' ;-)

sinseman44 commented 4 hours ago

it's incomprehensible! My opinion is that you must have a problem with the HA/pymodbus/pyserial tuple. In your test cases, you did not test other clients on the HAOS VM. You also did not try to use the Koolnova integration on a Linux machine (Desktop). Can you try to import the koolnova BMS python wrapper (device.py) in a virtual python app (virtualenv) in a Linux desktop (not HAOS) with the same environment.txt ("pymodbus==3.5.4", "pyserial==3.5") ?

sinseman44 commented 3 hours ago

You can also try to install the latest (3.7.4) version of pymodbus in your HAOS VM. Change the manifest.json in the koolnova integration package with it. Restart HA.

{
    "domain": "koolnova_bms",
    "name": "Koolnova BMS Modbus RS485",
    "codeowners": ["@sinseman44"],
    "config_flow": true,
    "documentation": "https://github.com/sinseman44/koolnova-BMS-Integration",
    "issue_tracker": "https://github.com/sinseman44/koolnova-BMS-Integration/issues",
    "integration_type": "device",
    "iot_class": "local_polling",
    "quality_scale": "silver",
    "loggers": ["koolnova"],
    "requirements": [
    "pymodbus==3.7.4",
    "pyserial==3.5"
    ],
    "version": "0.2.1"
}
ChrysMa commented 2 hours ago

Ok got it. Will be my next move. Right now I am under test with below params self._client = ModbusClient(port=self._rtu_port, baudrate=self._rtu_baudrate, parity=self._rtu_parity, stopbits=self._rtu_stopbits, bytesize=self._rtu_bytesize, timeout=self._timeout, reconnect_delay=0.2, reconnect_delay_max=500, retries=5) Got not any reported error...

Probably related to underlying software... pymodbus or...

Please not I also tried on a linux desktop see "on the linux desktop (got many computer here) : tried modbus (cf jpelletier) : no problem either". However you're right... did not test using pymodbus... I was trying to know if my dongle/cable was ok...