New Python plugin: Domoticz SolarEdge_ModbusTCP

Moderator: leecollings

User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

Updated to 2.0.6.
Restructured repository seems to work.
Stop, look and listen.
User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

EDIT: Seems that my .backup_zip directory must not stay in the plugins folder. Sorry. Will move it. Seems that a non coding guy like me is more disruptive than helpful 😔

SE errors at 21:36 with new version. Just at that point of time. No errors before and after.

Log data beyond errors at that point of time not available in log of web UI retroactive.

Would love to provide more data but I need to know how I can get it without sitting in front the computer at the exact time.

Code: Select all

2026-09-20 21:36:42.275  Error: SE_Modbus_Neu: Call to function 'onHeartbeat' failed, exception details:
2026-09-20 21:36:42.293  Error: SE_Modbus_Neu: Traceback (most recent call last):
2026-09-20 21:36:42.293  Error: SE_Modbus_Neu:   File "/home/pi/domoticz/plugins/solaredge_modbus_tcp_v2.backup_zip/plugin.py", line 709, in onHeartbeat
2026-09-20 21:36:42.293  Error: SE_Modbus_Neu:     _plugin.onHeartbeat()
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu:     ~~~~~~~~~~~~~~~~~~~^^
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu:   File "/home/pi/domoticz/plugins/solaredge_modbus_tcp_v2.backup_zip/plugin.py", line 251, in onHeartbeat
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu:     meter = self.inverter.meters()[device_name]
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu:             ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu: KeyError: 'Meter1'
Stop, look and listen.
AddieJanssen
Posts: 35
Joined: Sunday 27 September 2020 16:17
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by AddieJanssen »

imautohuttraeger wrote: Sunday 20 September 2026 22:55 EDIT: Seems that my .backup_zip directory must not stay in the plugins folder. Sorry. Will move it. Seems that a non coding guy like me is more disruptive than helpful 😔

SE errors at 21:36 with new version. Just at that point of time. No errors before and after.

Log data beyond errors at that point of time not available in log of web UI retroactive.

Would love to provide more data but I need to know how I can get it without sitting in front the computer at the exact time.

Code: Select all

2026-09-20 21:36:42.275  Error: SE_Modbus_Neu: Call to function 'onHeartbeat' failed, exception details:
2026-09-20 21:36:42.293  Error: SE_Modbus_Neu: Traceback (most recent call last):
2026-09-20 21:36:42.293  Error: SE_Modbus_Neu:   File "/home/pi/domoticz/plugins/solaredge_modbus_tcp_v2.backup_zip/plugin.py", line 709, in onHeartbeat
2026-09-20 21:36:42.293  Error: SE_Modbus_Neu:     _plugin.onHeartbeat()
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu:     ~~~~~~~~~~~~~~~~~~~^^
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu:   File "/home/pi/domoticz/plugins/solaredge_modbus_tcp_v2.backup_zip/plugin.py", line 251, in onHeartbeat
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu:     meter = self.inverter.meters()[device_name]
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu:             ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
2026-09-20 21:36:42.294  Error: SE_Modbus_Neu: KeyError: 'Meter1'
These errors can't come from v2.0.6. The line numbers mentioned don't match.

You can reduce the log level in the hardware settings of the plugin to "Verbose".
That will reduce the amount of log info, but does include the json output of the inverter.
User avatar
JayDotR
Posts: 26
Joined: Thursday 02 January 2025 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Lux
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by JayDotR »

Hi Addie,

Seems that the move to "src/" is not seen so transparently

Code: Select all

2026-09-21 09:03:49.347  Status: SolarEdge ModBus Roof: Started.
2026-09-21 09:03:49.347  Status: SolarEdge ModBus Roof: Entering work loop.
2026-09-21 09:03:49.348  Status: SolarEdge ModBus Batt: Started.
2026-09-21 09:03:49.348  Status: SolarEdge ModBus Batt: Entering work loop.
2026-09-21 09:03:50.116  Error: SolarEdge ModBus Batt: (SolarEdge_ModbusTCP) failed to load 'plugin.py'.
2026-09-21 09:03:50.193  Error: SolarEdge ModBus Roof: (SolarEdge_ModbusTCP) failed to load 'plugin.py'.
2026-09-21 09:03:50.479  Error: SolarEdge ModBus Batt: Exception: 'ModuleNotFoundError: No module named 'plugin''.  No traceback available.
2026-09-21 09:03:50.556  Error: SolarEdge ModBus Roof: Exception: 'ModuleNotFoundError: No module named 'plugin''.  No traceback available.
I doubt that the plugin.py must remain in the root folder, and eventually the imports could undergo a path modif (I will test) and keep you informed
--
Domoticz Beta on raspberry3b, and raspberry4(b) on Rasbian Trixie / Python 3.13 / 64 bit
Using: PiHole, SolarEdge Modbus, Sainlogic / Weather Underground, MQTT, Fritzbox, P1 Meter(s), dzvents Scripting
https://www.github.com/janreimen/
User avatar
JayDotR
Posts: 26
Joined: Thursday 02 January 2025 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Lux
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by JayDotR »

Your structure:

Code: Select all

Domoticz-SolarEdge-ModbusTCP/
├── plugin.py
└── src/
    ├── inverters.py
    └── ...
At the top of plugin.py, before importing inverters:

Code: Select all

import sys
from pathlib import Path

# Add src/ directory to Python module search path
SRC_DIR = Path(__file__).resolve().parent / "src"

if str(SRC_DIR) not in sys.path:
    sys.path.insert(0, str(SRC_DIR))

import inverters
--
Domoticz Beta on raspberry3b, and raspberry4(b) on Rasbian Trixie / Python 3.13 / 64 bit
Using: PiHole, SolarEdge Modbus, Sainlogic / Weather Underground, MQTT, Fritzbox, P1 Meter(s), dzvents Scripting
https://www.github.com/janreimen/
User avatar
JayDotR
Posts: 26
Joined: Thursday 02 January 2025 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Lux
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by JayDotR »

And solved the Issue I ran into later on (fatal error on a fetch)

Code: Select all


pi@pihole:/srv/domoticz/plugins/Domoticz-SolarEdge.2.0.6 $ diff plugin.new.py plugin.2.0.6.py

67,74d66
< import sys
< from pathlib import Path
<
< # Add src/ directory to Python module search path.
< SRC_DIR = Path(__file__).resolve().parent / "src"
< if str(SRC_DIR) not in sys.path:
<     sys.path.insert(0, str(SRC_DIR))
<
370c362
<                         last_update: datetime = datetime.strptime(Devices[unit[Column.ID] + offset].LastUpdate, "%Y-%m-%d %H:%M:%S")
---
>                         last_update: datetime = datetime.strptime(Devices[unit[Column.ID]].LastUpdate, "%Y-%m-%d %H:%M:%S")
Runs now at a glance beside 2.0.5 on the same host
--
Domoticz Beta on raspberry3b, and raspberry4(b) on Rasbian Trixie / Python 3.13 / 64 bit
Using: PiHole, SolarEdge Modbus, Sainlogic / Weather Underground, MQTT, Fritzbox, P1 Meter(s), dzvents Scripting
https://www.github.com/janreimen/
AddieJanssen
Posts: 35
Joined: Sunday 27 September 2020 16:17
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by AddieJanssen »

JayDotR wrote: Monday 21 September 2026 9:12 Hi Addie,

Seems that the move to "src/" is not seen so transparently

Code: Select all

2026-09-21 09:03:49.347  Status: SolarEdge ModBus Roof: Started.
2026-09-21 09:03:49.347  Status: SolarEdge ModBus Roof: Entering work loop.
2026-09-21 09:03:49.348  Status: SolarEdge ModBus Batt: Started.
2026-09-21 09:03:49.348  Status: SolarEdge ModBus Batt: Entering work loop.
2026-09-21 09:03:50.116  Error: SolarEdge ModBus Batt: (SolarEdge_ModbusTCP) failed to load 'plugin.py'.
2026-09-21 09:03:50.193  Error: SolarEdge ModBus Roof: (SolarEdge_ModbusTCP) failed to load 'plugin.py'.
2026-09-21 09:03:50.479  Error: SolarEdge ModBus Batt: Exception: 'ModuleNotFoundError: No module named 'plugin''.  No traceback available.
2026-09-21 09:03:50.556  Error: SolarEdge ModBus Roof: Exception: 'ModuleNotFoundError: No module named 'plugin''.  No traceback available.
I doubt that the plugin.py must remain in the root folder, and eventually the imports could undergo a path modif (I will test) and keep you informed
That's why there's a release zip file 8-) which puts all the required files nicely together in the root.
Don't clone the repo, but instead download the zip file and extract all files.
User avatar
JayDotR
Posts: 26
Joined: Thursday 02 January 2025 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Lux
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by JayDotR »

Hi Addie,

Indeed, makes sense with the zip. By convenience i made the classic git pull.

Nevertheless, I encountered an error when reading data, which is also part in the diff I posted the morning. I can check if I encounter it when using the zip as source. I sent you the diff to apply & error log by PM

Jan
--
Domoticz Beta on raspberry3b, and raspberry4(b) on Rasbian Trixie / Python 3.13 / 64 bit
Using: PiHole, SolarEdge Modbus, Sainlogic / Weather Underground, MQTT, Fritzbox, P1 Meter(s), dzvents Scripting
https://www.github.com/janreimen/
User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

AddieJanssen wrote: Monday 21 September 2026 9:05 These errors can't come from v2.0.6. The line numbers mentioned don't match.
That's right. That's why I added this EDIT note:
imautohuttraeger wrote: Sunday 20 September 2026 22:55 EDIT: Seems that my .backup_zip directory must not stay in the plugins folder. Sorry. Will move it. Seems that a non coding guy like me is more disruptive than helpful 😔
I have moved this backup folder outside the plugins folder now
Stop, look and listen.
AddieJanssen
Posts: 35
Joined: Sunday 27 September 2020 16:17
Target OS: -
Domoticz version:
Contact:

Pre-release version v2.0.7 published

Post by AddieJanssen »

A new day - a new release.

Thanks JayDotR for finding a bug and providing the fix as well :D

I have just published v2.0.7 on GitHub that should fix the bug.
User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

Wow, that was fast. In your Wiki
https://github.com/addiejanssen/domotic ... lugin/wiki
the following is written:
Updating the plugin can be done by removing the previous version and do a clean install again. Make sure to stop the Domoticz service before you start or at least stop all hardware that is related to the plugin.

Make sure that the requirements listed in the requirements.txt file are met. If newer versions of the solaredge_modbus library are required, make sure that you remove the older versions to prevent version conflicts.
Question: Will I loose all devices in Domoticz by a new clean install or will they be kept? I am asking, because I use several devices idx in scripts.
Stop, look and listen.
AddieJanssen
Posts: 35
Joined: Sunday 27 September 2020 16:17
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by AddieJanssen »

imautohuttraeger wrote: Monday 21 September 2026 22:20 Wow, that was fast. In your Wiki
https://github.com/addiejanssen/domotic ... lugin/wiki
the following is written:
Updating the plugin can be done by removing the previous version and do a clean install again. Make sure to stop the Domoticz service before you start or at least stop all hardware that is related to the plugin.

Make sure that the requirements listed in the requirements.txt file are met. If newer versions of the solaredge_modbus library are required, make sure that you remove the older versions to prevent version conflicts.
Question: Will I loose all devices in Domoticz by a new clean install or will they be kept? I am asking, because I use several devices idx in scripts.
Replacing the folder/files of the plugin will have no impact on existing devices or settings.
Just make sure that you don't make changes to the hardware in Domoticz.
User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

.......Thx! .....
Stop, look and listen.
AddieJanssen
Posts: 35
Joined: Sunday 27 September 2020 16:17
Target OS: -
Domoticz version:
Contact:

SolarEdge SunSpec Scanner

Post by AddieJanssen »

I need your help...

I have started work on the "detection of meters and batteries may not (correctly) work for all inverters" topic.

SolarEdge inverters implement the SunSpec protocol which provides an option to scan for devices connected to the inverter.

I have created a scanner that will contact the inverter to scan for devices attached to it.

I am looking for you to run the scanner and share the output here in this forum.
Based on that, I get an understanding of the different types of inverters in use and if scanning for devices works or not.
I would appreciate that you run the scanner even when there are no batteries or meters attached to your inverter.

You can find the scanner and instructions how to use it on GitHub: https://github.com/addiejanssen/solared ... ec-scanner

WARNING: the scanner requires a newer version of pymodbus which is incompatible with the Domoticz SolarEdge_ModbusTCP!
So, keep things separated by using different computers, containers or virtual environments!

Here's the output when I ran the scanner (python scanner.py inverter 502) for my inverter:

Code: Select all

Connecting to server
 Connected to server

  The inverter is providing a SunSpec Map

   Reading Block at address [40002] for device [1]
    Block id = 1: Common
     Manufacturer:   [SolarEdge ]
     Model:          [SE7K]
     Options:        []
     Version:        [0003.2537]
     Device Address: [1]

   Reading Block at address [40069] for device [1]
    Block id = 103: Inverter (Three Phase)

   Reading Block at address [40121] for device [1]
    Block id = -1: The End of the block list has been reached

Closed connection to serve
User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

Will try to run it on my Pi with a copy of the SD card for security reasons tomorrow.

However, in case we need to use pymodbus 3.15.0 more often for testing, I am thinking of this procedure:

1.
pip3 install pymodbus==3.15.0

2.
Do the scan, copy the output and post it on the forum

3.
Go back to old pymodbus, so that the current plugin works again:
pip3 install pymodbus==3.6.9

Would that work? If yes: Must I install the dependencies again?
Stop, look and listen.
AddieJanssen
Posts: 35
Joined: Sunday 27 September 2020 16:17
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by AddieJanssen »

There's an easier way of doing things...
Create another user on your pi and run the scanner while logged in as that user.
User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

Thank you very much for the tip to simply use annother user. When I asked Claude AI to guide me through the process of making a new user, "he" even suggested an even more simpler way for the purpose of running your scanner without conflicts to the running Domoticz: Create a separate VENV and execute the scanner there. I did this, it was fast and easy. So here is the result of my System:

Code: Select all

Connecting to server
 Connected to server

  The inverter is providing a SunSpec Map

   Reading Block at address [40002] for device [1]
    Block id = 1: Common
     Manufacturer:   [SolarEdge ]
     Model:          [SE10K-RWB48BFN4]
     Options:        []
     Version:        [0004.0025.0011]
     Device Address: [1]

   Reading Block at address [40069] for device [1]
    Block id = 103: Inverter (Three Phase)

   Reading Block at address [40121] for device [1]
    Block id = 1: Common
     Manufacturer:   [SolarEdge]
     Model:          [MTR-240-3PC1-D-A-MW]
     Options:        [Export+Import]
     Version:        [1.0.62]
     Device Address: [2]

   Reading Block at address [40188] for device [1]
    Block id = 203: wye-connect three phase (abcn) meter

   Reading Block at address [40295] for device [1]
    Block id = 701: Unknown block

Closed connection to server
Components of my system:

o Inverter:
SolarEdge SE10K-RWB48BFN4

o Battery:
Stack with 3 x SolarEdge Home Battery with 3 X 4,85 = 14,55 kWh, Low Volt technique with 44,8 Volt

o Backup Interface

o 32 optimizers type S500
Stop, look and listen.
User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

Not sure if I interpret the output correctly, but I don't see a battery. However, a battery is definitely attached and there are several devices created by the plugin that show correct and updated information.
Stop, look and listen.
AddieJanssen
Posts: 35
Joined: Sunday 27 September 2020 16:17
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by AddieJanssen »

Thanks for running the scanner. This is exactly why I need feedback from the community.
There's a bug in the scanner that I will fix tonight.

Code: Select all

256        case _:
257            print(f"    Block id = {block_id}: Unknown block")
258            next_address = -1
Line 258 should not be there.
That line stops further scanning and therefore has not found all devices attached to your inverter.

If you want, you can "fix" the bug by removing that line or put a # at the start of the line and run the scanner again.
User avatar
imautohuttraeger
Posts: 390
Joined: Saturday 14 March 2020 13:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Germany
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by imautohuttraeger »

I have put the # at the start of line 258 and this is the new output:

Code: Select all


Connecting to server
 Connected to server

  The inverter is providing a SunSpec Map

   Reading Block at address [40002] for device [1]
    Block id = 1: Common
     Manufacturer:   [SolarEdge ]
     Model:          [SE10K-RWB48BFN4]
     Options:        []
     Version:        [0004.0025.0011]
     Device Address: [1]

   Reading Block at address [40069] for device [1]
    Block id = 103: Inverter (Three Phase)

   Reading Block at address [40121] for device [1]
    Block id = 1: Common
     Manufacturer:   [SolarEdge]
     Model:          [MTR-240-3PC1-D-A-MW]
     Options:        [Export+Import]
     Version:        [1.0.62]
     Device Address: [2]

   Reading Block at address [40188] for device [1]
    Block id = 203: wye-connect three phase (abcn) meter

   Reading Block at address [40295] for device [1]
    Block id = 701: Unknown block

   Reading Block at address [40450] for device [1]
    Block id = 702: Unknown block

   Reading Block at address [40502] for device [1]
    Block id = 703: Unknown block

   Reading Block at address [40521] for device [1]
    Block id = 704: Unknown block

   Reading Block at address [40588] for device [1]
    Block id = 705: Unknown block

   Reading Block at address [40647] for device [1]
    Block id = 706: Unknown block

   Reading Block at address [40696] for device [1]
    Block id = 707: Unknown block

   Reading Block at address [40803] for device [1]
    Block id = 708: Unknown block

   Reading Block at address [40910] for device [1]
    Block id = 709: Unknown block

   Reading Block at address [41047] for device [1]
    Block id = 710: Unknown block

   Reading Block at address [41184] for device [1]
    Block id = 711: Unknown block

   Reading Block at address [41218] for device [1]
    Block id = 712: Unknown block

   Reading Block at address [41264] for device [1]
    Block id = 713: Unknown block

   Reading Block at address [41273] for device [1]
    Block id = -1: The End of the block list has been reached

Closed connection to server


Stop, look and listen.
Post Reply