Page 5 of 21
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Saturday 27 January 2018 19:33
by McMelloW
Domoticx wrote: ↑Saturday 27 January 2018 19:13
@McMelloW
No, this is a universal plugin for modbus, it can read 1-4 registers (depending on selected datatype)
It seems like you need a Modbus plugin (written) for your device!
@Domoticx,
Thanks for your update. It was a nice bit of trial and error. Tested the connection with a Win10 modbus scanner to find out what I can expect for data. I will look for other ways to read my SolarEdge
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Tuesday 30 January 2018 15:57
by palmipete
Hi all,
I have now running since 3 days 3 different Modbus equipments in my house for thermal and energy metering as well as for my heating system.
In general it works quite well (reading).
However, sometimes domoticz, even if it is displaying OK when I check the status, the web interface is blocked.
as soon as I restart domoticz all works again.
This happened 2 times in 3 days.
I tried to put an automatic restart in crontab (hourly) but this did not work yet (I perhaps not so bad in Python, but beginner in Linux).
my main comments to the plugin:
- I would preefer to put an additional parameter in the hardware menu for defining a time step (it is nice to have data every 10seconds, but if I need an energy value every hour this consumed memory for nothing).
- one step further, I am planning to put some kid of check and compare to the last value, and only save data if the change is higher than a limit which is specified in the hardware interface as well
- I do not like these 5 minutes averages in domoticz. For my needs the best would be to save only event based (if change is > threshold) but then keep ALL dataa, also when exporting. I guess this is not the right place to ask this question, but perhaps you have already thought about this since it is typically a problem for periodic measurements (such as modbus) that are in most cases too many values for nothing ...
at the end a question: in the modbus write function, I can switch off my heating system, but it fails later. I think this is due to the hex format of data.
my code is 0 or 1 and I tried: 0x00 for 0 and 0x01 for 1.
but it only cuts the systems, switching on does not work? is this format correct?
Peter
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Wednesday 31 January 2018 14:06
by Domoticx
Hi palmipete,
Are you using RTU or TCP?
palmipete wrote: ↑Tuesday 30 January 2018 15:57
Hi all,
I have now running since 3 days 3 different Modbus equipments in my house for thermal and energy metering as well as for my heating system.
In general it works quite well (reading).
Great!
palmipete wrote: ↑Tuesday 30 January 2018 15:57
my main comments to the plugin:
- I would preefer to put an additional parameter in the hardware menu for defining a time step (it is nice to have data every 10seconds, but if I need an energy value every hour this consumed memory for nothing).
There are no more configurable fields available in domoticz....i also wanted timeout and retry setting...but there is no more room...
palmipete wrote: ↑Tuesday 30 January 2018 15:57
- one step further, I am planning to put some kid of check and compare to the last value, and only save data if the change is higher than a limit which is specified in the hardware interface as well
Hopefully future versions of domoticz can implement this, based on plugin return data...
palmipete wrote: ↑Tuesday 30 January 2018 15:57
- I do not like these 5 minutes averages in domoticz. For my needs the best would be to save only event based (if change is > threshold) but then keep ALL dataa, also when exporting. I guess this is not the right place to ask this question, but perhaps you have already thought about this since it is typically a problem for periodic measurements (such as modbus) that are in most cases too many values for nothing ...
Hopefully future versions of domoticz can implement this...
palmipete wrote: ↑Tuesday 30 January 2018 15:57
at the end a question: in the modbus write function, I can switch off my heating system, but it fails later. I think this is due to the hex format of data.
my code is 0 or 1 and I tried: 0x00 for 0 and 0x01 for 1.
but it only cuts the systems, switching on does not work? is this format correct?
The HEX seems ok, are you sure you need to send 0x01 to switch it on?, what does the manual say?
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Monday 05 February 2018 21:59
by palmipete
I use Modbus RTU with a USB converter.
I understood the code so no I could make it work as I wanted (Modbus write).
I also wrote a code as python plugin to make an Event-Logger (check all 10 secs for new values and save to a daily log file).
perhaps somebody is interested in.
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Wednesday 14 February 2018 10:13
by JackWolfskind
Hi,
I'm currently stuck with the error "Modbus error communicating!, check your settings!" with two different Modbus TCP devices which work fine with different home automation SW.
Anybody got Modbus TCP working with any device at all?
Thanks
Jack
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Wednesday 14 February 2018 22:21
by pablo86
good morning.
i have the same problem with tcp modbus
2018-02-14 22:19:21.747 (test) MODBUS DEBUG TCP CMD - Method=tcp, Address=192.168.3.5, Port=502, Register=9, Data type=16int
2018-02-14 22:19:21.747 (test) Modbus error communicating!, check your settings!
2018-02-14 22:19:21.747 (test - ModbusDEV-READ) Updating device from 0:'0' to have values 0:'0'.
2018-02-14 22:19:21.748 (test) Modbus error decoding (or recieved no data)!, check your settings!
2018-02-14 22:19:21.748 (test - ModbusDEV-READ) Updating device from 0:'0' to have values 0:'0'.
my hardware is ad4eth Papouch 4-20mA 4 analog input
with software medford work fine
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Thursday 15 February 2018 19:08
by JackWolfskind
Actually it seems this plugin only supports "Modbus
RTU over TCP" (which is Modbus RTU send over TCP by a serial to LAN converter ) and not the more much common "Modbus TCP protocol", which is very similar but with different structure!
Maybe this helps to better understand:
http://control.com/thread/1305797461
Maybe in the future the plugin can Support both ways?

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Thursday 22 February 2018 20:42
by Domoticx
Hi Jack,
I think you are right, so maybe i can make a test plugin with this:
https://pypi.python.org/pypi/pyModbusTCP/

will make a alpha/beta plugin soon to test things out!
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Thursday 22 February 2018 23:03
by papoo
Domoticx wrote:

will make a alpha/beta plugin soon to test things out!
great

Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Thursday 22 February 2018 23:07
by McMelloW
Domoticx wrote: ↑Thursday 22 February 2018 20:42

will make a alpha/beta plugin soon to test things out!
+1 looking forward to it
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Friday 23 February 2018 21:50
by Domoticx
Hi All,
Here is the TEST APLHA PLUGIN
So now you need 2 modbus dependancies:
- PYMODBUS v1.4.0 or higher
- Install for python 3.x with:
sudo pip3 install -U pymodbus
- PYMODBUSTCP v0.1.5 or higher
- Install for python 3.x with:
sudo pip3 install -U pymodbusTCP
Option "TCP" is now modbusTCP and other has been renamed to "RTU over TCP"
Please test if the code/plugin works! (i do not have TCP hardware to test it on)
*edit file removed* (now got my own test software

)
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Friday 23 February 2018 21:57
by papoo
You can use a modbus esclave simulator
Here one
https://sourceforge.net/projects/modrssim/
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Friday 23 February 2018 22:05
by Domoticx
Thanks for that!
Ps. i see i also got another import error, i will look how to solve (*sigh*....domoticz paths....)
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Friday 23 February 2018 22:16
by Domoticx
Domoticx wrote: ↑Friday 23 February 2018 22:05
Thanks for that!
Ps. i see i also got another import error, i will look how to solve (*sigh*....domoticz paths....)
Fixed the importbug.
Ps. is port 502 default?
Also with the simulator i can use the machines IP right?
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Friday 23 February 2018 22:33
by Domoticx
Yes!!

got a Python script working with the windows simulator!! but there is/was a catch hahaha, i have to make the plugin a bit smarter....
Stay tuned!
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Friday 23 February 2018 23:40
by Domoticx
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Friday 23 February 2018 23:57
by papoo
Great
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Saturday 24 February 2018 9:46
by McMelloW
Looks great !!
What is the length of the register you can read? For the SolarEdge over port 502, you have to read 0 - 122 positions.
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Saturday 24 February 2018 10:08
by freijn
looks good, curious on results !
Re: [Released] Python plugin: Modbus RS485 RTU/ASCII/TCP
Posted: Saturday 24 February 2018 11:46
by McMelloW
Installing the READ plugin hangs domoticz. After restarting Domoticz, no screen visible and no connection via the browser is possible. SSH via Putty remains active. Removing the plugin from the Plugin directory and Domoticz restart solved the problem.
It is sadly, because it looked promising