kodebach / hacs-idm-heatpump

HACS integration for IDM heat pumps
MIT License
20 stars 1 forks source link

Add solar battery SOC #30

Closed Krasto82 closed 9 months ago

Krasto82 commented 9 months ago

Is your feature request related to a problem? Please describe. I would like to be able to see the SOC of the Huawei battery, just like I can see it on the heat pump display (I'm attaching a screenshot). idm

kodebach commented 9 months ago

Sorry, I don't think that's possible for this integration. AFAIK this info is not reported by the IDM heat pump (at least not via the Modbus interface this integration uses).

However, I did find https://github.com/wlcrs/huawei_solar. Maybe that integration can provide the data you're looking for.

Krasto82 commented 9 months ago

Thank you for your response. I was using this integration until a few weeks ago, but it stopped working, and I can no longer access the data from the solar inverter.

kodebach commented 9 months ago

I was using this integration until a few weeks ago, but it stopped working

You mean the integration I linked? If so, may I suggest you report the problem over there. I can't really help you there, since I don't know the integration and don't have access to a Huawei solar inverter.

All I can say is that AFAIK the only solar power stuff reported by the IDM Modbus interface is "PV Produktion" (solar power output) and "PV Überschuss" (excess solar power). Those two values should already be reported by the integration.

Krasto82 commented 9 months ago

Yes, i mean custom Huawei integration not work. Your integration works perfectly! Thanks for the help!

AndyNew2 commented 6 months ago

@Krasto82 I think you can exactly do what you want. Check the current issues especially #69, I think you will find there all needed information. Good luck, it works for me...

Krasto82 commented 6 months ago

@Krasto82 I think you can exactly do what you want. Check the current issues especially #69, I think you will find there all needed information. Good luck, it works for me...

Yes, this is the value i need! Thanks image

AndyNew2 commented 6 months ago

Be aware ID 86 is an integer not a float. You would get crazy batterie values, when writing a float. Therefore it support only 1% as LSB, you can't have 0,1% or something like 35.6% but that is acceptable. After regulary writing these values, I got also further statistics in IDM GUI and you can now specify a procentage value for the battery to enter IDM Solarpower mode. Have fun... You are from Italy?

Krasto82 commented 6 months ago

yes the soc is reported as integer even in the heat pump display in fact. It is perfectly fine as an integer value, having the decimals would be superfluous

Krasto82 commented 6 months ago

oh and yes, i'm italian

AndyNew2 commented 6 months ago

Nice to see, where IDM goes in the world. How long do you use it, and do you have NavigatorPro as well, or just standard room thermostates, or just nothing? It seems a few thinks are just complicated here in Germany, to be honest... Would be curious, if the new values works for you as well.

Krasto82 commented 6 months ago

I installed the heat pump at the end of 2021, and we are very comfortable with it. We live in the Italian Alps and the hp heats 2 apartments of 90sqm perfectly. One floor with Netatmo thermostat while the other with a supplied thermostat (the white one with a wheel, I don't know if it is the navigator). urfortunately italy is an "old" country and not many of us have heat pumps. Many people even still use oil boilers and don't want to switch to renewable energy....

Krasto82 commented 6 months ago

I created a sensor to see the SOC of the battery. The problem is that it works intermittently, one reading works fine and the other doesn't. probably I'm doing something wrong... This is the code:

`# ModBUS per lettura SOC batteria FV modbus:

AndyNew2 commented 6 months ago

I splitted it up into two parts. in my configuration.yaml there is only:

modbus:
  - name: "idm_heatpump"
    type: tcp
    host: 192.168.1.5
    port: 502
AndyNew2 commented 6 months ago

The rest is done from a script, I call regulary (every 30 seconds) from an automation:

idm_update_house_and_batt_values:
  alias: Update house values to IDM Headpump
  sequence:
  - service: modbus.restart  
    data:
      hub: idm_heatpump
    enabled: true
    # Hausverbrauch
  - service: modbus.write_register
    data:
      hub: idm_heatpump
      unit: 1
      address: 82
    data_template:
      value: >
        {% set myHomePower = (states("sensor.azzurrowechselrichter_activepower_load_sys")|float*0.001) %}
        {% set myHomePower = myHomePower + states("sensor.idm_warmepumpe_aktuelle_leistungsaufnahme_warmepumpe")|float %}
        [ {{ unpack(pack(myHomePower, ">f"), ">H", offset=2) }}, 
          {{ unpack(pack(myHomePower, ">f"), ">H") }} ]
    # Batterieentladung
  - service: modbus.write_register
    data:
      hub: idm_heatpump
      unit: 1
      address: 84
    data_template:
      value: >
        {% set myBattPower = -0.001 * states("sensor.azzurrowechselrichter_battery_1_power")|float  %}
        [ {{ unpack(pack(myBattPower, ">f"), ">H", offset=2) }}, 
          {{ unpack(pack(myBattPower, ">f"), ">H") }} ]
    # Batteriefüllstand
  - service: modbus.write_register
    data:
      hub: idm_heatpump
      unit: 1
      address: 86
    data_template:
      value: >
        {% set myBattState = states("sensor.azzurrowechselrichter_battery_1_soc") %}
        [ {{ myBattState }} ]
  mode: single
AndyNew2 commented 6 months ago

I think the key are the first lines

  - service: modbus.restart  
    data:
      hub: idm_heatpump
    enabled: true

Since the modbusTCP implemenation in HA is not very perfect, to be honest, this reset is needed to keep it working. Maybe that is the issue you fall over?

Krasto82 commented 6 months ago

i made this:

configuration.yaml: `modbus:

script.yaml: `idm_update: alias: Aggiornamento valori corrente IDM Headpump sequence:

automation.yaml `- alias: Avvia refresh modbus IDM trigger:

Unfortunately, I get this error and nothing works: The "Avvia refresh modbus IDM" automation (automation.avvia_refresh_modbus_idm) has an action that calls an unknown service: script.idm_update. This error prevents the automation from working properly. Perhaps this service is no longer available, or perhaps a typo caused it.

do you have any suggestions as to where i am wrong? thank you very much

Krasto82 commented 6 months ago

Also, I have the same problem as before, but every 30 seconds....

AndyNew2 commented 6 months ago

I think you totally misunderstood my post. The current IDM Integration has no support yet for these new values. You need to write them yourself. The script I posted before does everything you need. You would not need even the IDM_Integration for that purpose. Of course you can add the PV Generation and PV Overproduction values as well, but these two are supported by the IDM_Integration. You need to copy my script, especially the Modbus IDs are important. After that is should work. The IDM_Integration do not need this modbus reset, since the developer added himself a reasonable error handling.

Krasto82 commented 6 months ago

yes I misunderstood, I apologize. So I would just copy your code? Can the "sensor.azzurrowechselrichter_......" sensors be renamed as desired? (I assume you have a zucchetti inverter). As automation just call the script "idm_update_house_and_batt_values"?

AndyNew2 commented 6 months ago

Correct exactly that way. Replace the sensor values with yours. Since the heatpump wants kW as unit and my inverter delivers W I needed the recalculation with * 0.001. This is all dependent on your inverter, but I am sure you know how to modify the script. After you created the script you can call it from an automation. Good luck, it works for me. I hope Klemens will implement these values in the IDM_Integration, after that we can use the IDM_Integration service, once implemented.

AndyNew2 commented 6 months ago

By the way: Happy new year, and good luck with your heatpump!

Krasto82 commented 6 months ago

Correct exactly that way. Replace the sensor values with yours. Since the heatpump wants kW as unit and my inverter delivers W I needed the recalculation with * 0.001. This is all dependent on your inverter, but I am sure you know how to modify the script. After you created the script you can call it from an automation. Good luck, it works for me. I hope Klemens will implement these values in the IDM_Integration, after that we can use the IDM_Integration service, once implemented.

Yes, thanks for the help and happy new year!

Krasto82 commented 6 months ago

By the way: Happy new year, and good luck with your heatpump!

Hi Andy, i have a news. I've tried to READ the 86 address and works!

idm ha

AndyNew2 commented 6 months ago

Hi, everything seems to be good now. In my case, I just write to iDM my converter values. I have them all already in HA. In your case it seems a little bit wired? So your converter was originally completely supported by iDM and all the values had been communicated directly between your converter to the heatpump, is that correct? Than something happened, and it gots partly corrupted. With the values you can now correct the corrupted part? However you still want to read back the battery charge from iDM? Of course, all that values are shows as read/write, so you can read them back from iDM, no issue.