Compare commits
2 Commits
8dd681bfb0
...
05dd708d3b
| Author | SHA1 | Date | |
|---|---|---|---|
| 05dd708d3b | |||
| edfb665a35 |
@ -58,9 +58,6 @@ To add the inverter, go to `Setup` -> `Hardware` and add the counter:
|
|||||||
- Select `DS238-2 D/ZN ModbusTCP` from the `type` dropdown list.
|
- Select `DS238-2 D/ZN ModbusTCP` from the `type` dropdown list.
|
||||||
- Enter the IP address of the PW21 in the `Inverter IP Address` field.
|
- Enter the IP address of the PW21 in the `Inverter IP Address` field.
|
||||||
- Enter the port number (default: 502) of the inverter in the `Inverter Port Number` field.
|
- Enter the port number (default: 502) of the inverter in the `Inverter Port Number` field.
|
||||||
- Select `Yes` in the `Add missing devices` to create the devices when the counter is added. Select `No` after deleting unwanted devices. Leaving the option set to `Yes` will recreate the deleted devices once Domoticz is restarted.
|
|
||||||
- Select an `Interval` (default: 10 seconds); this defines how often the plugin will collect the data from the counter. Short intervals will result in more accurate values and graphs, but also result in more network traffic and a higher workload for both Domoticz and the counter.
|
|
||||||
- Optionally change the `Log level`; this defaults to `Normal`. When selecting `Extra`, the plugin will print all the information it received from the counter in the log.
|
|
||||||
- Optionally turn on `Debug`; be aware: this will generate a lot of entries in the Domoticz log!
|
- Optionally turn on `Debug`; be aware: this will generate a lot of entries in the Domoticz log!
|
||||||
- `Add` the counter.
|
- `Add` the counter.
|
||||||
|
|
||||||
|
|||||||
125
plugin.py
125
plugin.py
@ -7,7 +7,7 @@ Requirements:
|
|||||||
2. pymodbus AND pymodbusTCP
|
2. pymodbus AND pymodbusTCP
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
<plugin key="DS238_ModbusTCP" name="DS238-2 D/ZN ModbusTCP" author="Xavier Beaudouin" version="0.0.1" externallink="https://github.com/xbeaudouin/domoticz-ds238-modbus-tcp">
|
<plugin key="DS238_ModbusTCP" name="DS238-2 ZN/S ModbusTCP" author="Xavier Beaudouin" version="0.0.1" externallink="https://github.com/xbeaudouin/domoticz-ds238-modbus-tcp">
|
||||||
<params>
|
<params>
|
||||||
<param field="Address" label="IP Address" width="150px" required="true" />
|
<param field="Address" label="IP Address" width="150px" required="true" />
|
||||||
<param field="Port" label="Port Number" width="100px" required="true" default="502" />
|
<param field="Port" label="Port Number" width="100px" required="true" default="502" />
|
||||||
@ -72,12 +72,14 @@ class BasePlugin:
|
|||||||
|
|
||||||
# Create the devices if they does not exists
|
# Create the devices if they does not exists
|
||||||
if 1 not in Devices:
|
if 1 not in Devices:
|
||||||
Domoticz.Device(Name="Total Energy", Unit=1, Type=0x71, Subtype=0x0, Used=0).Create()
|
#Domoticz.Device(Name="Total Energy", Unit=1, Type=0x71, Subtype=0x0, Used=0).Create()
|
||||||
# Voir 0x107 / 0x30 ?
|
Domoticz.Device(Name="Total Energy", Unit=1, Type=248, Subtype=33, Used=0).Create()
|
||||||
if 2 not in Devices:
|
if 2 not in Devices:
|
||||||
Domoticz.Device(Name="Export Energy", Unit=2, Type=0x71, Subtype=0x0, Used=0).Create()
|
#Domoticz.Device(Name="Export Energy", Unit=2, Type=0x71, Subtype=0x0, Used=0).Create()
|
||||||
|
Domoticz.Device(Name="Export Energy", Unit=2, Type=248, Subtype=33, Used=0).Create()
|
||||||
if 3 not in Devices:
|
if 3 not in Devices:
|
||||||
Domoticz.Device(Name="Import Energy", Unit=3, Type=0x71, Subtype=0x0, Used=0).Create()
|
#Domoticz.Device(Name="Import Energy", Unit=3, Type=0x71, Subtype=0x0, Used=0).Create()
|
||||||
|
Domoticz.Device(Name="Import Energy", Unit=3, Type=248, Subtype=33, Used=0).Create()
|
||||||
if 4 not in Devices:
|
if 4 not in Devices:
|
||||||
Domoticz.Device(Name="Voltage", Unit=4, TypeName="Voltage", Used=0).Create()
|
Domoticz.Device(Name="Voltage", Unit=4, TypeName="Voltage", Used=0).Create()
|
||||||
if 5 not in Devices:
|
if 5 not in Devices:
|
||||||
@ -95,12 +97,15 @@ class BasePlugin:
|
|||||||
Options = { "Custom": "1;Hz" }
|
Options = { "Custom": "1;Hz" }
|
||||||
Domoticz.Device(Name="Frequency", Unit=9, TypeName="Custom", Used=0, Options=Options).Create()
|
Domoticz.Device(Name="Frequency", Unit=9, TypeName="Custom", Used=0, Options=Options).Create()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def onStop(self):
|
def onStop(self):
|
||||||
Domoticz.Log("onStop called")
|
Domoticz.Log("onStop called")
|
||||||
|
|
||||||
def onConnect(self, Connection, Status, Description):
|
def onConnect(self, Connection, Status, Description):
|
||||||
Domoticz.Log("onConnect called")
|
Domoticz.Log("onConnect called")
|
||||||
|
return
|
||||||
|
|
||||||
def onMessage(self, Connection, Data):
|
def onMessage(self, Connection, Data):
|
||||||
Domoticz.Log("onMessage called")
|
Domoticz.Log("onMessage called")
|
||||||
@ -131,6 +136,116 @@ class BasePlugin:
|
|||||||
Devices[8].Update(1, "0")
|
Devices[8].Update(1, "0")
|
||||||
Devices[9].Update(1, "0")
|
Devices[9].Update(1, "0")
|
||||||
|
|
||||||
|
# Total Energy
|
||||||
|
data = client.read_holding_registers(0, 2)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 32
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_32bit_int()
|
||||||
|
# Scale factor / 100
|
||||||
|
value = str ( round (value / 100, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[1].Update(1, value)
|
||||||
|
|
||||||
|
# Export Energy
|
||||||
|
data = client.read_holding_registers(0x8, 2)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 32
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_32bit_int()
|
||||||
|
# Scale factor / 100
|
||||||
|
value = str ( round (value / 100, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[2].Update(1, value)
|
||||||
|
|
||||||
|
# Import Energy
|
||||||
|
data = client.read_holding_registers(0xA, 2)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 32
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_32bit_int()
|
||||||
|
# Scale factor / 100
|
||||||
|
value = str ( round (value / 100, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[3].Update(1, value)
|
||||||
|
|
||||||
|
# Voltage
|
||||||
|
data = client.read_holding_registers(0xC, 1)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 16
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_16bit_int()
|
||||||
|
# Scale factor / 10
|
||||||
|
value = str ( round (value / 10, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[4].Update(1, value)
|
||||||
|
|
||||||
|
# Current
|
||||||
|
data = client.read_holding_registers(0xD, 1)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 16
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_16bit_int()
|
||||||
|
# Scale factor / 100
|
||||||
|
value = str ( round (value / 100, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[5].Update(1, value)
|
||||||
|
|
||||||
|
# Active Power
|
||||||
|
data = client.read_holding_registers(0xE, 1)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 16
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_16bit_int()
|
||||||
|
# Scale factor / 100
|
||||||
|
#value = str ( round (value / 100, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[6].Update(1, str(value))
|
||||||
|
|
||||||
|
# Reactive Power
|
||||||
|
data = client.read_holding_registers(0xF, 1)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 16
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_16bit_int()
|
||||||
|
# Scale factor / 100
|
||||||
|
#value = str ( round (value / 100, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[7].Update(1, str(value))
|
||||||
|
|
||||||
|
# Power Factor
|
||||||
|
data = client.read_holding_registers(0x10, 1)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 16
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_16bit_int()
|
||||||
|
# Scale factor / 1000
|
||||||
|
value = str ( round (value / 1000, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[8].Update(1, value)
|
||||||
|
|
||||||
|
# Frequency
|
||||||
|
data = client.read_holding_registers(0x11, 1)
|
||||||
|
Domoticz.Debug("Data from register 0: "+str(data))
|
||||||
|
# Unsigned 16
|
||||||
|
decoder = BinaryPayloadDecoder.fromRegisters(data, byteorder=Endian.Big, wordorder=Endian.Big)
|
||||||
|
# Value
|
||||||
|
value = decoder.decode_16bit_int()
|
||||||
|
# Scale factor / 100
|
||||||
|
value = str ( round (value / 100, 3))
|
||||||
|
Domoticz.Debug("Value after conversion : "+str(value))
|
||||||
|
Devices[9].Update(1, value)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
global _plugin
|
global _plugin
|
||||||
_plugin = BasePlugin()
|
_plugin = BasePlugin()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user