Page 7 of 21

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Tuesday 06 March 2018 7:06
by bonebuster
Hi

Great job
works fine for me with Unitronics V350 PLC

i can read memory intger in TCP mode thanks !
is it possible to read multiple registers with only one command and have them in multiple custom sensors ?

or i have to read 1 register by command ?

thanks

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Tuesday 06 March 2018 20:01
by JackWolfskind
Unfortunately Domoticz doesn't start at all , after installation of the new true TCP plugin version. Maybe because I'm already on the Domo beta?
Will there be eventually a new plugin Version also supporting the latest Domo, then I can test reading and writing some TCP_modbus Devices :D

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Tuesday 06 March 2018 20:48
by Domoticx
JackWolfskind wrote: Tuesday 06 March 2018 20:01 Unfortunately Domoticz doesn't start at all , after installation of the new true TCP plugin version. Maybe because I'm already on the Domo beta?
Will there be eventually a new plugin Version also supporting the latest Domo, then I can test reading and writing some TCP_modbus Devices :D
Bonebuster got it working with domoticz beta 3.8975

Have you installed pymodbusTCP correctly ?? (you also need the normal "serial" pymodbus)

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Tuesday 06 March 2018 20:49
by Domoticx
bonebuster wrote: Tuesday 06 March 2018 7:06 Hi

Great job
works fine for me with Unitronics V350 PLC

i can read memory intger in TCP mode thanks !
is it possible to read multiple registers with only one command and have them in multiple custom sensors ?

or i have to read 1 register by command ?

thanks
1 register by command

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Tuesday 06 March 2018 22:01
by JackWolfskind
Strange, it doesn't work anymore for me after replacing the plugin.py with the new 1.1.0 Version, although the older version was ok :?

Before I got the old version working by following the installation manual:
Install for python 3.x with: sudo pip3 install -U six
copy the py file to v3.x python
sudo cp six.py /usr/lib/python3.5
Install for python 3.x with: sudo pip3 install -U pymodbus
Install for python 3.x with: sudo pip3 install -U pymodbusTCP

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Tuesday 06 March 2018 22:51
by Domoticx
JackWolfskind wrote: Tuesday 06 March 2018 22:01 Strange, it doesn't work anymore for me after replacing the plugin.py with the new 1.1.0 Version, although the older version was ok :?

Before I got the old version working by following the installation manual:
Install for python 3.x with: sudo pip3 install -U six
copy the py file to v3.x python
sudo cp six.py /usr/lib/python3.5
Install for python 3.x with: sudo pip3 install -U pymodbus
Install for python 3.x with: sudo pip3 install -U pymodbusTCP
What does the LOG say?

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Tuesday 06 March 2018 22:57
by Domoticx
Hi all,

Programmed some more hours on the plugin! :geek:

Released READ v1.1.1, notable changes:
- Can also decode STRING 2/4/6/8 bytes (not tested)
- Code cleanup, Fixed widths
- Added timeouts (5 sec)

Released WRITE v1.0.7, notable changes:
- TCP/IP support
- Code cleanup, Fixed widths
NOTE: RTU = HEX, TCP/IP = INT value
TODO: Option wich datatype to send (using stringbuilder)

Overall TODO: To cleanup plugin option space combine IP with port, like: 192.168.1.1:502 (and if only IP, port is 502 by default)

Updated readme, please read!

DL @ https://github.com/DomoticX/domoticz-modbus

Enjoy!

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Tuesday 06 March 2018 23:55
by JackWolfskind
Domoticx wrote: Tuesday 06 March 2018 22:51
JackWolfskind wrote: Tuesday 06 March 2018 22:01 Strange, it doesn't work anymore for me after replacing the plugin.py with the new 1.1.0 Version, although the older version was ok :?

Before I got the old version working by following the installation manual:
Install for python 3.x with: sudo pip3 install -U six
copy the py file to v3.x python
sudo cp six.py /usr/lib/python3.5
Install for python 3.x with: sudo pip3 install -U pymodbus
Install for python 3.x with: sudo pip3 install -U pymodbusTCP
What does the LOG say?
Unfortunately I couldn't find out where the log is. So far domoticz pretends to be running but I can't access the domoticz GUI via Browser, as soon as I install the new TCP Modbus. With the old one its running fine.
Unfortunately it's the same fault with V1.11...
Gonna have find out where Domo hides its logs....

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Wednesday 07 March 2018 1:34
by McMelloW
JackWolfskind wrote: Tuesday 06 March 2018 23:55 Unfortunately I couldn't find out where the log is. So far domoticz pretends to be running but I can't access the domoticz GUI via Browser, as soon as I install the new TCP Modbus. With the old one its running fine.
Unfortunately it's the same fault with V1.11...
Gonna have find out where Domo hides its logs....
I had the same kind of problem. Got on my Rpi with Putty or WinSCP and did the following steps
stopped domoticz with

Code: Select all

sudo service domoticz stop
Removed the /plugin/modbus-read and the /plugin/modbus-write folders.
Started domoticz again with

Code: Select all

sudo service domoticz start
In the browser, go to hardware and remove all the modbus hardware and look for log entries

Perhaps it is a quick and dirty trick, but it worked in my situation.

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Wednesday 07 March 2018 7:37
by Domoticx
@JackWolfskind

New version also requires pymodbusTCP, have you installed it?

Also the plugin is for the stable version atm (not tested on beta)

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Wednesday 07 March 2018 20:38
by bonebuster
@Domoticx

Hi write command works fine with Domoticz beta V3.8975 TCP/IP modbus fonction 6 to write 1 register in Unitronics PLC in MI memory

Many thanks !

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Thursday 08 March 2018 15:10
by Jan Jansen
@ Domoticx,

After a lot of trial and error I now can use function 6 (write single holding registor). Using the example as described on your website (http://domoticx.com/arduino-modbus-rs485-rtu-slave/), I learned to switch a LED on and off via modbus RS485. Thanks for stimulating my brain.

Jan

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Thursday 08 March 2018 16:52
by McMelloW
@ Domoticx

Tried it again with the 06-03-2018 update.
Installed the plugin dicrectorie from github in /home/pi/domoticz/plugins
Restarted Domoticz.
Add a Mobus Read for TCP/IP
As soon as I add the hardware domoticz hangs.
After removed the mudbus pligin directories and restarted Domomticz I received the following errors

Code: Select all

2018-03-08 16:43:05.691 Error: (Modbus) failed to load 'plugin.py', Python Path used was ':/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-03-08 16:43:05.699 Error: (ModbusTCP) Module Import failed, exception: 'ImportError'
2018-03-08 16:43:05.699 Error: (ModbusTCP) Module Import failed: ' Name: plugin'
2018-03-08 16:43:05.699 Error: (ModbusTCP) Error Line details not available.
2018-03-08 16:44:30.971 Error: ModbusTCP hardware (9) thread seems to have ended unexpectedly
2018-03-08 16:45:01.544 Error: ModbusTCP hardware (9) thread seems to have ended unexpectedly
2018-03-08 16:45:30.558 Error: ModbusTCP hardware (9) thread seems to have ended unexpectedly
The mesaages are different from the previous trial

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Saturday 10 March 2018 19:38
by Jan Jansen
@Mc Mellow,

Suddenly I could no longer reach Domoticz via the web interface. Today I read viewtopic.php?f=65&t=22339&start=20#p173424.

I followed the instructions and was able to reach Domoticz (Stretch, V3.8976) again. I also can use the write function again.

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Saturday 10 March 2018 21:28
by McMelloW
Jan Jansen wrote: Saturday 10 March 2018 19:38 @Mc Mellow,

Suddenly I could no longer reach Domoticz via the web interface. Today I read viewtopic.php?f=65&t=22339&start=20#p173424.

I followed the instructions and was able to reach Domoticz (V3.8976) again. I also can use the write function again.
@Jan Jansen.
Thanks for your support.

On my system this plugin is a total disaster.
After removing python3.5 the plugins did not show up in the hardware list.
Installing pymodbus pymodbusTCP with pip3 Python 3.5 was installed again. Aaaarghhh
After reboot Modbus plugins showed up in the hardware list.
Adding and activating a modbus-read hardware freese domoticz and has errors in retreiving devices.
Deleting the plugin modbus-xx directories bring Domoticz to live again.
This is not going to work for me.
This are the errors in the log

Code: Select all

2018-03-10 21:15:44.185 Error: (Modbus) failed to load 'plugin.py', Python Path used was ':/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-03-10 21:15:44.186 Error: (Modbus read test) Module Import failed, exception: 'ImportError'
2018-03-10 21:15:44.186 Error: (Modbus read test) Module Import failed: ' Name: plugin'
2018-03-10 21:15:44.186 Error: (Modbus read test) Error Line details not available.
2018-03-10 21:15:44.212 Error: (Rpi) 'onStart' failed 'KeyError'.
2018-03-10 21:15:44.212 Error: (Rpi) ----> Line 162 in /home/pi/domoticz/plugins/PiMonitor/plugin.py, function onStart
2018-03-10 21:15:44.212 Error: (Rpi) ----> Line 56 in /home/pi/domoticz/plugins/PiMonitor/plugin.py, function onStart

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Sunday 11 March 2018 8:08
by Jan Jansen
@Mc Mellow,

I am certainly not an expert, I learn from a lot of trial and error. Perhaps you know a lot more than me, but still. Before Domoticz broke, I had similar problems as you still have. I followed the instructions as described in the WIKI (Using Python plugins, Installing Python on Raspberry Pi with Raspbian). Maybe you have not seen that. At that moment those problems were over.

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Sunday 11 March 2018 13:41
by Domoticx
@McMelloW,

Seems like a possible python conflict on your raspbian somewhere :roll: , maybe because you are using a very old (jessie or first stretch) rasbian image? have you installed six (or maybe you can check)?

six was already installed on (latest) stretch but not on some jessie images, maybe you can update to the latest stretch mage? (don't know of there is export/import function in domoticz that could save time)

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Sunday 11 March 2018 14:31
by McMelloW
Domoticx wrote: Sunday 11 March 2018 13:41 @McMelloW,

Seems like a possible python conflict on your raspbian somewhere :roll: , maybe because you are using a very old (jessie or first stretch) rasbian image? have you installed six (or maybe you can check)?

six was already installed on (latest) stretch but not on some jessie images, maybe you can update to the latest stretch mage? (don't know of there is export/import function in domoticz that could save time)
Thanks for your reaction.
Two python plugins are running fine. PiMonitor and Disc-usage.
So I did compgen -c python and removed python3.5
After that no modbus plugins were in the hardware list.
I tried to install six but pip3 was gone.
Installing pip3 caused an automatic install of python3.5 again. Back to square 1

Code: Select all

compgen -c python  ==> shows now the following python installed

python3.5m
python3.4m
python
python2-config
python3m
python3
python2.7
python3.5
python2.7-config
python3.4
python-config
python2

lsb_release -a   ==> shows the following version.
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.3 (stretch)
Release:        9.3
Codename:       stretch


This is my current situation.

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Monday 12 March 2018 6:38
by Domoticx
@McMelloW,

So.... have you installed six too?... after pip3 installed 3.5 again? (just to be sure)

My environment:

Code: Select all

compgen -c python

Code: Select all

python3.5m-config
python3.5m
python
python2-config
python3m
python3-config
python3
python2.7
python3.5
python3m-config
python3.5-config
python2.7-config
python-config
python2
-------------------------

Code: Select all

lsb_release -a

Code: Select all

No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.3 (stretch)
Release:        9.3
Codename:       stretch
-------------------------

Seems i don't have Python 3.4 installed, only Python 2.7 and 3.5 (and more -config listings)... :?

Maybe you can try to remove the 3.4 version (instead of 3.5) :?

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP

Posted: Monday 12 March 2018 6:40
by Domoticx
Updated OP!! with lots off goodies and links on Modbus to test stuff out! :ugeek: http://www.domoticz.com/forum/viewtopic ... 65&t=21297

You can even install modbus SLAVE on a ESP8266 Wireless!: http://domoticx.com/esp8266-wifi-modbus-tcp-ip-slave/