-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the possibility to write values using IDM modbus #10
Comments
First of all thanks for the interest in the integration. I know of the writable registers the IDM heat pumps provide. However, I have not implemented them, because the heat pump I used to develop this integration is connected to a Fronius Solar Inverter, which uses a proprietary protocol through which the heat pump can access even more information than otherwise. Therefore, I sadly have no way of testing the modbus way of setting solar energy values. Without a way to test things, I'm not comfortable to write the necessary code. If you feel comfortable writing the necessary code yourself, I am open to pull requests. I can also point you in the right direction (which code probably needs changes), but you'd have to do most of the work. Otherwise, I can only suggest you look into connecting the heat pump to your solar inverter through some other means. The IDM multiple different inputs for this, IDM support may be able to help you with that and you can also find some info via Google.
Yes, that in fact is part of the reason why I developed this integration. It seems the IDM heat pump doesn't like to keep TCP sockets open and refuses to respond after a while. The integration solves that by trying to reconnect when a read fails. Only if the reconnect also fails is the value set to unavailable. |
Yes I am considering a pull request but I still trying to understand the code. You did a really great job and looking into your code I am learning a lot of things. Last time I tested I was looking into the docker setup you made with visual studio code. I will try to implement something as soon as I understand the code better. For the moment since you know a lot of the problem on the TCP socket, what do you think opening an issue on homeassistant/core repo to explain the problem? and suggesting them the same fix? Probably it can solve the situation also for others. |
The VS Code / devcontainer setup is based on https://github.com/ludeeus/integration_blueprint, which has a bit more documentation on it.
There is already a recent issue home-assistant/core#87265 for similar problem with different device. The developers of Homeassistant decided that the "Connection unexpectedly closed" problem is not an error in the modbus integration and therefore they cannot do anything. It seems the config in home-assistant/core#87265 (comment) (somewhat) helped the person with the original issue. Maybe it works for you too. Otherwise, I would suggest you open a new issue yourself. You can tag me, or link to this issue and I'll gladly explain to the homeassistant devs what I did in this integration. But I don't think it would be much help, if I opened the issue myself. I don't have any logs with the error right now. I also can't test any fixes without reconfiguring my (working) homeassistant setup, which I'd like to avoid.
If the IDM heat pump does use a timeout for idle connections, the read intervals configured in homeassistant would definitely have an effect on the issue. If you read very often, you may not see the error at all. It could also be that different IDM models act differently or that it depends on your local LAN setup, especially WiFi might cause unstable connections. |
Thank you very much I found the documentation and I started following it yesterday. Let's see if I can come up with something useful. I have read the issue you linked multiple times, but at the end the owner found out the problem which was a NodeRed instance. After reading the issue I tested different setups hoping that also in my case was something network related. I disconnected everything and to be sure there was nothing even on my pc (which I use to monitor) I changed all the ips, but nothing. I found also an issue home-assistant/core#87265 which is more related to RTU but that suggest in June there will be an update of pymodbus. |
@Colleoni If you have progress on the writing data to the heatpump and you need testers... I'd be in... would be nice to control heating temperature in winter via home assistant! Also THANKS a lot for the integration so far. I used to read the values manually using node-red and their modbus integration. But this is just so much easier and gives me so much more sensor data! Love it! Thanks a lot!!! |
Hi all, closing connection and sockets may be related to limited resources and is a way to keep the system running endless. Therefore this behavior may be partly intended by IDM and I can understand why they did so. @kodebach: Your code fixes that issue and I think this is the prefered way anyway. You never can expect sockets are endless connected and need always be prepared for a error handling and reconnect code. Well done, just keep it that way, even modbus implementation changes later. That is good practise anyway. |
Yeah that all makes sense. However, the way it is implemented is still very strange. The heat pump doesn't actually terminate the TCP socket AFAICT, it just stops responding and/or sends empty responses. |
@georgbachmann @AndyNew2, unfortunately I did not have time to look any further into the setup. So still at the starting point and currently using a manual schedule which I setup to what I expect to be sunny hours during the day. Simply by manually looking into PV production stats (sure it does not consider the possibility of cloudy days, so not a real solution) For the initial considerations, sure it depends on personal setup I do not expect to find them integrated (or at least not strictly required), I just thought they could be useful to explain the issue and the possibilities. |
@Colleoni - @SimowN implemented the writing of the PV values already. See https://github.com/simowNgithub |
@kv62: I struggle to understand the work from SimowN: Does this mean the provided script directly writes the values via modbus to the iDM Heatpump. Because the provided github link is no home assistant integration. It is just little elements. The description is poor. So nothing to install, just copy and past the script and adapt to my needs? For example I do not need this calculation and currently just want to copy the values from Solarmodul to iDM. |
@kodebach should we check it together to get it work? at the moment i tuned my script for restarting the HA modbus service after every write register to the IDM. Because after updating the modbus libs with HA 2023.09.* the old script was broken. |
AFAICT the repo at https://github.com/simowNgithub/Homeassistant-IDM-Integration contains example configuration files that use the existing
The integration already has code to automatically restart it's internal modbus client, if a read fails, so there shouldn't be any issues in this integration. I believe the improvement to the underlying In #40 I added some basic logic for writing values via a service exposed by the integration. It is almost entirely untested, but should in theory allow write the values requested here. Feel free to test and provide feedback in #40. |
Yes that is a lot better understandable. When I read the description from simowNgithub, I expected to see something similar you did. But this is not the case. The the sentense "Use my script for getting the available power for the heatpump and sync the values to the heatpump" means actually a little bit rework and not just using the script. The main work is actually in the configuration file holding the code and needs adaptation. Nothing described, but the integration in iDM which is described in the iDM paper anyway, is very detailed. That is confusing, since you expect the same detail level on the HA integration as well. I am quite busy in the moment but at a certain point will try #40 |
Thanks to @kodebach for the improved integration. So far I have used @simowNgithub 's script/config and adapted this for my situation (surplus solar power provided from a P1-connector to my smart meter + calculated solar production from my clamps used by my Myenergi-car charger(some problems with the latter)). I get values to the heat pump and can see that it reacts based on this. I am now considering to use @kodebach 's integration as the basis. To make this work for my situation, I wanted to ask whether it is correct that I can do the following:
Appreciate if you could confirm that in principle this would work + I assume that the @kodebach integration will be extended with the write option later on, so that only 1. will be required. |
In theory your idea should work. I think you can just remove the |
it is exactly what i‘m doing. and exaktly the case why i‘m active in this issue, because for long term i want to get everything work by only using the idm integration package from @kodebach. |
Anybody tried yet this beta? It is a little bit hassle to install that version. |
Hi All, I am about to test the write feature. I was able to successfully implement the write-values branch into HA. But I struggle with the adaption of the scripts.yaml.
I am not sure with what I have to replace the data (hub, unit, address) part with?
My sensor names from the integration are default:
Could someone please give me an example what exactly this has to look like? |
Hi, i had this issues with the new HA releases. At the moment I always restart the modbus HA component before the write register…
|
See #40 (comment) |
A question to people already have written to the registers.
|
Actually for trying the branch I am a little bit behind the topic. Do I need to have git installed to do so? I have no idea how to get the clone done. I guess it is too error prone to do it file by file and transfer this to the HA installation? |
That seems to be the case. At least from what I can tell with my setup, where the heat pump is communicating directly with the Fronius solar inverter. I can still read the "PV Übschuss" value from the heat pump and as soon as the heat pump switches on this value drops. I assume the the idea behind the two value is that you have two power meters. One that measure the power from the solar array and another that measures the power leaving your house towards the grid (sometimes you can use the smart meter provided by the power company for that). The heat pump then wants the raw value from the first power meter as well as the difference between the two meters. The Modbus documentation from IDM also says that you can use the "Aktuelle Leistungsaufnahme Wärmepumpe" value if necessary and that the heat pump will start as soon as "PV Überschuss" > "Aktuelle Leistungsaufnahme Wärmepumpe" and will then follow the settings in the PV menu. I assume there is also some hysteresis involved and that the heat pump compares against an expected power value, if it is not currently running.
Not sure. The integration would currently show negative values as "unavailable". But you can just look at the debug logs, when your PV is running and producing power, but there is no surplus. If the raw value for But the difference between 0 and negative is probably just what shows up in the IDM UI. |
Thanks for the explanation. In the developer section it is working fine and looks for example like this:
But I am was not able to successfully add my sensor data to the value. Maybe it is a problem with the format of my data preparation?
The two values are prepared as float and rounded to two decimal places. It is working fine with the "modbus.write_register" script, but somehow I cannot use it in the "idm_heatpump.setpower" service.
Fehler beim Aufrufen des Diensts idm_heatpump.set_power. Unknown error Does someone have an idea what I am doing wrong?
As the uberschuss it the actual value fed into the grid measured by the smart meter, it will be for sure getting lower if the power is consumed by the heat pump. I think the IDM is regulating the actual usage by using both values (produktion and uberschuss), but not sure how exactly it works. I assume that it regulates the power usage of the IDM always close to a uberschuss of almost 0.
These values are above prepared in a way, that it will never be below 0.
I simply downloaded the branch (ZIP) and copy pasted (replaced) the files of the idm integration: \config\custom_components\idm_heatpump |
In the IDM GUI in settings - Photovoltaik - PV Leistung |
I assume "Hausverbrauch" is calculated by the heat pump as
@geryyyyyy can we please continue this discussion in #40. Otherwise it gets complicated with so many people discussing different things in one thread. See #40 (comment) |
I have temporary the script from simon running. I see value for PV Generation and PV Überschuss, but Hausverbrauch is always 0. |
The new release It would also be helpful, if you could post a list of other sensors which you'd like to set from Home Assistant. Some would be pretty easy to add. Others come with caveats in the Modbus docs from IDM, where I'd like to come up with some kind of safety mechanism first to avoid users (unknowingly) damaging their heat pump by using this integration. Please report the sensors in #50 to avoid spamming this issue too much. |
Hi,
before all, thanks for this integration.
I performed different tests and this integration (at least with my setup) represents the only way to correctly setup the
modbus communication with the IDM heatpump.
Here I suggest what I think is a useful integration
Is your feature request related to a problem? Please describe.
IDM heat pump offers the possibility to also write values using modbus. I found two sensors to be particularly interesting.
Setting this two values, you can inform the heat pump about how much energy you have from a photovoltaic system and how much of that energy is available as it does exceed your current consumption. As far as I understood, this way the heat pump can prepare hot water taking advantage of the energy that otherwise will be unused. Saving energy later as the water will be already hot.
Describe the solution you'd like
The perfect solution will be to select another sensor as input, and one of the two variables as output, repeating the process for both variables.
Two considerations:
sensor.my_inverter_pv_produktion or 0.0
Describe alternatives you've considered
I tried to setup everything manually following the really precious instructions on this repo Homeassistant-IDM-Integration, however I encounter some problems with the home assistant modbus implementation as every few reads it encounters an error, setting the values to unavailable until the next read.
I have investigated a little bit in the code as home assistant core uses the same pymodbus 3.1.3, but I did non find the cause of the problem.
I never tested write operations as I do not feel confident of the solution until I can get rid of the problem during reading.
Error:
[homeassistant.components.modbus.modbus] Pymodbus: idm_wp: Modbus Error: [Connection] ModbusTcpClient(192.168.61.6:502): Connection unexpectedly closed 0.0067907405853271484 seconds into read of 8 bytes without response from unit before it closed connection
The text was updated successfully, but these errors were encountered: