Page 20 of 21
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Friday 18 August 2023 15:59
by PieterS
simat wrote: ↑Tuesday 15 August 2023 9:44
Like this ?
Its type 243 - Domoticz.Device(Name="Import Wh", Unit=2,Type=243,Subtype=29,Used=0).Create()
Yes, indeed!
But since my last question in this thread I changed my hardware. Went over to a ESP8266 and ESPeasy. Because it is a bit difficult to store a Raspberry in that area. Maybe on a later moment. Thanks for now.
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Friday 15 December 2023 17:47
by bonebuster
Hi
since complete re-install
with Pi4B, bullseye, python 3.9.2, pymodbus 3.6.2, pymodbusTCP 0.2.1, domoticz 2023.2 modbus-domoticz plugin last version, i have this issue :
(ModbusREAD) failed to load 'plugin.py', Python Path used was '/home/pi4/domoticz/plugins/modbus-read/:/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'.
2023-12-14 16:34:04.186 Error: Conso_saison: Traceback (most recent call last):
2023-12-14 16:34:04.186 Error: Conso_saison: File "/home/pi4/domoticz/plugins/modbus-read/plugin.py", line 177, in <module>
2023-12-14 16:34:04.186 Error: Conso_saison: from pymodbus.client.sync import ModbusSerialClient # RTU
2023-12-14 16:34:04.186 Error: Conso_saison: ModuleNotFoundError: No module named 'pymodbus.client.sync'
Anyone to help-me ?
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Thursday 07 March 2024 15:03
by Copitano
Same problem here. Found no solution yet. Has anybody seen @DomoticX around on the forum. Mybe he can provide a solution?
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Thursday 07 March 2024 15:07
by waltervl
Copitano wrote: ↑Thursday 07 March 2024 15:03
Same problem here. Found no solution yet. Has anybody seen @DomoticX around on the forum. Mybe he can provide a solution?
USER STATISTICS DomoticX
Joined:Sunday 07 January 2018 21:19
Last active:Sunday 30 August 2020 21:26
So do not expect a solution from him/her....
Did you check the wiki on this error?
https://www.domoticz.com/wiki/Using_Pyt ... ules_Fails
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Thursday 07 March 2024 23:36
by FlyingDomotic
It seems that pymodbus changed.
Instead of pymodbus.client.sync, try pymodbus.client.serial in the plugin.
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Wednesday 20 March 2024 16:20
by Copitano
by FlyingDomotic » Friday 08 March 2024 0:36
It seems that pymodbus changed.
Instead of pymodbus.client.sync, try pymodbus.client.serial in the plugin.
Tried your suggestion. At first I got another error, but after also replacing 'pymodbus.client.sync' in the TCP part bij 'pymodbus.client.tcp' at least I got an device. Still got an error like this:
Code: Select all
2024-03-20 15:45:27.099 Error: Modbus RTU read: Modbus error decoding or received no data (RTU/ASCII/RTU over TCP)!, check your settings!
2024-03-20 15:45:27.105 Error: Modbus RTU read: Modbus error decoding or received no data!, check your settings!
I gues it's because there is no real device on this test Pi. Now I think I have to edit also the write part of the plugin the same way.
EDIT1: Yes, it worked the same way for the write function

Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Wednesday 20 March 2024 16:22
by Copitano
FlyingDomotic wrote: ↑Thursday 07 March 2024 23:36
It seems that pymodbus changed.
Instead of pymodbus.client.sync, try pymodbus.client.serial in the plugin.
See above

Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Thursday 21 March 2024 20:31
by Copitano
Tested the Python plugin: Modbus RTU / ASCII / TCP/IP with de edited plugin.py scripts.
Unfortunately I cheered too early. Although the devices are now displayed properly, no data enters the devices after connecting the CH341-UART converter. As far as I can tell, I don't see anything crazy with dmesg. What am I missing?
Code: Select all
pi@raspberrypi4BSEM:~ $ sudo dmesg | grep -i usb
[ 0.139822] usbcore: registered new interface driver usbfs
[ 0.139881] usbcore: registered new interface driver hub
[ 0.139949] usbcore: registered new device driver usb
[ 0.140329] usb_phy_generic phy: supply vcc not found, using dummy regulator
[ 0.140559] usb_phy_generic phy: dummy supplies not allowed for exclusive requests
[ 1.508199] usbcore: registered new interface driver r8152
[ 1.508274] usbcore: registered new interface driver lan78xx
[ 1.508360] usbcore: registered new interface driver smsc95xx
[ 1.556002] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 1
[ 1.557814] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 2
[ 1.557836] xhci_hcd 0000:01:00.0: Host supports USB 3.0 SuperSpeed
[ 1.558214] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.01
[ 1.558235] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1.558249] usb usb1: Product: xHCI Host Controller
[ 1.558263] usb usb1: Manufacturer: Linux 6.1.21-v8+ xhci-hcd
[ 1.558275] usb usb1: SerialNumber: 0000:01:00.0
[ 1.559105] hub 1-0:1.0: USB hub found
[ 1.560148] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.01
[ 1.560171] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1.560186] usb usb2: Product: xHCI Host Controller
[ 1.560200] usb usb2: Manufacturer: Linux 6.1.21-v8+ xhci-hcd
[ 1.560213] usb usb2: SerialNumber: 0000:01:00.0
[ 1.560898] hub 2-0:1.0: USB hub found
[ 1.563807] usbcore: registered new interface driver uas
[ 1.563925] usbcore: registered new interface driver usb-storage
[ 1.575796] usbcore: registered new interface driver usbhid
[ 1.575810] usbhid: USB HID core driver
[ 1.814947] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[ 1.965513] usb 1-1: New USB device found, idVendor=2109, idProduct=3431, bcdDevice= 4.21
[ 1.965551] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 1.965566] usb 1-1: Product: USB2.0 Hub
[ 1.967415] hub 1-1:1.0: USB hub found
[ 2.262902] usb 1-1.4: new full-speed USB device number 3 using xhci_hcd
[ 2.369316] usb 1-1.4: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.63
[ 2.369346] usb 1-1.4: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 2.369362] usb 1-1.4: Product: USB2.0-Serial
[ 6.153943] usbcore: registered new interface driver brcmfmac
[ 6.522257] usbcore: registered new interface driver usbserial_generic
[ 6.522367] usbserial: USB Serial support registered for generic
[ 6.608848] usbcore: registered new interface driver ch341
[ 6.608949] usbserial: USB Serial support registered for ch341-uart
[ 6.636039] usb 1-1.4: ch341-uart converter now attached to ttyUSB0
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Friday 22 March 2024 0:47
by Copitano
waltervl wrote: ↑Thursday 07 March 2024 15:07
Copitano wrote: ↑Thursday 07 March 2024 15:03
Same problem here. Found no solution yet. Has anybody seen @DomoticX around on the forum. Mybe he can provide a solution?
USER STATISTICS DomoticX
Joined:Sunday 07 January 2018 21:19
Last active:Sunday 30 August 2020 21:26
So do not expect a solution from him/her....
Did you check the wiki on this error?
https://www.domoticz.com/wiki/Using_Pyt ... ules_Fails
Yes, but it didn't solve all.
https://www.domoticz.com/forum/viewtopi ... 20#p315320
Would it be a good idea to downgrade the Python version to the latest version under which the plugin fully worked?
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Tuesday 26 March 2024 0:11
by waltervl
You can try to downgrade Python but that is not an easy process.
The Docker version of Domoticz runs with python 3.8 I believe. Perhaps it that an option?
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Tuesday 14 May 2024 9:43
by simat
My version is still working fine on 2024.4
https://github.com/simat-git/SDM120-Modbus
Easy to adapt to any modbus meter if you know the register numbers.
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Thursday 06 June 2024 18:25
by Copitano
@simat
I just saw your response now. I had given up for the time being because my knowledge of Phyton does not extend that far. But I'll definitely see if I can get things working again with your solution. Although it would be very nice if a next version of Domoticz could include a native version for Modbus RTU that is also maintained in new versions.

Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Monday 26 August 2024 16:34
by Copitano
waltervl wrote: ↑Tuesday 26 March 2024 0:11
You can try to downgrade Python but that is not an easy process.
The Docker version of Domoticz runs with python 3.8 I believe. Perhaps it that an option?
On second thought, that doesn't seem to be the way to go. I think that will get in the way of every further update. But I don't have another solution yet. Unfortunately, my pyranometer has to keep running on an old Pi 3B+ with version 2021.1 on it. My Enphase inverters unfortunately no longer work on it due to an (unrequested) security update from Enphase.
Ik hoop dat er in een van de komende stable versies een native Modbus RTU module ingebouwd kan worden in de lijn van die van DomoticX.
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Monday 26 August 2024 16:37
by Copitano
I have looked at your version, but I can't figure out how to adapt it for more general use. So not only specifically for your meter, but also for my pyranometer that measures the global radiation of the sun.
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Friday 20 September 2024 17:49
by Rosomak
Hi All,
I rewrote the script of the Read plugin and it reads the modbus RTU and modbus TCP/IP registers correctly.
I have no way to check modbus RTU over IP.
Just replace the plugin.py file in the location .../domoticz/plugins/modbus-read and restart Domoticz
I will work on the plugin for writing next week.
Dependences needed:
pip3 install -U pymodbus pymodbusTCP
pip install pyserial
P.S. I'm not able to attach file here so I left it on
https://easyupload.io/fj9psi
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Tuesday 24 September 2024 1:24
by Copitano
Rosomak wrote: ↑Friday 20 September 2024 17:49
Hi All,
I rewrote the script of the Read plugin and it reads the modbus RTU and modbus TCP/IP registers correctly.
I have no way to check modbus RTU over IP.
Just replace the plugin.py file in the location .../domoticz/plugins/modbus-read and restart Domoticz
I will work on the plugin for writing next week.
Dependences needed:
pip3 install -U pymodbus pymodbusTCP
pip install pyserial
P.S. I'm not able to attach file here so I left it on
https://easyupload.io/fj9psi
Super!!!! I will be testing this tomorrow.
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Wednesday 25 September 2024 0:40
by Copitano
As I said, I tested today with the new plugin.py version 2024 beta. Unfortunately, I now have the problem back that I also mentioned above. No widget is created. I have not been able to change that yet as with the previous version because those lines in the script are commented out.
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Saturday 28 September 2024 13:27
by Copitano
Rosomak wrote: ↑Friday 20 September 2024 17:49
Hi All,
I rewrote the script of the Read plugin and it reads the modbus RTU and modbus TCP/IP registers correctly.
I have no way to check modbus RTU over IP.
Just replace the plugin.py file in the location .../domoticz/plugins/modbus-read and restart Domoticz
I will work on the plugin for writing next week.
Dependences needed:
pip3 install -U pymodbus pymodbusTCP
pip install pyserial
P.S. I'm not able to attach file here so I left it on
https://easyupload.io/fj9psi
I am getting this Error:
Code: Select all
2024-09-28 13:22:34.672 Error: Test Total Solar Radiation: (ModbusREAD) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/modbus-read/:/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'.
2024-09-28 13:22:34.673 Error: Test Total Solar Radiation: Traceback (most recent call last):
2024-09-28 13:22:34.673 Error: Test Total Solar Radiation: File "/home/pi/domoticz/plugins/modbus-read/plugin.py", line 163, in <module>
2024-09-28 13:22:34.673 Error: Test Total Solar Radiation: from pymodbus import FramerType
2024-09-28 13:22:34.673 Error: Test Total Solar Radiation: ImportError: cannot import name 'FramerType' from 'pymodbus' (/usr/local/lib/python3.9/dist-
I am using Python Version: 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
and I did:
sudo apt-get update && sudo apt-get upgrade
pip3 install -U pymodbus pymodbusTCP
pip install pyserial
Looks like FramerType isn't where it should be. How do I get it in the right place?
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Sunday 29 September 2024 18:11
by Copitano
Rosomak wrote: ↑Friday 20 September 2024 17:49
Hi All,
I rewrote the script of the Read plugin and it reads the modbus RTU and modbus TCP/IP registers correctly.
Hi Rosomak,
I solved the problem of not creating devices/widgets by a clean install of the operating system and python 3.9.6 Below the result. Looks as if its working for me aswell

Now I just have to test with the sunsensor on the roof connected

.
Re: Python plugin: Modbus RTU / ASCII / TCP/IP
Posted: Tuesday 31 December 2024 8:36
by JPSke
Hello developers,
I am looking for someone with enough knowledge of the origininal Python plugin (version V2020.2F) to solve a problem I have:
After an update by Domoticz or a restart of the RPi, all my READ sensors start at the same time (heartbeat I presume).
I use the plugin to read information from a Solax Solar inverter and this device allows only one call per second.
This means that most of the 7 values I read come back wrong or not at all.
I have to adjust the heartbeats of each sensor by manually starting and stopping the hardware at different moments.
I tried to solve the problem by working with the polling rate and giving each sensor a different rate, but after some time they will be aligning again for a short period and giving errors again.
I was hoping that someone might be willing to change the plugin so that not only the polling rate but also the starting point or delay of the sensor can be set. My knowledge of Python is far too limited to try and do it myself, so I am calling on the community for help.
Thanks in advance