Closed viandox closed 1 year ago
Thank you for reporting this. Have you tried power cycling your DTU? Probably yes, just making sure. Could you please enable logging in your script? Add the following code at the beginning:
import logging
import pymodbus
pymodbus.pymodbus_apply_logging_config(logging.DEBUG)
Just a note... I do not yet have panels and inverters running. Still snow on the roof. So there is no value for today production, but I expect it should return 0 not error.
Unfortunately for this issue, I managed to get DTU returned and refunded. I replaced it with cheap OpenDTU. I won't be able to proceed requested network capture and logging. I do confirm the DTU has been power cycled. Anyway thanks for your work!
It seems that DTU sends invalid response. E.g., request sno returns data length properly 3, Unit ID 0, function 3. Then there is 0 bytes data coming, while 4 registers (8 bytes) has been requested. Does not matter, what command or adress I try result is always same - 0 bytes data.
@ttlappalainen Indeed there should be data included in the response but it is not. There is nothing wrong with the library, and the only thing I can do is to improve error handling (make the exception more informative).
What DTU version do you have (HW and SW)? Is this DTU Pro-S? This issue is different from the one observed by others when DTU doesn't respond at all.
If you have extended access (installator rights) to your DTU then you may try playing with modbus setting, refer to https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwi514L9mKr9AhWkmIsKHS8IAloQFnoECCcQAQ&url=https%3A%2F%2Fwww.shinetech-power.de%2Fwp-content%2Fuploads%2F2021%2F07%2FTechnical-Note-Modbus-implementation-using-3Gen-DTU-Pro-V1.2.pdf&usg=AOvVaw1epboI0-XprGZWnV9mKnMd
Please also try reading other registers, perhaps your panels are in later registers. Each panel/port takes 40 registers, so add 40 (0x28) offset: 0x1001 + 0x28 + 0x28 + 0x28 + ... The total number of possible ports is 99.
Thanks for response.
Definetely problem is not in script, sorry I did not point that on my last mail. If you improve script error code, it could be something like: "device responded empty data". In DTU respond it partially right. As I pointed only problem is that it responds 0 length data, while 8 shold have been returned. On the other hand I did not find good exception code from modbus definitions for this case - "request is right, but for now I do not want to give any data". Maybe execption code 4 "An unrecoverable error occurred while the slave was attempting to perform the requested action" would be nearest.
As I mentioned I have device on table just for developing code. No inverters installed yet. Not sure could DTU be so stupid and then prevent all data. I would expect serial number would be returned in any case. But I do get same response from any address.
Device id DTU-Pro-S, Software Ver.V00.02.15, Hardware Ver.H09.06.01. I do not installer rights. I'll try to contact importer. Also will try with modbas RTU.
@ttlappalainen are your inverters added to DTU? Sorry for stupid question but the last comment from you confused me. Inverters have to be added by instalator to the system. DTU must be connected with hoymiles cloud to download the configuration.
Not stupid question. DTU and inverters has been added to cloud. But inverters are not yet connected at all - no solar or grid. I just have DTU on table powered and connected to network.
But sorry my mistake - I used wrong adress. So reading works for DTU sno at address 2000 and port number at 2501. I tried accidentaly read inverter sno, which doe not exist yet.
So since this is specified to Holymiles, it could instead of causing exception inform that "data is not available" or "inverter not available". DTU returns 0 length response, when trying to read from address, where is no inverter.
Or e.g., it could return just 0 for data. Then it would be possible to read sum on inverters total power without causing exception.
OK, so I understand that your inverters are not mapped to beginning registers and that's why the library doesn't find them.
For simplicity, the current implementation assumes that all inverters are mapped to consecutive registers starting from 0x1001, gaps are not supported. I can change it to support the whole range of registers no matter which ones are really occupied.
Now script started to work. Just tested again and now DTU returns data for inverters and shows U,I and P as 0. Also serial numbers will be shown for inverters. The difference is that now when device has been on long time, it shows on the cloud online. Before it showed offline even it was on already several hours. So somehow mapping took long time. But still strange is that before it did not repond with 0 values for inverters/panels. Now it shows 16 panels and 17th return 0 values.
More Chinese logic...
Conclusion:
Fix:
I'm happy that you have got it working. It seems that you confirmed that the library also works with DTU Pro-S Yes, Modbus implementation has some quirks (not to mention stability issues).
Description
Hi, first of all thanks for this work.
Finaly decided to open this issue after struggling hours with the following issue I initialy encountered when trying to use hoymiles-mqtt side project, with my hoymiles DTU-PRO:
What I Did
Simply trying to run sample code from documentation:
DTU is connected throught Ethernet, is IP (ICMP) reachable and port 502 open. Same code explicitely ouptuts error when bad IPAddress is provided:
Error also here when running from hoymiles-mqtt docker or python 3.10 on raspbery.
Thanks a lor for you help with whats look cryptic modbus error. Regards