laszlojakab / homeassistant-easycontrols

Helios EasyControls Modbus TCP/IP integration for Home Assistant
MIT License
21 stars 12 forks source link

Cannot initialize integration #100

Open TheBigNeo opened 1 year ago

TheBigNeo commented 1 year ago

Hi

When I start my HA, with homeassistant-easycontrols to connect to my Helios 003 KWL EC 200 W R with version v2.27 i get an initialization error.

Error: TypeError: expected string or bytes-like object, got 'NoneType'

Stracktrace:

Logger: custom_components.easycontrols
Source: custom_components/easycontrols/coordinator.py:220
Integration: Helios Easy Controls ([documentation](https://github.com/laszlojakab/homeassistant-easycontrols#usage), [issues](https://github.com/laszlojakab/homeassistant-easycontrols/issues))
First occurred: 8:12:57 PM (2 occurrences)
Last logged: 8:12:59 PM

expected string or bytes-like object, got 'NoneType'
Traceback (most recent call last):
  File "/config/custom_components/easycontrols/__init__.py", line 47, in async_setup_entry
    coordinator = await create_coordinator(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/easycontrols/coordinator.py", line 515, in create_coordinator
    return await coordinator.init()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/easycontrols/coordinator.py", line 220, in init
    self._maximum_air_flow = float(re.findall(r"\d+", self._article_description)[0])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/re/__init__.py", line 216, in findall
    return _compile(pattern, flags).findall(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
TheBigNeo commented 1 year ago

I have found the problem. The device type (VARIABLE_ARTICLE_DESCRIPTION) (here) cannot be read on my Helios device. And therefore the self._maximum_air_flow = float(re.findall(r"\d+", self._article_description)[0]) (here) does not work afterward.

laszlojakab commented 1 year ago

Can it be solved by a restart or is it a persistent problem?

TheBigNeo commented 1 year ago

The problem persists. I have set the description manually for me

https://github.com/laszlojakab/homeassistant-easycontrols/compare/develop...TheBigNeo:homeassistant_helios_easycontrols:develop

laszlojakab commented 1 year ago

Could you please try to query the v00000 (article description) variable with eazyctrl to check if it is a integration related problem or something else? Integration based on eazyctrl package.

TheBigNeo commented 1 year ago
PS D:\Projects\PycharmProjects\eazyctrl> eazyctrl getvar 192.168.1.106 v00000 31
Error: Could not get variable 'v00000'

PS D:\Projects\PycharmProjects\eazyctrl> eazyctrl getvar 192.168.1.106 v00102 1 
1

PS D:\Projects\PycharmProjects\eazyctrl> eazyctrl getvar 192.168.1.106 v00103 3
16

PS D:\Projects\PycharmProjects\eazyctrl> eazyctrl getvar 192.168.1.106 v00002 18
Error: Could not get variable 'v00002'

PS D:\Projects\PycharmProjects\eazyctrl> eazyctrl getvar 192.168.1.106 v00094 1 
0

PS D:\Projects\PycharmProjects\eazyctrl> eazyctrl getvar 192.168.1.106 v02119 1
1

The information is also missing here image

laszlojakab commented 1 year ago

It is strange that the type is empty and you eazyctrl also fails to get variable value. I have never seen like that before. My device shows the actual type here: image

It could also be a firmware problem because I have one version older 2.26 than yours.

Maybe you could try to create an issue in eazyctrl github page if the package owner can fix the problem.

TheBigNeo commented 1 year ago

Yes, I can open an issue, but what should he change? If the device does not provide the information, he can't do anything.

If then we would have to catch it in your repo and use a default name.

I also created a new service to set the fan stage. Are you interested in another pr?

GDRMC commented 1 year ago

For anyone having this issue, I got a working solution after experiencing the exact same initialization problem. It has nothing to do with the integration, but with the way the initial setup is done on the device. Had weird String in place of the v00000 modbus field (Device data > Type), was "Please change SD- card" and giving me issues:

2023-10-30 18:52:04.326 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Helios Please change the SD- card (helios)' for easycontrols integration not ready yet: Error during initialization; Retrying in background
2023-10-30 18:52:09.673 DEBUG (MainThread) [custom_components.easycontrols.coordinator] Getting v00002.
2023-10-30 18:52:10.094 DEBUG (MainThread) [custom_components.easycontrols.coordinator] v00002 value: REDACTED
2023-10-30 18:52:10.094 DEBUG (MainThread) [custom_components.easycontrols.coordinator] Getting v00303.
2023-10-30 18:52:10.326 DEBUG (MainThread) [custom_components.easycontrols.coordinator] v00303 value: REDACTED
2023-10-30 18:52:10.326 DEBUG (MainThread) [custom_components.easycontrols.coordinator] Getting v00000.
2023-10-30 18:52:10.574 DEBUG (MainThread) [custom_components.easycontrols.coordinator] v00000 value: Please change the SD- card
2023-10-30 18:52:10.574 DEBUG (MainThread) [custom_components.easycontrols.coordinator] Getting v01101.
2023-10-30 18:52:10.822 DEBUG (MainThread) [custom_components.easycontrols.coordinator] v01101 value: 2.27
2023-10-30 18:52:10.822 ERROR (MainThread) [custom_components.easycontrols] list index out of range

In short, you must use modbus protocol to edit the value of the v00000 field with a "good" value. I first got the model of my helios HVAC from http:///tinfo.htm, manuals page redirected me to the "KWL EC 370 W R" page. The new value has to be "KWL EC 370 W R".

Download modpoll.exe from there https://www.modbusdriver.com/modpoll.html, and modbus documentation for Helios, which you can find here: https://www.easycontrols.net/fr/service/downloads/category/4-software (first two links)

From documentation, go at Chapter 2 of the English documentation (this document starts with German), then have a look at how modbus works.

Here is the command that worked for me and how I managed to prepare the hex String: v0000=KWL EC 370 W R

0x7630 0x3030 0x3030 0x3D4B 0x574C 0x2033 0x3730 0x2057 0x2052 0x00
  v 0    0 0    0 0    = K    W L      3    7 0      W      R

Do not forget 00 at the end for String termination.

Send this payload through this command, I recommend using a terminal and cd into the directory where modpoll.exe has been downloaded and extracted.

modpoll.exe -m tcp -a 180 -t4:hex -r 1 -0 -1 -o 2.0 <DEVICE_IP> 0x7630 0x3030 0x3030 0x3D4B 0x574C 0x2033 0x3730 0x2057 0x2052 0x00

Here is the command output

λ modpoll.exe -m tcp -a 180 -t4:hex -r 1 -0 -1 -o 2.0 <DEVICE_IP> 0x7630 0x3030 0x3030 0x3D4B 0x574C 0x2033 0x3730 0x2057 0x2052 0x00
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC16
Slave configuration...: address = 180, start reference = 1 (PDU), count = 1
Communication.........: <DEVICE_IP>, port 502, t/o 2.00 s, poll rate 1000 ms
Data type.............: 16-bit register (hex), output (holding) register table

Written 10 references.

Refresh your browser at http:///tinfo.htm, the value should change ! image

Now, go back to HA and refresh your integration, it should work flawlessly.

Had been playing with my own custom integration of helios from now on, now using this integration instead.

Michirieger commented 1 week ago

For anyone having this issue, I got a working solution after experiencing the exact same initialization problem. It has nothing to do with the integration, but with the way the initial setup is done on the device. Had weird String in place of the v00000 modbus field (Device data > Type), was "Please change SD- card" and giving me issues:

2023-10-30 18:52:04.326 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Helios Please change the SD- card (helios)' for easycontrols integration not ready yet: Error during initialization; Retrying in background
2023-10-30 18:52:09.673 DEBUG (MainThread) [custom_components.easycontrols.coordinator] Getting v00002.
2023-10-30 18:52:10.094 DEBUG (MainThread) [custom_components.easycontrols.coordinator] v00002 value: REDACTED
2023-10-30 18:52:10.094 DEBUG (MainThread) [custom_components.easycontrols.coordinator] Getting v00303.
2023-10-30 18:52:10.326 DEBUG (MainThread) [custom_components.easycontrols.coordinator] v00303 value: REDACTED
2023-10-30 18:52:10.326 DEBUG (MainThread) [custom_components.easycontrols.coordinator] Getting v00000.
2023-10-30 18:52:10.574 DEBUG (MainThread) [custom_components.easycontrols.coordinator] v00000 value: Please change the SD- card
2023-10-30 18:52:10.574 DEBUG (MainThread) [custom_components.easycontrols.coordinator] Getting v01101.
2023-10-30 18:52:10.822 DEBUG (MainThread) [custom_components.easycontrols.coordinator] v01101 value: 2.27
2023-10-30 18:52:10.822 ERROR (MainThread) [custom_components.easycontrols] list index out of range

In short, you must use modbus protocol to edit the value of the v00000 field with a "good" value. I first got the model of my helios HVAC from http:///tinfo.htm, manuals page redirected me to the "KWL EC 370 W R" page. The new value has to be "KWL EC 370 W R".

Download modpoll.exe from there https://www.modbusdriver.com/modpoll.html, and modbus documentation for Helios, which you can find here: https://www.easycontrols.net/fr/service/downloads/category/4-software (first two links)

From documentation, go at Chapter 2 of the English documentation (this document starts with German), then have a look at how modbus works.

Here is the command that worked for me and how I managed to prepare the hex String: v0000=KWL EC 370 W R

0x7630 0x3030 0x3030 0x3D4B 0x574C 0x2033 0x3730 0x2057 0x2052 0x00
  v 0    0 0    0 0    = K    W L      3    7 0      W      R

Do not forget 00 at the end for String termination.

Send this payload through this command, I recommend using a terminal and cd into the directory where modpoll.exe has been downloaded and extracted.

modpoll.exe -m tcp -a 180 -t4:hex -r 1 -0 -1 -o 2.0 <DEVICE_IP> 0x7630 0x3030 0x3030 0x3D4B 0x574C 0x2033 0x3730 0x2057 0x2052 0x00

Here is the command output

λ modpoll.exe -m tcp -a 180 -t4:hex -r 1 -0 -1 -o 2.0 <DEVICE_IP> 0x7630 0x3030 0x3030 0x3D4B 0x574C 0x2033 0x3730 0x2057 0x2052 0x00
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC16
Slave configuration...: address = 180, start reference = 1 (PDU), count = 1
Communication.........: <DEVICE_IP>, port 502, t/o 2.00 s, poll rate 1000 ms
Data type.............: 16-bit register (hex), output (holding) register table

Written 10 references.

Refresh your browser at http:///tinfo.htm, the value should change ! image

Now, go back to HA and refresh your integration, it should work flawlessly.

Had been playing with my own custom integration of helios from now on, now using this integration instead.

Thanks for that information. I have the KWL EC 500 W ET L and hat the same strange SD-Card Thing. Your solution worked great at the first try