mbuchber / ha_heliotherm

Home Assistant Custom Component for Heliotherm Heatpumps
16 stars 5 forks source link

Discrepancies with values read / values seem wrong #3

Closed partach closed 1 year ago

partach commented 1 year ago

Hi,

I see a discrepancy between value read by HA as opposed to values read by App/website of Heliotherm. As example:

Any ideas where this discrepancy comes from?

partach commented 1 year ago

Hi Michael, any chance to have a look at this? Can i help?

mbuchber commented 1 year ago

Hi, sorry for my late response - in my case all these values are zero (0) - in the App/Website and also in HA, I have no idea why these value differ. Maybe they rely on different base values? Do you have any clue what could be behind that?

partach commented 1 year ago

My guess would be there is an offset error in reading modbus registers. So actually the wrong (part) of the address is read. But could be other stuff. Different sizes of registers? Wrong typecasting? (int, float, etc), LSB/MSB reversed? Code error? Documentation error? Or maybe update in modbus implementation for Heliotherm? So i would need to dive into the code maybe to check. Any rough architecture explanation of the code? Which file does what.

heubie commented 1 year ago

I have the same issues and looked in to it. It looks like there al the 32 bit values (float's) which are wrong. I tried to shift around with the modbusdata2 register settings in de _init_py code but I can't get values who are the same as in the remotecontrole.at website. Some of my values are negative so looks like the was a shift in Modbus Register addresses. I'm not a programmer but do like to play around in the code.....

mbuchber commented 1 year ago

Thanks for the comment - I have the problem, that all of my values are zero within my heatpump and therefore have the problem, that I cannot tell which way to read the values is the correct one. But I read these values the same way as others with the same data type and the works in all other cases, so this is kind of weird - I will try to get in contact with the company and ask for support. I will let you know here any progres...

heubie commented 1 year ago

I did some further testing and found that this does readout the values. The values are the same as the once in the remotecontrol environment but of coarse the vales behind the decimal are not represented (integer). I also asked my local Heliotherm dealer if the is an update version of the "Nutzung des Modbus-Protokolls im RCG2" V1.0/10.04.2017 (AS)

 - name: WMZ_Heizung (kWh)
    scan_interval: 1000
    slave: 1
    scale: 1
    address: 61
    unit_of_measurement: kWh
    input_type: input
    data_type: int16
  - name: Stromz_Heizung (kWh)
    scan_interval: 1000
    slave: 1
    scale: 1
    address: 63
    unit_of_measurement: kWh
    input_type: input
    data_type: int16
  - name: WMZ_Brauchwassr (kWh)
    scan_interval: 1000
    slave: 1
    scale: 1
    address: 65
    unit_of_measurement: kWh
    input_type: input
    data_type: int16
  - name: Stromz_Brauchwassr (kWh)
    scan_interval: 1000
    slave: 1
    scale: 1
    address: 67
    unit_of_measurement: kWh
    input_type: input
    data_type: int16
  - name: Stromz_Gesamt (kwh)
    scan_interval: 1000
    slave: 1
    scale: 1
    address: 69
    unit_of_measurement: kWh
    input_type: input
    data_type: int16
heubie commented 1 year ago

I got the new document. If you want I can send it to you.

The values are not int16 but uint32.

mbuchber commented 1 year ago

ok thanks I will change this

mbuchber commented 1 year ago

I tried to change the decoding to signed 32 Bit of these values - can somebody check if this makes a difference. The values in question are all zero in my case, so I am not able to check...

heubie commented 1 year ago

Looks like everything works except for "Temp. Frischwasser". But we will finish the setup next week and I hope this sensor is connected then.

Capture

mbuchber commented 1 year ago

ok, did you compare the values to the web interface?

heubie commented 1 year ago

No, you are right, the negative values are gone but they are not ok. Could it be that readout the wrong Modbus register. The starting adres is 1 and as you see I had to read Reg 61 (int16) to get the correct value and the new document says Reg 60-61. Capture

heubie commented 1 year ago

I did my best to get as much as possible sensors in 1 shot. My remotecontrol screen is in English but if you look at the document you can compare the values. Capture

mbuchber commented 1 year ago

Try again, I checked in a new release - otherwise I will send you a dump and you send it back to me, then I can find out whats the problem...

heubie commented 1 year ago

Sorry to say but it doesn't work. As I mentioned a made sensor (Stromzahl_Leistung) to read out a value (this time with unit32) to do some calculations and this one works. Maybe this helps you. modbus:

mbuchber commented 1 year ago

Which version did you test? Current is 1.0.7

heubie commented 1 year ago

No I tested 1.06 but did test 1.0.7. now......sorry NOK I have some work to do new but in the afternoon I will check 1.0.7 again but then with Little i.s.o Big again. image

heubie commented 1 year ago

I gues I did somthing wrong but I can not get it running anymore. I'll keep gettings this error: 2023-01-20 20:36:02.076 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration ha_heliotherm: cannot import name 'ModbusTcpClient' from 'pymodbus.client' (/usr/local/lib/python3.10/site-packages/pymodbus/client/init.py)

heubie commented 1 year ago

I did some search on the internet and found how to update the pymodus and managed to get 3.1 installed. So the 1.07 at least installs and sometimes gives values but also gives the same error on a reboot.

mbuchber commented 1 year ago

if you unistall old version, and reinstall 1.07 newly, the new version pymodbus should be installed automatically. Are you sure, that on reboot the error massage appears again?

heubie commented 1 year ago

I had my doubts on the status of my install so I took an old laptop and did a fresh install of a Generic x86-64 Home assistant. I added HACS an from there I installed 1.07. So I have a clean system with only this. The good news is that the error about pymodbus 3.10 are gone but the values are still not OK. When I use "Big" thay are all 0. When I use Little the are as in the screenshot.

image

heubie commented 1 year ago

I did some reading on the "BinaryPayloadDecoder" and found what is wrong. I went back to version 1.05 and changed:

[line 378] decoder = BinaryPayloadDecoder.fromRegisters( [line 379] modbusdata2.registers, byteorder=Endian.Big <----changed wordorder to byteorder [line 380] )

O, and found a small readout error:

[line 364] self.data["expansionsventil"] = self.checkval(expansionsventil, 0.1) <-- changed 1 to 0.1

My readouts are now the same as the ones in remotecontrol.at but they are 2 decemals accurate. Maybe you can change this?

mbuchber commented 1 year ago

Cool, thanks for the help! I just missed the word/byteorder - that makes sense... One more thing, are the values in the webcontrol decimals or intergers? I am not quite sure weather to decode as uint or as float...? Can you post some example like above - value from Home Assistant and vakue from webcontrol with your changes based on version 1.0.5 Please also past the code from line 378 - downto the end - thanks.

heubie commented 1 year ago

Code from line 377 downwards:

    # -----------------------------------------------------------------------------------
    decoder = BinaryPayloadDecoder.fromRegisters(
        modbusdata2.registers, byteorder=Endian.Big
    )

    wmz_heizung = decoder.decode_32bit_uint()
    self.data["wmz_heizung"] = self.checkval(wmz_heizung, 1, 32)

    stromz_heizung = decoder.decode_32bit_uint()
    self.data["stromz_heizung"] = self.checkval(stromz_heizung, 1, 32)

    wmz_brauchwasser = decoder.decode_32bit_uint()
    self.data["wmz_brauchwasser"] = self.checkval(wmz_brauchwasser, 1, 32)

    stromz_brauchwasser = decoder.decode_32bit_uint()
    self.data["stromz_brauchwasser"] = self.checkval(stromz_brauchwasser, 1, 32)

    stromz_gesamt = decoder.decode_32bit_uint()
    self.data["stromz_gesamt"] = self.checkval(stromz_gesamt, 1, 32)

    stromz_leistung = decoder.decode_32bit_uint()
    self.data["stromz_leistung"] = self.checkval(stromz_leistung, 1, 32)

    wmz_gesamt = decoder.decode_32bit_uint()
    self.data["wmz_gesamt"] = self.checkval(wmz_gesamt, 1, 32)

    wmz_leistung = decoder.decode_32bit_uint()
    self.data["wmz_leistung"] = self.checkval(wmz_leistung, 1, 32)

    # -----------------------------------------------------------------------------------

    select_betriebsart = modbusdata3.registers[0]
    self.data["select_betriebsart"] = self.getbetriebsart(select_betriebsart)

    climate_hkr_raum_soll = modbusdata3.registers[1]
    self.data["climate_hkr_raum_soll"] = {
        "temperature": self.checkval(climate_hkr_raum_soll, 0.1)
    }

    climate_ww_bereitung_max = modbusdata3.registers[5]
    climate_ww_bereitung_min = modbusdata3.registers[6]
    self.data["climate_ww_bereitung"] = {
        "target_temp_low": self.checkval(climate_ww_bereitung_min, 0.1),
        "target_temp_high": self.checkval(climate_ww_bereitung_max, 0.1),
        "temperature": self.checkval(temp_brauchwasser, 0.1),
    }

    # externe_anforderung = modbusdata3.registers[20]

    return True
heubie commented 1 year ago

I don't know what the values are in "remotecontrol" (decimal or integer) but they do have some decimals, see attached picture.

image

mbuchber commented 1 year ago

Can you try the following code and tell me what comes out?

    wmz_heizung = decoder.decode_32bit_float()
    self.data["wmz_heizung"] = round (wmz_heizung,2)
heubie commented 1 year ago

I had to change: self.data["wmz_heizung"] = round (wmz_heizung,2) to
self.data["wmz_heizung"] = round(wmz_heizung, 2)

to get it running but the value is 0.0 kWh, so my best guess is that the have a value in there controller but the value they put in modbus register is a 32uint. No problem om those large numbers.

mbuchber commented 1 year ago

Released Version 1.0.8... hopefully its ok now. Thanks for your help!

heubie commented 1 year ago

Everything looks good now!!!!

You only forgot "[line 364] self.data["expansionsventil"] = self.checkval(expansionsventil, 0.1) <-- changed 1 to 0.1"

but this is no big deal.....

mbuchber commented 1 year ago

Ok, now I changed it... I redeployed v1.0.8 - so if you want to update, you need to select "Redownload" in the HACS->Repository.