Integration of heatpump „iDM Terra ML Complete HGL“

No :face_vomiting:

Hey, I’m back with my project, since the sun has been shining for several days now and I’ve had the chance to go on.

I have adapted the code to my system but as I’m still new to YAML coding I need support.

   - name: "WP aktueller PV Überschuss"
    unique_id: "wp_aktueller_pv_uberschuss"
    unit_of_measurement: kW
    state: >
     {% if ( states('sensor.pv_aktuelle_produktion') | float(3) ) | round(2) == 0 | float %}
       0.0
     {% elif (
                 states('sensor.stromzaehler_verbrauch') | float(3)
               + states('sensor.sn_3009431441_grid_power') | float(1)
             )|round(2) > 0 | float
     %}
       0.0
     {% else %}
       {{ (
            (
                states('sensor.stromzaehler_verbrauch') | float(3)
              + states('sensor.sn_3009431441_grid_power') | float(1)
            ) *(-1)
          ) | round(2) }}
     {% endif %}
    state_class: measurement
    device_class: power
    icon: mdi:solar-power

In this code block I’m calculating two states - sensor.stromzaehler_verbrauch and sensor.sn_3009431441_grid_power. Once addition, once subtraction.

The issue is, that one value comes in kW and one in W.

Question: (how) can I calculate /1000 on the fly (directly in the code line), is there a valid syntax or do I have to define a new entity for this intermediate result?

BR
Michael

{{ states('sensor.sma_aktuelle_leistung')|float / 1000|float }}
        

here a simple example

1 Like

Thank you! I had been trying this before, but without success.
Now I finally found the bug! Debug notification in Home Assistance are challenging…

Hi everyone and first of all thanks for all the good informations you posted, the setup from @SimowN is the more detailed I found in days of searching.

I am currently trying to read data from an IDM heat pump using Modbus.
I have enabled modbus in the heat pump menu (still have to set smart fox, as I am only interest in reading at the moment) and configured the modbus part like @SimowN did in his repo.
However, I noticed that sometimes sensors in home assistant appears as unavailable.
The more sensible seems idm_vorlauftemperatur, idm_vorlauftemperatur, idm_leistungsaufnahme.
I increased every scan_interval to 60 or more as the intervals seemed very low and now it is more noticeable.

Looking at logs the error seems to be

2023-04-19 16:32:53.360 ERROR (SyncWorker_5) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.60.3:502): Connection unexpectedly closed 0.0066907405853271484 seconds into read of 8 bytes without response from unit before it closed connection

Reading online it can be related to pymodbus which has been update in 2023.2 if I correctly understood, but still no idea how to fix it. Moreover, I do not have feedback on previous versions because I just installed everything.

So basically I have two questions:

  • Did you encounter the same problem?
  • Did you set scan_interval to low values (15 or 20) for this reason or for another particular reason?

Thank you very much

These are the version of the software I currently use

Home Assistant 2023.4.5
Supervisor 2023.04.0
Operating System 10.0
Frontend 20230411.1 - latest
IDM: 20.22

I already read this message, but to long to know what the trick was…

Have you configured modbus service from off to on on your idm navigator?

Yes, I turn it on before trying as I followed one of the PDF you linked.

The strange thing is that I can get all the values I want to read.
It is just that in some cases only few variables are read and then this error appears.

I looked into it and it occurs also using small intervals, it is simply that since the intervals are really small it is not so evident from the interface, but I can find it in logs

Just a small update, today I tested almost everything I could.

Simplifying the network having only IDM and raspberry connected on the router, changing both IP addresses to be sure no other services are interacting with them.
Turning on and off modbus in navigator.
Disabling every other modbus configuration, removing all sensors and starting inserting one by one, however the problem occurs even with a single sensor.
Still no way to solve the issue, I am now coding in python using pymodbus==3.2.2 and AsyncModbusTcpClient and everything seems to work from a small script.
So now I am looking for differences in homeasssistant/core implementation.
In worst case I will try to insert the small script and populate sensors from it.

Can any of you indicate a version of Home Assistant in which everything works? The other possibility I consider is a downgrade if necessary.

The scan interval is by trying to get a good value for testing. In productive mode i changed them to 30….

I think reading is not the issue, i‘m writting every 3 minutes the solar values to the idm, i think here you have to check to do not get to close intervals.

I‘m not sure, but I think your error message belongs to reading a wrong type from a field (to short or to long values), and after this try, the connection get closed.

Did you rechecked the register addresses from my sample with your idm configuration?

Yes, to be sure I am currently using a sample from your GitHub repo.
At the moment I configured only idm_Warmwasserzapftemperatur. the only changes I made are scan_interval which I set to 60 and I added a unique_id so that I can rename the sensor after.

But as you can see form the screenshot, I still encounter problems in reading the value.
It seems that every time it reads a correct value the next time it fails, then the next one Is correct again.
Actually from the graph the strange thing is that it seems it reads a correct value every time. However, since it encounters an error in the reading process it set the value to unavailable.

Sorry I can not reproduce your issue and I‘m not familiar with the python / modbus libs and there versions… For me it looks like that any network route is broken for this time.

I also tested in the last days your interval, worked perfectly.

Hello everyone,

I tried to add the idm_heating.py file to the /custom_component/idm_heating/ folder as shown in the image. However, after adding the sensor to configuration.yaml and attempting to restart, I received the error message:
Platform error sensor.idm_heating - Integration 'idm_heating' not found.
I have tried various solutions but none have worked. Can someone please help me?

Some additional information:
I am currently renting my home, so I cannot obtain the PIN to configure Modbus.

Home Assistant version 2023.4.6
Supervisor version 2023.04.1
Operating System version 10.1
Frontend version 20230411.1 - latest

Thanks!
image
image

Hi All,

I see a pretty similar effect like Colle described above.
I read out value from IDM with modbus every 15 seconds. However, it seems like that I only can actually read out the value from every 4th try.

To avoid having empty reads (no data vailable), I created a “dummy” readout at the very beginning of the modbus list. This will do the first reading and fail/interrupt the reading for the others.
However, that means that the other values are only available for every minute.

2023-05-01 16:00:05.088 ERROR (SyncWorker_2) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.180.70:502): Connection unexpectedly closed 3.24249267578125e-05 seconds into read of 8 bytes without response from unit before it closed connection

2023-05-01 16:00:35.090 ERROR (SyncWorker_1) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.180.70:502): Connection unexpectedly closed 3.361701965332031e-05 seconds into read of 8 bytes without response from unit before it closed connection

2023-05-01 16:00:50.091 ERROR (SyncWorker_3) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.180.70:502): Connection unexpectedly closed 2.8133392333984375e-05 seconds into read of 8 bytes without response from unit before it closed connection

2023-05-01 16:01:05.091 ERROR (SyncWorker_2) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.180.70:502): Connection unexpectedly closed 2.5033950805664062e-05 seconds into read of 8 bytes without response from unit before it closed connection

2023-05-01 16:01:35.094 ERROR (SyncWorker_5) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.180.70:502): Connection unexpectedly closed 2.86102294921875e-05 seconds into read of 8 bytes without response from unit before it closed connection

2023-05-01 16:01:50.094 ERROR (SyncWorker_5) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.180.70:502): Connection unexpectedly closed 3.0517578125e-05 seconds into read of 8 bytes without response from unit before it closed connection

2023-05-01 16:02:05.096 ERROR (SyncWorker_3) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.180.70:502): Connection unexpectedly closed 3.147125244140625e-05 seconds into read of 8 bytes without response from unit before it closed connection

2023-05-01 16:02:15.380 ERROR (SyncWorker_2) [homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.180.70:502): Connection unexpectedly closed
modbus:
  - name: "idm_wp"
    type: tcp
    host: 192.168.180.70
    port: 502
    sensors:
      - name: "idm_Aussentemperatur_dummy"
        unique_id: "idm_Aussentemperatur_dummy"
        slave: 1
        unit_of_measurement: °C
        address: 1000
        data_type: float32
        count: 2
        precision: 1
        swap: word
      - name: "idm_Leistungsaufnahme"
        unique_id: "idm_Leistungsaufnahme"
        slave: 1
        address: 4122
        data_type: float32
        count: 2
        precision: 1
        swap: word
        unit_of_measurement: kW
        device_class: power
        state_class: measurement        
      - name: "idm_Momentanleistung"
        unique_id: "idm_Momentanleistung"
        slave: 1
        address: 1790
        data_type: float32
        count: 2
        precision: 1
        swap: word
        unit_of_measurement: kW
        device_class: power
        state_class: measurement
        
      - name: "idm_AktuellerPhotovoltaikUeberschuss"
        unique_id: "idm_AktuellerPhotovoltaikUeberschuss"
        slave: 1
        unit_of_measurement: kW
        address: 74
        data_type: float32
        count: 2
        precision: 1
        swap: word
      - name: "idm_AktuellePhotovoltaikProduktion"
        unique_id: "idm_AktuellePhotovoltaikProduktion"
        slave: 1
        unit_of_measurement: kW
        address: 78
        data_type: float32
        count: 2
        precision: 1
        swap: word

I tried to increase the readout time to every minute instead of every 15 seconds. But in this case again only every 4th value will be read correcty and results into a 4 minute readout.

Anyone has an idea what could cause this modbus error?

@SimowN thank you very much for the time you spent testing it.

@geryyyyyy yes exactly the same issue.

I only partially understand the dummy variable, as I understand the idea, but when I insert more than one value I randomly receive unavailable on the different values. But probably this is due to the fact that I use different scan_intervals.

Might be, in my case all values have the same scan_interval.

I just tested this IDM intregration on HACS:

This one seems to be working fine even with readouts every 15 seconds:

As this is working fine, I don’t think our modbus issue comes from IDM site. I guess it has something to do with our yaml config?

For me this full IDM integration would work as well, but I would need to update the values ‘sensor.idm_warmepumpe_aktueller_pv_uberschuss’ and ‘sensor.idm_warmepumpe_aktueller_pv_produktion’ somehow…

I did not tested this integration, but I will.
I have the same problem I also want to update the two values.
I also have the same feeling that is a home assistant modbus related problem, I was looking into homeassistant core to see if others have the same problem. I think it is something regards the way it is implemented. I wrote a small python script just to test if it was related to pymodbus 3.x but both 3.1.3 (the one in the current core) and 3.2.0 works.

I found out a single issue, where the person who wrote it finally found a solution and it was another software that was interfering. For this I setup a completely different network made only of router home assistant idm and the pc all with new ips and nothing changed. Now that you tested another integration I am more convinced that it should be a problem of implementation.

I can confirm that everything correctly works using the integration you linked.
I still think it depends on the home assistant core modbus implementations as both the core and the integration uses the same library pymodbus 3.1.3
Have to check but I think the library uses asynchronous client while core use the synchronous one.

I am also looking into a solution to update the two variables:

  • sensor.idm_warmepumpe_aktueller_pv_uberschuss
  • sensor.idm_warmepumpe_aktueller_pv_produktion

@SimowN how do you calculate "PV geschätzte Produktion (nächste Std.)
thanks for your integration. unfortunatelly I had the same isssues with the modbus connection:
Connection unexpectedly closed…
but you gave me some ideas for the automation…

Hi,

I have been trying to create a humidity sensor, but all of them display the same value at the same time. I’m not sure what I’m doing wrong. Can someone help? Thank you very much.

      - name: "idm_Hum_r1"
        unique_id: "idm_Hum_r1"
        slave: 1
        unit_of_measurement: '%'
        address: 2034
        data_type: float32
        count: 2
        precision: 1
        swap: word

Hi all,
I also had the very same issues: reading has lot of ‘unavailable’ items sometimes it works.
Also similar problem when writing back the values as Simon proposed. Usually only one item reached the IDM. It seems that IDM Modbus interface is a bit picky. So I added these lines to the script:

  - service: modbus.restart
    data:
      hub: idm_wp

that did the job for writing BOTH values, so in context it looks like this:

idm_update_pv_values:
  alias: Update Photovoltaik values to IDM Headpump
  sequence:
  - service: modbus.restart
    data:
      hub: idm_wp
  - service: modbus.write_register
    data:
      hub: idm_wp
      unit: 1
      address: 74
    data_template:
...

still have some problems when reading the values!?