From ff6f56af3bd2637f400cc5554db342ce6ae500fd Mon Sep 17 00:00:00 2001 From: Sebastiaan Ebeltjes Date: Tue, 12 May 2020 11:47:17 +0200 Subject: [PATCH] updates updates --- README.md | 6 +- changelog.txt => modbus-read/changelog.txt | 153 ++++++++++----------- modbus-read/plugin.py | 55 ++++---- modbus-write/changelog.txt | 59 ++++++++ modbus-write/plugin.py | 50 ++++--- 5 files changed, 196 insertions(+), 127 deletions(-) rename changelog.txt => modbus-read/changelog.txt (87%) create mode 100644 modbus-write/changelog.txt diff --git a/README.md b/README.md index bb67d49..f1c1f67 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ ### Modbus Read/Write Plugins for Domoticz Author: Sebastiaan Ebeltjes / DomoticX.nl -Succesfully Tested on Domoticz version: 2020.2 +Succesfully Tested on Domoticz version: 2020.2 stable + +You can update domoticz with command: ```cd /home/pi/domoticz | ./updaterelease``` **Support for:** @@ -68,7 +70,7 @@ Then restart domoticz with: ```sudo service domoticz.sh restart``` ----- ### Dependancies -1. Raspbian image (FULL version recommended) +1. RPi: Raspbian image (FULL version recommended) 2. additional python3 libraries: **pymodbus AND pymodbusTCP** diff --git a/changelog.txt b/modbus-read/changelog.txt similarity index 87% rename from changelog.txt rename to modbus-read/changelog.txt index 4271517..e953666 100644 --- a/changelog.txt +++ b/modbus-read/changelog.txt @@ -1,79 +1,74 @@ -Modbus WRITE v2020.2B -- Added proper description - -Modbus WRITE v2020.2A -- Added: version checks and notification for needed dependancies -- Improved: TCP IP and PORT options now merged -- Improved: option descriptions, sorted options -- Optimized: Debug lines and info -- Optimized: All settings read once at plugin start -- Code cleanup - -Modbus READ v2020.2D -- Optimized: Added default device name -- Optimized: Debug lines and info - -Modbus READ v2020.2C -- Added: Plugin description -- Optimized: All settings read once at plugin start -- Optimized: Better log, debug, error usage. -- Fixed: Bug for device update on TCP/IP (on error) -- Code cleanup - -Modbus READ v2020.2B -- Added: Device polling rate setting (seconds) (e.g. ID:POLL = 1:10 then Device ID=1 and Pollingrate=10 seconds) -- Added: Some more debug lines for value output and pollingrate (heartbeat) - -Modbus READ v2020.2A -- Fixed: "no data found check settings" for new domoticz v2020.x -- Fixed: default settings are now filled correctly -- Added: BOOL conversion (for read coils...not tested on hardware) -- Added: version checks and notification for needed dependancies -- Added: ability for debug yes/no (for easy troubleshooting) -- Improved: TCP IP and PORT options now merged -- Improved: option descriptions, sorted options -- Code cleanup - -v2.0.0 -- Fixed exception in modbus library (added .registers again) -- New plugin: modbus-device [bramvreugd] - - With this plugin you can add a device with many registers at once - -v1.2.1 -- Fixed the exception "Modbus Error: [Invalid Parameter] Invalid collection of registers supplied" on my Raspberry/Domoticz - -v1.2.0 -- Fixed TAB error. - -v1.1.9 -- Fixed debug output [Sandolution] - -v1.1.8 -- Added "sys.path.append('/usr/local/lib/python3.5/dist-packages')" in the begining for modern python libraries compatibility. [akliouev] -- After wrestling for a day finaly found out that "data" is a list and doesn't have method ".registers" associated with it. [akliouev] - Must be remnants of older pymodbus versions. Changed "data.registers" -> "data". [akliouev] -- Fix: line 403 was verifying that Username is "1" (only "read coil") and otherwise wasn't updating anything. [akliouev] - -v1.1.7 -- Removed debug option due to implementation of sensor type. [Sandolution] -- Added more options for data type (swapping of low/high byte/word). [Sandolution] -- Adjusted dividing settings to include 10000. [Sandolution] -- Added more append paths [Sandolution] - -v1.1.6 -- Added import RTU framer for RTU over TCP to work. [Sandolution] -- Fix for unit id on RTU over TCP [Sandolution] - -v1.1.5 -- Added ID option for IP/TCP addresses. [S. Ebeltjes] - -v1.1.4 -- Removed debug option due to implementation of sensor type. [Sandolution] -- Added more options for data type (swapping of low/high byte/word). [Sandolution] -- Adjusted dividing settings to include 10000. [Sandolution] - -TODO: float decode word orders -float AB CD == byteorder=Endian.Big, wordorder=Endian.Big -float CD AB == byteorder=Endian.Big, wordorder=Endian.Little -float BA DC == byteorder=Endian.Little, wordorder=Endian.Big -float DC BA == byteorder=Endian.Little, wordorder=Endian.Little +Modbus READ v2020.2E +- Fixed: Plugin not starting in unreleased beta versions (dependancies check) +- Fixed: Default function set to to read holding registers. +- Improved: option and plugin descriptions +- Optimized: timeout on all methods set to 2 seconds. + +Modbus READ v2020.2D +- Optimized: Added default device name +- Optimized: Debug lines and info + +Modbus READ v2020.2C +- Added: Plugin description +- Optimized: All settings read once at plugin start +- Optimized: Better log, debug, error usage. +- Fixed: Bug for device update on TCP/IP (on error) +- Code cleanup + +Modbus READ v2020.2B +- Added: Device polling rate setting (seconds) (e.g. ID:POLL = 1:10 then Device ID=1 and Pollingrate=10 seconds) +- Added: Some more debug lines for value output and pollingrate (heartbeat) + +Modbus READ v2020.2A +- Fixed: "no data found check settings" for new domoticz v2020.x +- Fixed: default settings are now filled correctly +- Added: BOOL conversion (for read coils...not tested on hardware) +- Added: version checks and notification for needed dependancies +- Added: ability for debug yes/no (for easy troubleshooting) +- Improved: TCP IP and PORT options now merged +- Improved: option descriptions, sorted options +- Code cleanup + +v2.0.0 +- Fixed exception in modbus library (added .registers again) +- New plugin: modbus-device [bramvreugd] + - With this plugin you can add a device with many registers at once + +v1.2.1 +- Fixed the exception "Modbus Error: [Invalid Parameter] Invalid collection of registers supplied" on my Raspberry/Domoticz + +v1.2.0 +- Fixed TAB error. + +v1.1.9 +- Fixed debug output [Sandolution] + +v1.1.8 +- Added "sys.path.append('/usr/local/lib/python3.5/dist-packages')" in the begining for modern python libraries compatibility. [akliouev] +- After wrestling for a day finaly found out that "data" is a list and doesn't have method ".registers" associated with it. [akliouev] + Must be remnants of older pymodbus versions. Changed "data.registers" -> "data". [akliouev] +- Fix: line 403 was verifying that Username is "1" (only "read coil") and otherwise wasn't updating anything. [akliouev] + +v1.1.7 +- Removed debug option due to implementation of sensor type. [Sandolution] +- Added more options for data type (swapping of low/high byte/word). [Sandolution] +- Adjusted dividing settings to include 10000. [Sandolution] +- Added more append paths [Sandolution] + +v1.1.6 +- Added import RTU framer for RTU over TCP to work. [Sandolution] +- Fix for unit id on RTU over TCP [Sandolution] + +v1.1.5 +- Added ID option for IP/TCP addresses. [S. Ebeltjes] + +v1.1.4 +- Removed debug option due to implementation of sensor type. [Sandolution] +- Added more options for data type (swapping of low/high byte/word). [Sandolution] +- Adjusted dividing settings to include 10000. [Sandolution] + +TODO: float decode word orders +float AB CD == byteorder=Endian.Big, wordorder=Endian.Big +float CD AB == byteorder=Endian.Big, wordorder=Endian.Little +float BA DC == byteorder=Endian.Little, wordorder=Endian.Big +float DC BA == byteorder=Endian.Little, wordorder=Endian.Little diff --git a/modbus-read/plugin.py b/modbus-read/plugin.py index 1a855a6..e207657 100644 --- a/modbus-read/plugin.py +++ b/modbus-read/plugin.py @@ -1,6 +1,6 @@ -# Modbus RTU/ASCII/TCP - Universal READ Plugin for Domoticz +# Modbus RTU / ASCII / TCP/IP - Universal READ Plugin for Domoticz # -# Tested on domoticz 2020.2 with Python v3.7.3 and pymodbus v2.3.0 +# Tested on domoticz 2020.2 (stable) with Python v3.7.3 and pymodbus v2.3.0 # # Author: Sebastiaan Ebeltjes / DomoticX.nl # RTU Serial HW: USB RS485-Serial Stick, like https://webshop.domoticx.nl/index.php?route=product/search&search=RS485%20RTU%20USB @@ -11,20 +11,24 @@ # """ - + -

Modbus RTU/ASCII/TCP - READ

- With this plugin you can readout RS485 Modbus devices with methods RTU/ASCII/TCP
+

Modbus RTU / ASCII / TCP/IP - READ

+ With this plugin you can read from RS485 Modbus devices with methods RTU/ASCII/TCP

-

Functions of the READ plugin:

- Read Coil (Function 1)
- Read Discrete Input (Function 2)
- Read Holding Registers (Function 3)
- Read Input Registers (Function 4)
+

RTU

+ The serial binary communication protocol. It is the communication standard that
+ became widely used and all series of PLC's and other device producers support it.
+ It goes about the network protocol of the 1Master x nSlave type. The Slave devices can be 254 at the most.
+

ASCII

+ This protocol is similar to Modbus RTU, but the binary content is transformed to common ASCII characters.
+ It is not used as frequently as Modbus RTU.
+

RTU over TCP

+ Means a MODBUS RTU packet wrapped in a TCP packet. The message bytes are modified to add the 6 byte MBAP header and remove the two byte CRC. +

TCP/IP

+ It is a network protocol - classic Ethernet TCP/IP with the 10/100 Mbit/s speed rate, a standard net HW Ethernet card is sufficient.
+ The communication principle (1Master x nSlave) is the same as for Modbus RTU.

-

Supported data types:

- No conversion (passtrough) / BOOL / INT / UINT / FLOAT / STRING
-

Set-up and Configuration:

See wiki link above.
@@ -33,8 +37,8 @@ - + @@ -188,9 +192,12 @@ def onStart(self): Domoticz.Log("Modbus RTU/ASCII/TCP - Universal READ loaded!, using python v" + sys.version[:6] + " and pymodbus v" + pymodbus.__version__) # Dependancies notification - if (float(Parameters["DomoticzVersion"]) < float("2020.2")): Domoticz.Error("WARNING: Domoticz version is outdated/not supported, please update!") - if (float(sys.version[:1]) < 3): Domoticz.Error("WARNING: Python3 should be used!") - if (float(pymodbus.__version__[:3]) < float("2.3")): Domoticz.Error("WARNING: Pymodbus version is outdated, please update!") + try: + if (float(Parameters["DomoticzVersion"][:6]) < float("2020.2")): Domoticz.Error("WARNING: Domoticz version is outdated/not supported, please update!") + if (float(sys.version[:1]) < 3): Domoticz.Error("WARNING: Python3 should be used!") + if (float(pymodbus.__version__[:3]) < float("2.3")): Domoticz.Error("WARNING: Pymodbus version is outdated, please update!") + except: + Domoticz.Error("WARNING: Dependancies could not be checked!") ######################################## # READ-IN OPTIONS AND SETTINGS @@ -312,7 +319,7 @@ def onHeartbeat(self): Domoticz.Debug("MODBUS DEBUG - INTERFACE: Port="+self.Domoticz_Setting_Serial_Port+", BaudRate="+self.Domoticz_Setting_Baudrate+", StopBits="+str(self.StopBits)+", ByteSize="+str(self.ByteSize)+" Parity="+self.Parity) Domoticz.Debug("MODBUS DEBUG - SETTINGS: Method="+self.Domoticz_Setting_Communication_Mode+", Device ID="+self.Domoticz_Setting_Device_ID+", Register="+self.Domoticz_Setting_Register_Number+", Function="+self.Domoticz_Setting_Modbus_Function+", Data type="+self.Domoticz_Setting_Data_Type+", Pollrate="+self.Domoticz_Setting_Device_Pollrate) try: - client = ModbusSerialClient(method=self.Domoticz_Setting_Communication_Mode, port=self.Domoticz_Setting_Serial_Port, stopbits=self.StopBits, bytesize=self.ByteSize, parity=self.Parity, baudrate=int(self.Domoticz_Setting_Baudrate), timeout=1, retries=2) + client = ModbusSerialClient(method=self.Domoticz_Setting_Communication_Mode, port=self.Domoticz_Setting_Serial_Port, stopbits=self.StopBits, bytesize=self.ByteSize, parity=self.Parity, baudrate=int(self.Domoticz_Setting_Baudrate), timeout=2, retries=2) except: Domoticz.Error("Error opening Serial interface on "+self.Domoticz_Setting_Serial_Port) Devices[1].Update(1, "0") # Set value to 0 (error) @@ -324,7 +331,7 @@ def onHeartbeat(self): Domoticz.Debug("MODBUS DEBUG - INTERFACE: IP:Port="+self.Domoticz_Setting_TCP_IP+":"+self.Domoticz_Setting_TCP_PORT) Domoticz.Debug("MODBUS DEBUG - SETTINGS: Method="+self.Domoticz_Setting_Communication_Mode+", Device ID="+self.Domoticz_Setting_Device_ID+", Register="+self.Domoticz_Setting_Register_Number+", Function="+self.Domoticz_Setting_Modbus_Function+", Data type="+self.Domoticz_Setting_Data_Type+", Pollrate="+self.Domoticz_Setting_Device_Pollrate) try: - client = ModbusTcpClient(host=self.Domoticz_Setting_TCP_IP, port=int(self.Domoticz_Setting_TCP_PORT), framer=ModbusRtuFramer, auto_open=True, auto_close=True, timeout=5) + client = ModbusTcpClient(host=self.Domoticz_Setting_TCP_IP, port=int(self.Domoticz_Setting_TCP_PORT), framer=ModbusRtuFramer, auto_open=True, auto_close=True, timeout=2) except: Domoticz.Error("Error opening RTU over TCP interface on address: "+self.Domoticz_Setting_TCP_IPPORT) Devices[1].Update(1, "0") # Set value to 0 (error) @@ -336,7 +343,7 @@ def onHeartbeat(self): Domoticz.Debug("MODBUS DEBUG - INTERFACE: IP:Port="+self.Domoticz_Setting_TCP_IP+":"+self.Domoticz_Setting_TCP_PORT) Domoticz.Debug("MODBUS DEBUG - SETTINGS: Method="+self.Domoticz_Setting_Communication_Mode+", Device ID="+self.Domoticz_Setting_Device_ID+", Register="+self.Domoticz_Setting_Register_Number+", Function="+self.Domoticz_Setting_Modbus_Function+", Data type="+self.Domoticz_Setting_Data_Type+", Pollrate="+self.Domoticz_Setting_Device_Pollrate) try: - client = ModbusClient(host=self.Domoticz_Setting_TCP_IP, port=int(self.Domoticz_Setting_TCP_PORT), unit_id=int(self.Domoticz_Setting_Device_ID), auto_open=True, auto_close=True, timeout=5) + client = ModbusClient(host=self.Domoticz_Setting_TCP_IP, port=int(self.Domoticz_Setting_TCP_PORT), unit_id=int(self.Domoticz_Setting_Device_ID), auto_open=True, auto_close=True, timeout=2) except: Domoticz.Error("Error opening TCP/IP interface on address: "+self.Domoticz_Setting_TCP_IPPORT) Devices[1].Update(1, "0") # Set value to 0 (error) diff --git a/modbus-write/changelog.txt b/modbus-write/changelog.txt new file mode 100644 index 0000000..bc404ca --- /dev/null +++ b/modbus-write/changelog.txt @@ -0,0 +1,59 @@ +Modbus WRITE v2020.2C +- Fixed: Plugin not starting in unreleased beta versions (dependancies check) +- Improved: option and plugin descriptions +- Optimized: timeout on all methods set to 2 seconds. + +Modbus WRITE v2020.2B +- Added: proper plugin description + +Modbus WRITE v2020.2A +- Added: version checks and notification for needed dependancies +- Improved: TCP IP and PORT options now merged +- Improved: option descriptions, sorted options +- Optimized: Debug lines and info +- Optimized: All settings read once at plugin start +- Code cleanup + +v2.0.0 +- Fixed exception in modbus library (added .registers again) +- New plugin: modbus-device [bramvreugd] + - With this plugin you can add a device with many registers at once + +v1.2.1 +- Fixed the exception "Modbus Error: [Invalid Parameter] Invalid collection of registers supplied" on my Raspberry/Domoticz + +v1.2.0 +- Fixed TAB error. + +v1.1.9 +- Fixed debug output [Sandolution] + +v1.1.8 +- Added "sys.path.append('/usr/local/lib/python3.5/dist-packages')" in the begining for modern python libraries compatibility. [akliouev] +- After wrestling for a day finaly found out that "data" is a list and doesn't have method ".registers" associated with it. [akliouev] + Must be remnants of older pymodbus versions. Changed "data.registers" -> "data". [akliouev] +- Fix: line 403 was verifying that Username is "1" (only "read coil") and otherwise wasn't updating anything. [akliouev] + +v1.1.7 +- Removed debug option due to implementation of sensor type. [Sandolution] +- Added more options for data type (swapping of low/high byte/word). [Sandolution] +- Adjusted dividing settings to include 10000. [Sandolution] +- Added more append paths [Sandolution] + +v1.1.6 +- Added import RTU framer for RTU over TCP to work. [Sandolution] +- Fix for unit id on RTU over TCP [Sandolution] + +v1.1.5 +- Added ID option for IP/TCP addresses. [S. Ebeltjes] + +v1.1.4 +- Removed debug option due to implementation of sensor type. [Sandolution] +- Added more options for data type (swapping of low/high byte/word). [Sandolution] +- Adjusted dividing settings to include 10000. [Sandolution] + +TODO: float decode word orders +float AB CD == byteorder=Endian.Big, wordorder=Endian.Big +float CD AB == byteorder=Endian.Big, wordorder=Endian.Little +float BA DC == byteorder=Endian.Little, wordorder=Endian.Big +float DC BA == byteorder=Endian.Little, wordorder=Endian.Little diff --git a/modbus-write/plugin.py b/modbus-write/plugin.py index 8491bed..e4a2e14 100644 --- a/modbus-write/plugin.py +++ b/modbus-write/plugin.py @@ -1,6 +1,6 @@ -# Modbus RTU/ASCII/TCP - Universal WRITE Plugin for Domoticz +# Modbus RTU / ASCII / TCP/IP - Universal READ Plugin for Domoticz # -# Tested on domoticz 2020.2 with Python v3.7.3 and pymodbus v2.3.0 +# Tested on domoticz 2020.2 (stable) with Python v3.7.3 and pymodbus v2.3.0 # # Author: Sebastiaan Ebeltjes / DomoticX.nl # RTU Serial HW: USB RS485-Serial Stick, like https://webshop.domoticx.nl/index.php?route=product/search&search=RS485%20RTU%20USB @@ -11,21 +11,24 @@ # """ - + -

Modbus RTU/ASCII/TCP - WRITE

+

Modbus RTU / ASCII / TCP/IP - WRITE

With this plugin you can write to RS485 Modbus devices with methods RTU/ASCII/TCP

-

Functions of the WRITE plugin:

- Write Single Coil (Function 5)
- Write Single Holding Register (Function 6)
- Write Multiple Coils (Function 15)
- Write Registers (Function 16)
+

RTU

+ The serial binary communication protocol. It is the communication standard that
+ became widely used and all series of PLC's and other device producers support it.
+ It goes about the network protocol of the 1Master x nSlave type. The Slave devices can be 254 at the most.
+

ASCII

+ This protocol is similar to Modbus RTU, but the binary content is transformed to common ASCII characters.
+ It is not used as frequently as Modbus RTU.
+

RTU over TCP

+ Means a MODBUS RTU packet wrapped in a TCP packet. The message bytes are modified to add the 6 byte MBAP header and remove the two byte CRC. +

TCP/IP

+ It is a network protocol - classic Ethernet TCP/IP with the 10/100 Mbit/s speed rate, a standard net HW Ethernet card is sufficient.
+ The communication principle (1Master x nSlave) is the same as for Modbus RTU.

-

Typical payloads:

- HEX Payloads, like: 0x0100
- INT Payloads, like: 53
-

Set-up and Configuration:

See wiki link above.
@@ -34,8 +37,8 @@ - + @@ -111,9 +114,12 @@ def onStart(self): Domoticz.Log("Modbus RTU/ASCII/TCP - Universal WRITE loaded!, using python v" + sys.version[:6] + " and pymodbus v" + pymodbus.__version__) # Dependancies notification - if (float(Parameters["DomoticzVersion"]) < float("2020.2")): Domoticz.Error("WARNING: Domoticz version is outdated/not supported, please update!") - if (float(sys.version[:1]) < 3): Domoticz.Error("WARNING: Python3 should be used!") - if (float(pymodbus.__version__[:3]) < float("2.3")): Domoticz.Error("WARNING: Pymodbus version is outdated, please update!") + try: + if (float(Parameters["DomoticzVersion"][:6]) < float("2020.2")): Domoticz.Error("WARNING: Domoticz version is outdated/not supported, please update!") + if (float(sys.version[:1]) < 3): Domoticz.Error("WARNING: Python3 should be used!") + if (float(pymodbus.__version__[:3]) < float("2.3")): Domoticz.Error("WARNING: Pymodbus version is outdated, please update!") + except: + Domoticz.Error("WARNING: Dependancies could not be checked!") ######################################## # READ-IN OPTIONS AND SETTINGS @@ -188,7 +194,7 @@ def onCommand(self, Unit, Command, Level, Hue): Domoticz.Debug("MODBUS DEBUG - INTERFACE: Port="+self.Domoticz_Setting_Serial_Port+", BaudRate="+self.Domoticz_Setting_Baudrate+", StopBits="+str(self.StopBits)+", ByteSize="+str(self.ByteSize)+" Parity="+self.Parity) Domoticz.Debug("MODBUS DEBUG - SETTINGS: Method="+self.Domoticz_Setting_Communication_Mode+", Device ID="+self.Domoticz_Setting_Device_ID+", Register="+self.Domoticz_Setting_Register_Number+", Function="+self.Domoticz_Setting_Modbus_Function+", Payload="+payload) try: - client = ModbusSerialClient(method=self.Domoticz_Setting_Communication_Mode, port=self.Domoticz_Setting_Serial_Port, stopbits=self.StopBits, bytesize=self.ByteSize, parity=self.Parity, baudrate=int(self.Domoticz_Setting_Baudrate), timeout=1, retries=2) + client = ModbusSerialClient(method=self.Domoticz_Setting_Communication_Mode, port=self.Domoticz_Setting_Serial_Port, stopbits=self.StopBits, bytesize=self.ByteSize, parity=self.Parity, baudrate=int(self.Domoticz_Setting_Baudrate), timeout=2, retries=2) except: Domoticz.Error("Error opening Serial interface on "+self.Domoticz_Setting_Serial_Port) Devices[1].Update(1, "0") # Set value to 0 (error) @@ -200,7 +206,7 @@ def onCommand(self, Unit, Command, Level, Hue): Domoticz.Debug("MODBUS DEBUG - INTERFACE: IP:Port="+self.Domoticz_Setting_TCP_IP+":"+self.Domoticz_Setting_TCP_PORT) Domoticz.Debug("MODBUS DEBUG - SETTINGS: Method="+self.Domoticz_Setting_Communication_Mode+", Device ID="+self.Domoticz_Setting_Device_ID+", Register="+self.Domoticz_Setting_Register_Number+", Function="+self.Domoticz_Setting_Modbus_Function+", Payload="+payload) try: - client = ModbusTcpClient(host=self.Domoticz_Setting_TCP_IP, port=int(self.Domoticz_Setting_TCP_PORT), framer=ModbusRtuFramer, auto_open=True, auto_close=True, timeout=5) + client = ModbusTcpClient(host=self.Domoticz_Setting_TCP_IP, port=int(self.Domoticz_Setting_TCP_PORT), framer=ModbusRtuFramer, auto_open=True, auto_close=True, timeout=2) except: Domoticz.Error("Error opening RTU over TCP interface on address: "+self.Domoticz_Setting_TCP_IPPORT) Devices[1].Update(1, "0") # Set value to 0 (error) @@ -212,7 +218,7 @@ def onCommand(self, Unit, Command, Level, Hue): Domoticz.Debug("MODBUS DEBUG - INTERFACE: IP:Port="+self.Domoticz_Setting_TCP_IP+":"+self.Domoticz_Setting_TCP_PORT) Domoticz.Debug("MODBUS DEBUG - SETTINGS: Method="+self.Domoticz_Setting_Communication_Mode+", Device ID="+self.Domoticz_Setting_Device_ID+", Register="+self.Domoticz_Setting_Register_Number+", Function"+self.Domoticz_Setting_Modbus_Function+", Payload="+payload) try: - client = ModbusClient(host=self.Domoticz_Setting_TCP_IP, port=int(self.Domoticz_Setting_TCP_PORT), unit_id=int(self.Domoticz_Setting_Device_ID), auto_open=True, auto_close=True, timeout=5) + client = ModbusClient(host=self.Domoticz_Setting_TCP_IP, port=int(self.Domoticz_Setting_TCP_PORT), unit_id=int(self.Domoticz_Setting_Device_ID), auto_open=True, auto_close=True, timeout=2) except: Domoticz.Error("Error opening TCP/IP interface on address: "+self.Domoticz_Setting_TCP_IPPORT) Devices[1].Update(1, "0") # Set value to 0 (error)