-
-
Notifications
You must be signed in to change notification settings - Fork 461
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 Modbus #1893
base: master
Are you sure you want to change the base?
Add Modbus #1893
Conversation
Very nice work! This would absolutely be something I could use. Do you think that, expanding on this commit, making the same modbus data also available through modbus RTU would be possible? OpenDTU Fusion already includes a Renesas ISL3178E TTL to RS485 transceiver, meaning the hardware is already prepared for this. It's just not used yet at the moment. EDIT: |
Thank you.
eModbus supports RTU also, so it should be possible. My Fusionv2 board is used to monitor my system, so I would be a little bit reluctant to use it for testing Modbus RTU. I will have a look into RTU. Maybe there is a way to keep memory footprint low in case one or both servers are not used.
Good suggestion, will work on that. |
I'm very glad that I was an inspiration :) And I'm even more glad that someone took proper care of a problem that I personally didn't have time to deal with. |
77d2f85
to
04ebf74
Compare
Hello, |
Edit:
Added app.js.gz to the pull request. Now you can build the firmware without building the webapp before. |
Added modbus server for minimal SunSpec meter. Only provides AC power and AC yield as if measuring the output of all registered inverters. Same approach as for the "Total Inverter" but now disguised as a meter. To be used e.g. as a "Fronius Smart Meter TCP" as orginally done in https://github.com/AloisKlingler/OpenDTU-FroniusSM-MB. |
Hello,
And now the strangest thing when it comes to reading from a real DTU. Generally, real DTU has 8-bit registers, not 16-bit registers like real Modbus... The question is whether it would be worth adding a selection option. Especially if openDTU was to be compatible with various DTU libraries. |
Thx for testing and advise.
Changed now - just takes the values provided by OpenDTU. Does not check for not reachable anymore.
Added an alarm code in case the inverter is unreachable. Can you advise on the link status? I though it is the DTU communication status (not the inverter communication status).
Changed - Now 0 is provided for all inverter data list registers that are supported by the DTU if they are unused.
Changed - adapted to your original code. It is very strange that the start address for the data (0x1000)/ SN (0x2000) list in the documentation seems to be a "normal" Modbus address, but the following fields are per byte. I tested with your https://github.com/ArekKubacki/Hoymiles-Plant-DTU-Pro app for HomeAssistant. At least the application starts. This was tested without inverters. By the way during testing I triggered several Python exceptions due to configuration problems. Especially if the number of panels is > 0 and there are no inverters, the app won't start. Fault indication can only be found in the system log and it is somehow misleading as it is an index out of bounds fault. I don't own a Hoymiles DTU, so your help is very much appreciated. |
Hi, [HMSeriesMicroinverterData(data_type=0, serial_number='00000000003c', port_number=17, pv_voltage=Decimal('2494.7'), pv_current=Decimal('165.3'), grid_voltage=Decimal('409.7'), grid_frequency=Decimal('3.96'), pv_power=Decimal('20.1'), today_production=2325, total_production=327551956, temperature=Decimal('0'), operating_status=1384, alarm_code=58, alarm_count=12431, link_status=0, reserved=[107, 0, 3, 0, 0, 0, 0]), |
Hello @ArekKubacki , I did some more tests using synthetic test data (fixed values for 1 inverter with 6 channels) for the DTUPro data. The test data can be activated in platformio_override.ini by -DOPENDTU_SIM_DTUPRO:
I used this HomeAssistant configuration.yaml
As a result HomeAssistant shows the following. Test data seems to be correctly displayed. I this the expected output? |
Unfortunately not yet. today_production, total_production, pv_power, pv_current, pv_voltage should be for each port (string, panel), not for the entire inverter. port_number should change depending on the number of ports on the inverter. In my case 1-4. It is currently growing to 24, which is the maximum panels I have. |
Thank youu for testing. Will look into this. I hopefully can now understand your original code. |
OpenDTU is extended by a Modbus server. The Modbus server serves TCP at port 502. At Modbus ID 1 the server mimicks the Modbus registers in the original DTUPro. At Modbus ID 125 the server serves a SunSpec compatible pseudo inverter that provides the OpenDTU aggregated data from all registered inverters. At Modbus ID 243 the server serves a Sunspec meter that provides aggregated AC power and AC yield values of all registered inverters. The OpenDTU Modbus sources were imspired by : https://github.com/ArekKubacki/OpenDTU. See tbnobody#582 for the orignal pull request. The Modbus library used for Modbus communication is: https://github.com/eModbus/eModbus. Documentation for the library is here: https://emodbus.github.io/. The library was choosen to achieve a lower memory footprint. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Add Modbus TCP configuration and info views. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Hello @ArekKubacki
Now switched to values per string.
Reported port numbers adapted to per inverter. Would be nice if you could test this version. I tried to make a one to one copy of your code. What is still open to me is the first byte (data type) at 0x1000. According to the specification it shall be 0x3C, you are using 0x0C. Do you know more? What does the DTUPro use here? Thanks again for testing. |
Looks very good. As far as register 1 is concerned, it does not matter. According to the specifications, it is 3C in the original DTU, at least in my case it is 0C. It is not used for anything so I think you can leave it as per specifications. Have you thought about making 2 choices? How is "DTU Clone" and how it should be according to the specification with normal 16-bit registers? This will give users more space to use. |
OpenDTU is extended by a Modbus server.
The Modbus server serves TCP at port 502.
provides the OpenDTU aggregated data from all registered inverters.
The webapp is extended by Modbus configuration and info views.
Modbus can be enabled/ disabled. Only a minimal subset of DTUPro/ OpenDTU aggregated data
is currently supported.
Main intention was to have an easy feed to my HomeAssistant installation that already monitors
and controls my other inverters by Modbus.
The OpenDTU Modbus sources were inspired by : https://github.com/ArekKubacki/OpenDTU.
See #582 for the orignal pull request.
The Modbus library used for Modbus communication is: https://github.com/eModbus/eModbus.
Documentation for the library is here: https://emodbus.github.io/.
The library was choosen over full featured libraries to achieve a lower memory footprint.
Memory footprint: