New Python plugin: Domoticz SolarEdge_ModbusTCP

Moderator: leecollings

JakeOfOz
Posts: 9
Joined: Wednesday 31 March 2021 10:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by JakeOfOz »

Apologies in advance: but for the basics: do you have the modus tcp enabled in your inverter?

Also: is there no other device that uses it? I noticed that when I have two instances of domoticz running, only one can read the solaredge.

Another tip I got, but could not verify, is that you have to make some sort of request to the inverter within 5 minutes of enabling the modus. But like I said: not sure if that is true.
Zenek1961
Posts: 7
Joined: Monday 05 April 2021 16:46
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Zenek1961 »

Ip inverter based on the mac address from the router, I removed the plug many times, restarted Domoticz and does not detect devices

I have the modus tcp enabled in my inverter
how to send request to inverter?
Last edited by Zenek1961 on Monday 05 April 2021 19:05, edited 2 times in total.
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

JakeOfOz wrote: Monday 05 April 2021 18:53 *snip*
Another tip I got, but could not verify, is that you have to make some sort of request to the inverter within 5 minutes of enabling the modus. But like I said: not sure if that is true.
I can only verify that it does not matter. I initially enabled the plugin hours after activation of the modus and subsequently had no issues when I had to downgrade the library (after having the plugin disabled for almost two weeks).
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

Zenek1961 wrote: Monday 05 April 2021 18:58 Ip inverter based on the mac address from the router, I removed the plug many times, restarted Domoticz and does not detect devices

I have the modus tcp enabled in your inverter
I am not entirely sure what you mean with "IP inverter based on the mac address from the router" Sorry for my bad English :oops: The inverter needs to have a static IP. It will get that from your router. I am sure you have that covered ;)

Is your inverter connected to your home network via WiFi or wired? Has there been any configuration changed in your WiFi network recently? Is it possible to connect the inverter by cable?
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
Zenek1961
Posts: 7
Joined: Monday 05 April 2021 16:46
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Zenek1961 »

my inverter connected via WIFI, I cannt to connect by cable
Zenek1961
Posts: 7
Joined: Monday 05 April 2021 16:46
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Zenek1961 »

problem fixed, wrong IP address was set
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

Just upgraded to Bullseye and all my plugins are working but one. I am getting a strange error when starting or restarting Domoticz:
2022-10-07 13:38:18.777 Error: SolarEdge: (SolarEdge_ModbusTCP) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/domoticz-solaredge-modbustcp-plugin/:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/usr/local/lib/python3.9/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.9/dist-packages'.
2022-10-07 13:38:18.785 Error: SolarEdge: Traceback (most recent call last):
2022-10-07 13:38:18.785 Error: SolarEdge: File "/home/pi/domoticz/plugins/domoticz-solaredge-modbustcp-plugin/plugin.py", line 54, in <module>
2022-10-07 13:38:18.785 Error: SolarEdge: import solaredge_modbus
2022-10-07 13:38:18.785 Error: SolarEdge: ModuleNotFoundError: No module named 'solaredge_modbus'
I tried to update the repo but all was up to date. I renamed the directory on my Pi and cloned the repo again. Unfortunately with the same results.

Any help greatly appreciated!

EDIT: Got it working! I re-read this thread and found this post: viewtopic.php?p=272142#p272142 which indicates that the current version of the modbus implementation is not working with the plugin. Downgraded as per instructions and now I have got a working plugin again :mrgreen:

EDIT2: Bummer! I forgot I had disabled the device in Domoticz. After re-enabling it i get the following error:
2022-10-07 14:21:49.103 Error: SolarEdge: Call to function 'onHeartbeat' failed, exception details:
2022-10-07 14:21:49.103 Error: SolarEdge: Traceback (most recent call last):
2022-10-07 14:21:49.103 Error: SolarEdge: File "/home/pi/domoticz/plugins/domoticz-solaredge-modbustcp-plugin/plugin.py", line 544, in onHeartbeat
2022-10-07 14:21:49.103 Error: SolarEdge: _plugin.onHeartbeat()
2022-10-07 14:21:49.104 Error: SolarEdge: File "/home/pi/domoticz/plugins/domoticz-solaredge-modbustcp-plugin/plugin.py", line 423, in onHeartbeat
2022-10-07 14:21:49.104 Error: SolarEdge: self.contactInverter()
2022-10-07 14:21:49.104 Error: SolarEdge: File "/home/pi/domoticz/plugins/domoticz-solaredge-modbustcp-plugin/plugin.py", line 440, in contactInverter
2022-10-07 14:21:49.104 Error: SolarEdge: inverter_values = self.inverter.read_all()
2022-10-07 14:21:49.104 Error: SolarEdge: AttributeError: 'NoneType' object has no attribute 'read_all'
Anybody any clue?
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
eddieb
Posts: 279
Joined: Wednesday 04 July 2018 7:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by eddieb »

in the github readme there is a line on upgrading a python library with pip.
If you do that manually all might work ;-)
RPI4 Beta / Tasmota / ZigBee2MQTT / P1meter / Haier AC with Node-Red and MQTT / SolarEdge SE3500H modbus_tcp / Opentherm gateway / Plugwise Anna/Smile / ObserverIP weatherstation thru WuDirect
Feeding ADSB https://adsb.im/home
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

It wasn't caused by a library as it seems. After (re)reading the github page I found that the modbus address needs to be on 1. Wonder why...

All is working now. Tx!
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

I migrated from the Pi to another application server. I installed Domoticz in a container and created a location for my plugins on the host. That all works. But I am having a problem getting solaredge_modbus to load. I did the

Code: Select all

sudo pip3 install -r requirements.txt
on the host and the solaredge_modbus Python library got installed. Unfortunately Domoticz does not see it. Any idea how to get the module loaded in Domoticz? This is the error I get:

Code: Select all

2022-11-20 18:08:40.450 Error: SolarEdge: (SolarEdge_ModbusTCP) failed to load 'plugin.py', Python Path used was '/opt/domoticz/userdata/plugins/SolarEdge/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2022-11-20 18:08:40.600 Error: SolarEdge: Traceback (most recent call last):
2022-11-20 18:08:40.600 Error: SolarEdge: File "/opt/domoticz/userdata/plugins/SolarEdge/plugin.py", line 54, in <module>
2022-11-20 18:08:40.600 Error: SolarEdge: import solaredge_modbus
2022-11-20 18:08:40.600 Error: SolarEdge: ModuleNotFoundError: No module named 'solaredge_modbus' 
Help appreciated as always!

EDIT: Just reran the error again and I see it is looking for Python 3.7 where Python 3.9 is installed. Python 3.7 is not (no longer?) in the repositories of Ubunut 22.04 so how to proceed? Where can I have the plugin look at Python 3.9?
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by waltervl »

You installed Domoticz in a container so that Python module also should be available in that container. The Domoticz Docker container is running python 3.7 I believe (not a Docker fan myself)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

Thanks for your reply! The million dollar question is: how do I get the solaredge_modbus loaded? Surely I am not the only one using Domoticz in Docker with a few plug-ins to match. I can't update the container and I can't downgrade Python from 3.9 to 3.7 on the host AFAIK. So I am a bit in a pickle I believe ...
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by waltervl »

You can install the python module in the container. So you have to run a bash session into the docker image with something like

Code: Select all

docker exec –it domoticz /bin/bash
And then in that session install the python modules with pip3.
With a custom startup script (see https://www.domoticz.com/wiki/Docker#cu ... _container) you can automate this else you have to install this module every time when you update domoticz.

Or

Delete docker, install domoticz as usual with

Code: Select all

sudo bash -c "$(curl -sSfL https://install.domoticz.com)"
copy the old domoticz.db to the new installation and you are a happy camper ;-)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

Thanks for your support! I will have a go at installing the module in the container and try to figure out how to add that with a startup script.

I know you're not a fan of containers but I must say that I am rather impressed with the ease of use and management in general. Just have to iron out a few quirks like this Python module ;)
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

Well... I had a go but was not succesful. I am afraid I haven't got enough Python knowledge to fix this. Will have to investigate further but decided to post my preliminary results in case someboday has experienced the same problems and found a solution (you never know ;))

This is the result of my installation attempts inside the docker container:

Code: Select all

root@ba0fc83c619f:/opt/domoticz/userdata/plugins/SolarEdge# ls
LICENSE  __pycache__  plugin.py  requirements.txt
root@ba0fc83c619f:/opt/domoticz/userdata/plugins/SolarEdge# pip3 install -r requirements.txt
Collecting solaredge_modbus==0.7.0 (from -r requirements.txt (line 1))
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fba4a5a8d30>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/solaredge-modbus/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fba4a5a8cc0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/solaredge-modbus/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fba4a5a8e48>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/solaredge-modbus/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fba4a5a8f60>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/solaredge-modbus/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fba4a5a8c50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/solaredge-modbus/
  Could not find a version that satisfies the requirement solaredge_modbus==0.7.0 (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for solaredge_modbus==0.7.0 (from -r requirements.txt (line 1))
Open to suggestions ;)

EDIT: Gotcha! :) I have been experimenting with the container and I have found the solution. I had to change the DNS server the container looks at for resolving DNS names. I use AdguardHome as my DNS server and somehow that prevented DNS requests from the container from being resolved. So I modified the container to look at 1.1.1.1 as DNS server and recreated the container. Now

Code: Select all

pip3 install -r requirements.txt
pulled the modbus file and the plugin is now working. Thanks Walter for putting me on the right track! :mrgreen:
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
AddieJanssen
Posts: 17
Joined: Sunday 27 September 2020 16:17
Target OS: -
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by AddieJanssen »

This is how I develop the plugin:
- I am using the domoticz/domoticz image.
- Start the container and mount a local (host) folder to store the plugin (looks like you've got that covered)
- Connect to the container using: docker exec -it domoticz bash
- Goto the folder where the plugin lives: cd /opt/domoticz/userdata/plugins/domoticz-solaredge-modbustcp-plugin
- Install the modbus library IN that folder: pip3 install solaredge_modbus-0.7.0 -t . (notice the dot at the end of that command

Once you exit the session, you should see the solaredge modbus library files in the plugin folder on your host.
This should survive updates of the container, since the files are on the host.

Might not be the best option, but works for me and makes updating very easy...
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

Hi Addie,

Excellent! Your procedure is even more effective. I will try to uninstall the plugin tomorrow and use your instructions to install the modbus package on my host.

Thanks for the plugin and the tip!
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

Hmmm.... slight problem.... When I try to install the plugin I get this:

Code: Select all

root@ba0fc83c619f:/opt/domoticz/userdata/plugins/SolarEdge# pip3 install solaredge_modbus-0.7.0 -t .
Collecting solaredge_modbus-0.7.0
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/solaredge-modbus-0-7-0/
I have the container use 1.1.1.1 as DNS server so my AdguardHome DNS should not interfere (I think).

I should note that Watchtower updated the container this afternoon. I now have build 14767

Tips?
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
User avatar
Sjonnie2017
Posts: 361
Joined: Wednesday 02 August 2017 19:43
Target OS: Linux
Domoticz version: Latest ß
Location: The Netherlands
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by Sjonnie2017 »

I gave it another try. And now I got it working. I just had to omit the version numer of solaredge_modus :)

Code: Select all

root@ba0fc83c619f:/opt/domoticz/userdata/plugins/SolarEdge# pip3 install solaredge_modbus -t . --upgrade
Collecting solaredge_modbus
  Using cached https://files.pythonhosted.org/packages/a7/f9/ab37fd34dc835a1673cd2edf6e22e246c16f70566b48b87c7e8b14e05bcb/solaredge_modbus-0.7.0-py3-none-any.whl
Collecting pymodbus>=2.4.0 (from solaredge_modbus)
  Using cached https://files.pythonhosted.org/packages/fb/0f/28190d06bbc3b78834d384cb04bb15e5dcdea4f5d370094dbf5debc3af10/pymodbus-2.5.3-py2.py3-none-any.whl
Collecting pyserial>=3.4 (from pymodbus>=2.4.0->solaredge_modbus)
  Using cached https://files.pythonhosted.org/packages/07/bc/587a445451b253b285629263eb51c2d8e9bcea4fc97826266d186f96f558/pyserial-3.5-py2.py3-none-any.whl
Collecting six>=1.15.0 (from pymodbus>=2.4.0->solaredge_modbus)
  Using cached https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl
Installing collected packages: pyserial, six, pymodbus, solaredge-modbus
Successfully installed pymodbus-2.5.3 pyserial-3.5 six-1.16.0 solaredge-modbus-0.7.0
root@ba0fc83c619f:/opt/domoticz/userdata/plugins/SolarEdge# 
Since my Domoticz container is updated almost daily I will soon enough find out if the installation "sticks" :mrgreen:

EDIT: One day later, new container arrived overnight. solaredge_modbus is still functioning.
ConBee II - TRÅDFRI lights + switches, loads of ChingLing dimmers and switches, Heiman and Xiaomi sensors
SolarEdge SE4000H (with active modbus_tcp)
YouLess Energy meter
Shelly 2.5 in roller shutter mode
brjhaverkamp
Posts: 56
Joined: Wednesday 06 December 2017 16:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New Python plugin: Domoticz SolarEdge_ModbusTCP

Post by brjhaverkamp »

Hi Addie et.all,

I thought this christmas break was a good idea to update my domoticz a bit.
Your plugin was one of the things to update. I am running your plugin to great satisfaction for a long time now.
But I was still on the version of October 2020 before.

I updated it with a simple git pull. After starting domoticz up again, I noticed In the log got the error: KeyError: 'p1_current' (longer snippet of my /var/log/syslog below)

Probably it is related to what I saw in your log, renaming from p1 to l1. But I don't know how to solve this.
Are there some steps to do in the database?

Regards,

Bert
Dec 21 14:49:20 joulebox domoticz[12136]: domoticz: Solar panels attic: _plugin.onHeartbeat()
Dec 21 14:49:20 joulebox domoticz[12136]: 2022-12-21 14:49:20.133 #33[1;31mError: Solar panels attic: _plugin.onHeartbeat()#33[0;0m
Dec 21 14:49:20 joulebox domoticz[12136]: domoticz: Solar panels attic: File "/var/www/domoticz/plugins/domoticz-solaredge-modbustcp-plugin-backup/plugin.py", line 358, in onHeartbeat
Dec 21 14:49:20 joulebox domoticz[12136]: 2022-12-21 14:49:20.133 #33[1;31mError: Solar panels attic: File "/var/www/domoticz/plugins/domoticz-solaredge-modbustcp-plugin-backup/plugin.py", line 358, in onHeartbeat#033[0;0m
Dec 21 14:49:20 joulebox domoticz[12136]: domoticz: Solar panels attic: m.update(inverter_values[unit[Column.MODBUSNAME]], inverter_values[unit[Column.MODBUSSCALE]])
Dec 21 14:49:20 joulebox domoticz[12136]: 2022-12-21 14:49:20.133 #33[1;31mError: Solar panels attic: m.update(inverter_values[unit[Column.MODBUSNAME]], inverter_values[unit[Column.MODBUSSCALE]])#33[0;0m
Dec 21 14:49:20 joulebox domoticz[12136]: domoticz: Solar panels attic: KeyError: 'p1_current'
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest