-
Notifications
You must be signed in to change notification settings - Fork 2
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 support for local Modbus TCP #113
Comments
Jealous, mine is locked with password and cert auth. I will check this out as we discussed to try and make this easier I think map the numbers to the I_1 etc so I can map directly into and from the online mappings, then hopfully only need to replace the API part with a modbusAPI. Do you think maybe login using the Web to get the setup then in options allow local connection and (hoping I find another way) have an option on type of connection for each device, once enabled it will switch the data updates to local for that specific device. This probably doesn't matter for most people but just thinking if you have multiple devices to monitor (large houses), still that is a bit off have to get a connection which is going to be interesting as I can't test. I think I will need you to share me sample data for Unit testing, once I work out how. |
This actually does work on mine to but in my case A_2 is 4002 and A_5 is 4006 |
Oh really? You also have access to modbus TCP then? |
seems like it I pointed that app at it and it started updating, so need to work out if there really is a difference in where yours starts and where mine starts |
I changed the requested temp to 48.8 and it changed 4006 to 488, now the hot water is requesting 46.0 and its 460 |
40038 and 40039 are A_37 and A_38 on mine |
Weird seems not to be mapped to the same as yours: D_1 start at 1002 (02 - Input status) |
Well this is great news! This opens up local access to (nearly) everyone. We just need to allow for these different mapping types. Mine would be 'Carel pGDX' and yours would be whatever Gateway or Mastertherm you have. We'll have it selectable. |
yeh just knocked my pump offline :), but can still talk to it with pymodbus. |
Coils are 1-bit registers, read/write |
Can you share a pic of your holding registers? |
Okay well this is great. Looks like there is a shift. We'll need at least two mappings then. But this means we can make the integration fully local (local polling) instead of cloud-dependent! Will make testing a lot easier for you with your own heatpump! |
So have written a small piece of code that reads the coils and registers (in my case) and converts to A and D Registers. Takes about 1.2s. Can't work out the I Registers where they are have looked through the registers to 9000, grrrr |
Perfect thank you: Not sure about the end range need to check the register manual its about 524 for each range. Can you check the Coil values see if they fit the D Registers? you say that your D registers start at 40503 however there are about 524 A registers so that should not fit as they start at 40003. |
ok so first pass with rough code, locally takes 1.9s to retrieve the registers. using online full run takes 1.356 seconds. but will see as my code is grabbing the registers 100 at a time (modbus limitation) and then converting one at a time into registers in a dict so A_1 = etc. So not so quick, still even if takes 2 seconds it can be pinged every 5 seconds no issues. |
Do I understand correctly, that you are connecting to Modbus TCP on the pGDX? |
That's correct, I'm connecting to the pGdx, but @sHedC is connecting to his heatpump. Try using the program I suggested above? Does it work for you to read registers? |
the controller in my heat pump reports as a pco5 which is the carel pco5 controller it supports modbus. I tried to connect to it but nothing then used the app that SebsZ suggested and it gave me registers. What controller do you have reported and in the HP itself? The Carel PC1 to PC5 plus a few others support modbus with the RJ45 adatper. |
Oh, you're right. It works for me as well! So what's next? How can I help? Is there some alpha version to try and report the results? |
Sorry for the late reply been ill and work is about all I have been doing, plus have another project which might actually earn me money. As for this working on but have to refactor quite a lot to support cloud and local. My idea is this:
The idea is to make this as easy as possible to configure. So I thinkf or now I need some analysis
Most mappings should be as follows D Registers are in the read_coil from value 1 to 500 (I think) But more recent HP's have custom firmware and may be mapping else where for example SeBsZ is a upc all his map to the Holding Registers, see top of the thread. |
No worries, take your time. Health and source of money for our families are more important than these toys of ours ;-) Interesting fields to identify my HP:
Or do you need whole diag output? Seems my mapping looks like this: BTW: I have noticed this in the diag:
The integration only exposes
|
D should be in the Coils (input is read only) Rest should look liike mine, its a bit confusing as I think it is actually A_1 is 1 and I_1 is 5002 as the index actually starts at 0, but will check most important is you are usng the standard firmware and pco5 is same as mine for the controller. |
Yep, you're right. The D values are visible in '01 - Coil status' as well as in '02 - Input status'. |
Hi. Is there any progress with this? |
Not recently, I am overly busy with work and a fair amount of travel at the moment. I did start there is a branch for modbus local access but been 6 months since I could last look. I do want to do it though as I loose connectivity too |
So I discovered that in my MasterTherm installation I have access to instant local data via the Modbus TCP protocol. This is open and does not require and authentication or additional hardware.
Hardware Requirements
I have a MasterTherm geo heatpump installed in 2022 which came with a touchscreen display in the living area:
The screen used is by CAREL called pGDX (https://www.carel.com/pgdx). The screen connects to my WiFi and I can connect to its Modbus via TCP port 502.
Testing
To test if it works, download the free Open ModScan on Windows (https://github.com/sanny32/OpenModScan/releases) and go to Connection -> Connect. Choose 'Remote TCP/IP Server' and enter your Touchscreen's IP Address. Leave the port at 502 and click OK. Now leave the address and device id at 1. Choose 03: HOLDING REGISTER under 'MODBUS Point Type'. Make sure your data display option is set to integer:
It's working if you see data listed in the registers:
Home Assistant
To add this to Home Assistant, I suggest adding support for Modbus TCP to Masterthermconnect.
The MasterTherm integration would need to have its settings UI changed. All that's needed is the option to choose between 'MasterTherm Cloud' and 'Modbus TCP'. Then for Modbus users only need to enter an IP address.
Modbus has different types of registers you can read and sometimes write to:
0x = Coil = 00001-09999
1x = Discrete Input = 10001-19999
3x = Input Register = 30001-39999
4x = Holding Register = 40001-49999
We are only interested in the holding registers with address range 40001-49999. All the other registers are not used for this application.
Addresses
Since the first two address locations 40001 and 40002 are used for something else, everything is shifted by 2 when compared to our current implementation. Also, all the data types are one after the other.
Everything is stored as a signed integer.
All the above need to be divided by 10. For example a temperature of 17.1 is stored as 171.
I think the easiest is to use PyModbus. See Solaredge Modbus for an example implementation.
The text was updated successfully, but these errors were encountered: