Python plugin: Modbus RTU / ASCII / TCP/IP Topic is solved

Python and python framework

Moderator: leecollings

simat
Posts: 33
Joined: Thursday 04 November 2021 21:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by simat »

marcin81233 wrote: Sunday 11 June 2023 12:33
simat wrote: Sunday 07 May 2023 9:57 Is your inverter Modbus RTU or Modbus TCP ?

Someone suggested that the Deye Inverter is the same as Sol-Ark ?



Either way the Modbus RTU/ASCI/TCP plugin mentioned in this thread should do the trick without modification, you just need to know the modbus slave ID, register address and data type for starters.
I'm a novice in such matters. Could you write what I should enter in the appropriate fields in domoticz from this frame?
Looking at your easy to read pdf, try 053 in the register box, and the modbus ID and rate in the ID:PollingRate box.
Raspberry Pi4, Sunny Boy 4000TL, Victron Multiplus II 10kw ESS, 44kWh LiFEPO4, Batrium BMS, NodeRED on Cerbo GX
simat
Posts: 33
Joined: Thursday 04 November 2021 21:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by simat »

PieterS wrote: Tuesday 04 July 2023 21:38
Alain wrote: Saturday 08 April 2023 8:59 Yes, 2021.1 was the last working version. I had the above issues too and although I looked into it to try and find out why this was happening, I just decided to run a 2021.1 version of Domoticz. In my case this is possible because I run this plugin on a dedicated remote server. It doesn't influence the running of any other plugins of which you want the latest versions.
I investigate the posibility of buying a kWh-meter with Modbus. Especialy a Eastron SDM 630 V2. Goal is to read how much energy is loaded into my EV. But reading this thread it seems not that easy with Domoticz.

@Alain:
Can you explain how you configure it to run the plugin on a remote server?
How do you export the results of the measurements to Domoticz?

I am very interested. Thanks in advance.

https://www.domoticz.com/wiki/Setting_up_Device_sharing
Raspberry Pi4, Sunny Boy 4000TL, Victron Multiplus II 10kw ESS, 44kWh LiFEPO4, Batrium BMS, NodeRED on Cerbo GX
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

@Simat: Thanks for the hint.

I am familiar with the Master/Slave principle. I used it before. Master on the Syno in a virtual machine (Docker) and the slave on a Pi. I did not think of this solution, but it might work! :o

Studied your link to the Wiki. But there is one restriction in there:

You have, for example, 3 machines or controllers or RaspberryPis with Domoticz. All software should be at the latest version and all main and remotes must be running the same version.

I read Alain used an older version for running the Python-script because the latest version of Domoticz is running scripts simultaniously. But I will try it. With different versions.. Maybe it does the job. Thanks!
Synology with Domoticz build (V2024.7) in Docker
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

Hi Domoberry,

Lots of information and as I read about what data the DDS024MR exposes, it should be sufficient for me. But I didn't found a shop in the Netherlands where I can buy one. I will not buy such a kWh-meter in cheap countries for my own safety.

Do you think your version is working on the Eastron SDM630 V2 or any other meter with a Modbus-interface?

Read your link https://github.com/domoticz/domoticz/issues/5671 and maybe the suggestion of simat to use a master/slave workaround will do the job for me.

Thanks for your help anyway.
Synology with Domoticz build (V2024.7) in Docker
User avatar
Domoberry
Posts: 116
Joined: Tuesday 30 May 2017 19:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Domoberry »

Hi PieterS,
My plugin will not work out-of-the-box with the SDM630. However, since my plugin was forked from the SDM630, it should be possible by updating some parameters. However, Mr. Murphy typically exists in these cases.
You would need to compare both plugins; they have the same structure. A quick scan on the key differences: different default Modbus slave address, different parity, different register addresses for the various parameters. Updating the latter two requires some value changes in the plugin itself. Next to that, there are obviously several textual references to 'DDS024MR'. Perhaps it is easier to revive the SDM630 plugin.
Alternatively, the plugin from DomoticX is likely to work, but you will only be able to retrieve one value without any changes to the plugin.
simat
Posts: 33
Joined: Thursday 04 November 2021 21:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by simat »

What about using something like ESPEasy to post straight into Domoticz

and btw, the plugin I published had been updated to handle the parallel running of multiple scripts in the later versions of Domoticz to avoid comms problems. Although if you only have one Modbus device you'll have no problems as there won't be multiple calls.
Raspberry Pi4, Sunny Boy 4000TL, Victron Multiplus II 10kw ESS, 44kWh LiFEPO4, Batrium BMS, NodeRED on Cerbo GX
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

simat wrote: Thursday 06 July 2023 9:40 What about using something like ESPEasy to post straight into Domoticz

and btw, the plugin I published had been updated to handle the parallel running of multiple scripts in the later versions of Domoticz to avoid comms problems. Although if you only have one Modbus device you'll have no problems as there won't be multiple calls.
Thanks for your additional info! I will have one Modbus device. But what if I use a three fase kWh-meter like the Eastron SDM630 instead of your single fase?

I will keep the way of ESPEasy in mind. Ik use that method for reading my gasmeter and PV. But they read just S0-pulses in my case.
Synology with Domoticz build (V2024.7) in Docker
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

Domoberry wrote: Wednesday 05 July 2023 22:57 Hi PieterS,
My plugin will not work out-of-the-box with the SDM630. However, since my plugin was forked from the SDM630, it should be possible by updating some parameters. However, Mr. Murphy typically exists in these cases.
You would need to compare both plugins; they have the same structure. A quick scan on the key differences: different default Modbus slave address, different parity, different register addresses for the various parameters. Updating the latter two requires some value changes in the plugin itself. Next to that, there are obviously several textual references to 'DDS024MR'. Perhaps it is easier to revive the SDM630 plugin.
Alternatively, the plugin from DomoticX is likely to work, but you will only be able to retrieve one value without any changes to the plugin.
Thanks for adding more info. I will think about it.

Regards
Synology with Domoticz build (V2024.7) in Docker
marcin81233
Posts: 3
Joined: Saturday 06 May 2023 20:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by marcin81233 »

Po dodaniu 4 czujnika zaczyna zgłaszać błędy.
Aziona
Posts: 9
Joined: Monday 04 March 2019 14:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by Aziona »

I use the plugin with and Eastron SDM220 kwh meter. The value of the total active energy is 52520.4765625 Kwh but it shows as "0, 52520.4765625". How can I remove the "0, " from the value? I tried all data types but nothing seems to work.

RTU/9600/1/8/N
Register number 74
Data Type FLOAT 32-bit

It might be the ByteSize but changing that does not work.
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

simat wrote: Monday 24 April 2023 21:11 Updated and tested plugin now available on

https://github.com/simat-git/SDM120-Modbus

Works with Domoticz 2023.1, now just takes a few minutes to initially allocate each instance to its own timeslot, will also recover from bus disconnection and re-time itself. The previous plugin would error until manual intervention / reset.
@simat:
I bought a SDM630-Modbus V2 together with a USB to RS485 Adapter - CH340 and installed your SDM120-Modbus software on a Raspberry Pi 4 - 4GB. The OS: Raspbian GNU/Linux 11 (bullseye), Python 3.9.2.

On the Py I installed Domoticz Version: 2023.2 (build 15459)

In Hardware I selected the
Modbus Port: /dev/ttyUSB0
Baud rate: 9600
Device ID: 1
Reading Interval min: 1
Debug: True

This is part of the log:

Code: Select all

 2023-07-23 22:51:32.326 Status: SDM120-Modbus Simat: Entering work loop.
2023-07-23 22:51:32.326 Status: SDM120-Modbus Simat: Started.
2023-07-23 22:51:32.499 Status: SDM120-Modbus Simat: Initialized version 2, author 'simat-git'
2023-07-23 22:58:42.394 SDM120-Modbus Simat: Total kwh: 52.264 kWh
2023-07-23 22:58:42.395 SDM120-Modbus Simat: Voltage: 228.340 V
2023-07-23 22:58:42.395 SDM120-Modbus Simat: Import power: 0.000 W
2023-07-23 22:58:42.395 SDM120-Modbus Simat: Export power: 0.000 W
2023-07-23 22:59:42.412 SDM120-Modbus Simat: SDM120M Modbus Data
2023-07-23 22:59:42.412 SDM120-Modbus Simat: Total system power: 0.000 W
2023-07-23 22:59:42.412 SDM120-Modbus Simat: Import Wh: 0.000 kWh
2023-07-23 22:59:42.412 SDM120-Modbus Simat: Export Wh: 52.264 kWh
2023-07-23 22:59:42.412 SDM120-Modbus Simat: Total kwh: 52.264 kWh
2023-07-23 22:59:42.412 SDM120-Modbus Simat: Voltage: 228.530 V 
The results are hopefull because a part the output of the meter to Domoticz is the same as on the display of the meter. And no errors at all!

When I start loading the EV the information is updated in Domoticz. But it is only a small part of all the results the meter is calculating.

The SDM630 is a 3-fase meter and now I only get the total value and the Voltage of L1.. Should be nice to get all info from the meter.

Can you explain how to edit the file(s) to get all output from the SDM630 to Domoticz?

Thanks in advance. Best regards,
Pieter
Synology with Domoticz build (V2024.7) in Docker
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

As I own a SDM630 Modbus 3Fase-meter I wanted to extend the SDM120-plugin from @simat with some values. A lot of trial and error... But there is some progress.. 8-)

Code: Select all

  2023-07-24 17:19:32.487 SDM630: Worker thread started.
2023-07-24 17:19:32.670 SDM630: SDM120M Modbus plugin start
2023-07-24 17:19:32.487 Status: SDM630: Entering work loop.
2023-07-24 17:19:32.487 Status: SDM630: Started.
2023-07-24 17:19:32.667 Status: SDM630: Initialized version 2, author 'simat-git'
2023-07-24 17:19:42.667 SDM630: SDM630 Modbus Data
2023-07-24 17:19:42.667 SDM630: Total system power: -1150.726 W
2023-07-24 17:19:42.667 SDM630: Import Wh: 0.000 kWh
2023-07-24 17:19:42.667 SDM630: Export Wh: 56.092 kWh
2023-07-24 17:19:42.667 SDM630: Total kwh: 56.092 kWh
2023-07-24 17:19:42.667 SDM630: Import power: 0.000 W
2023-07-24 17:19:42.667 SDM630: Export power: 0.000 W
2023-07-24 17:19:42.667 SDM630: Voltage L1: 230.010 V
2023-07-24 17:19:42.667 SDM630: Voltage L2: 228.774 V
2023-07-24 17:19:42.667 SDM630: Voltage L3: 229.036 V
2023-07-24 17:19:42.667 SDM630: Current L1: 5.005 A
2023-07-24 17:19:42.667 SDM630: Current L2: 4.985 A
2023-07-24 17:19:42.667 SDM630: Current L3: 4.983 A 
I keep you informed.
Synology with Domoticz build (V2024.7) in Docker
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

A small update...
As I am a noob with Python language.. I got lost about the command

Code: Select all

Devices[2].Update(0,str(Total_kWh))
Environment:
SDM630-Modbus V2 together with a USB to RS485 Adapter - CH340
I changed the SDM120-Modbus software
Raspberry Pi 4 - 4GB.
OS: Raspbian GNU/Linux 11 (bullseye)
Python 3.9.2.
Domoticz Version: 2023.2 (build 15459)

I prefer in the GUI a device with the type of Managed Counter. Or General, kWh. It should show a bar for every different day. A line graph is less readable...
But not the results I expected.
So I tried 3 different sort of devices from the list in the Wiki: https://www.domoticz.com/wiki/Developin ... vice_Types

But not always input from the plugin to the devic in Domoticz :roll:
Image

Image

The device with IDX 1, SubType kWh, is updated but has no data in graph.
The device with IDX 2, custom sensor, is updated and had data in graph.
The device with IDX 3, Managed Counter, is not updated


This is my script: Original authors still readable ;)

Code: Select all

#!/usr/bin/env python
"""
Eastron SDM120-Modbus Smart Meter Single Phase Electrical System. The Python plugin for Domoticz
Original Author: MFxMF and bbossink and remcovanvugt
Better Error handling and event recovery added by simat-git 2023.

Edited by PieterS for Eastron SDM630

Works with Eastron SDM120M / SDM120CT-M, can be easily adapted to any Modbus meter.

Requirements: 
    1.python module minimalmodbus -> http://minimalmodbus.readthedocs.io/en/master/
        (pi@raspberrypi:~$ sudo pip3 install minimalmodbus)
    2.Communication module Modbus USB to RS485 converter module
"""
"""
<plugin key="SDM630-Pieter" name="SDM630" version="2" author="simat-git">
    <params>
        <param field="SerialPort" label="Modbus Port" width="200px" required="true" default="/dev/ttyUSB0" />
        <param field="Mode1" label="Baud rate" width="40px" required="true" default="9600"  />
        <param field="Mode2" label="Device ID" width="40px" required="true" default="1" />
        <param field="Mode3" label="Reading Interval min." width="40px" required="true" default="1" />
        <param field="Mode6" label="Debug" width="75px">
            <options>
                <option label="True" value="Debug"/>
                <option label="False" value="Normal"  default="true" />
            </options>
        </param>
    </params>
</plugin>
"""

import minimalmodbus    #v2.0.1
#import serial          #minimalmodbus imports this now.
import Domoticz         #tested on Python 3.9.2 in Domoticz 2023.2


class BasePlugin:
    def __init__(self):
        self.runInterval = 1
        self.rs485 = "" 
        return

    def onStart(self):
        
        devicecreated = []
        Domoticz.Log("SDM630 Pieter plugin start")
        self.runInterval = int(Parameters["Mode3"]) * 1 
        

        if 2 not in Devices:
            Domoticz.Device(Name="Total kWh Unit2", Unit=2,TypeName="General",Subtype=29,Used=0).Create()  #Subtype Name:kWh, TypeName:kWh, Electric (Instant+Counter)
        Options = { "Custom" : "1;kWh"}
        if 3 not in Devices:
            Domoticz.Device(Name="Total kWh Unit3", Unit=3,TypeName="Custom",Used=0,Options=Options).Create()
        Options = { "Custom" : "1;kVArh"} 
        if 4 not in Devices:
            Domoticz.Device(Name="Total kWh Unit4", Unit=4,TypeName="General",Subtype=33,Used=0).Create()


    def onStop(self):
        Domoticz.Log("SDM630 plugin stop")

    def onHeartbeat(self):
        self.runInterval -=1;
        if self.runInterval <= 0:
        
            Total_System_Power = 0  #  Declare these to keep the debug section at the bottom from complaining. 1
            Import_Wh = 0                                          # Var 2
#            Export_Wh = 0                                          # Var 3
            Total_kWh = 0   #Fix door Pieter: kwh naar kWh    Var 4
			
            # Get data from SDM630
            try:
                 self.rs485 = minimalmodbus.Instrument(Parameters["SerialPort"], int(Parameters["Mode2"]))
                 #class minimalmodbus.Instrument(port: str, slaveaddress: int, mode: str = 'rtu', close_port_after_each_call: bool = False, debug: bool = False)
                 self.rs485.serial.baudrate = Parameters["Mode1"]
                 self.rs485.serial.bytesize = 8
                 self.rs485.serial.parity = minimalmodbus.serial.PARITY_NONE
                 self.rs485.serial.stopbits = 1
                 self.rs485.serial.timeout = 1
                 self.rs485.serial.exclusive = True # Fix From Forum Member 'lost'
                 self.rs485.debug = False
                            
                 self.rs485.mode = minimalmodbus.MODE_RTU
                 self.rs485.close_port_after_each_call = True
                 
                 Total_kWh = self.rs485.read_float(342, 4, 2)    
                 #self.rs485.read_float(register, functioncode, numberOfRegisters)
                 self.rs485.serial.close()  #  Close that door !
            except:
                Domoticz.Heartbeat(1)   # set Heartbeat to 1 second to get us back here for quick retry.
                self.runInterval = 1    # call again in 1 second
                Domoticz.Log("**** SDM120M Connection problem ****");
            else:
                #Update devices
                Devices[2].Update(0,str(Total_kWh))
                Devices[3].Update(0,str(Total_kWh))
                Devices[4].Update(0,str(Total_kWh))
                self.runInterval = int(Parameters["Mode3"]) * 6 # Success so call again in 60 seconds.
                Domoticz.Heartbeat(10)  # Sucesss so set Heartbeat to 10 second intervals.


            if Parameters["Mode6"] == 'Debug':
                Domoticz.Log("SDM630 Modbus Data")
                Domoticz.Log('Total kWh: {0:.3f} kWh'.format(Total_kWh))
            #self.runInterval = int(Parameters["Mode3"]) * 6

global _plugin
_plugin = BasePlugin()


def onStart():
    global _plugin
    _plugin.onStart()


def onStop():
    global _plugin
    _plugin.onStop()


def onHeartbeat():
    global _plugin
    _plugin.onHeartbeat()

# Generic helper functions
def DumpConfigToLog():
    for x in Parameters:
        if Parameters[x] != "":
            Domoticz.Debug("'" + x + "':'" + str(Parameters[x]) + "'")
    Domoticz.Debug("Device count: " + str(len(Devices)))
    for x in Devices:
        Domoticz.Debug("Device:           " + str(x) + " - " + str(Devices[x]))
        Domoticz.Debug("Device ID:       '" + str(Devices[x].ID) + "'")
        Domoticz.Debug("Device Name:     '" + Devices[x].Name + "'")
        Domoticz.Debug("Device nValue:    " + str(Devices[x].nValue))
        Domoticz.Debug("Device sValue:   '" + Devices[x].sValue + "'")
        Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
    return
In my opinion it has to do with the command

#Update devices
Devices[2].Update(0,str(Total_kWh))
Devices[3].Update(0,str(Total_kWh))
Devices[4].Update(0,str(Total_kWh))


I do not understand what is wrong. :oops: 3 different devicetypes, 1 command should do the job? No errors in the logfile of Domoticz.

Code: Select all

 2023-07-27 12:27:00.495 SDM630: Worker thread started.
2023-07-27 12:27:00.682 SDM630: SDM630 Pieter plugin start
2023-07-27 12:27:00.495 Status: SDM630: Entering work loop.
2023-07-27 12:27:00.495 Status: SDM630: Started.
2023-07-27 12:27:00.680 Status: SDM630: Initialized version 3, author 'PieterS'
2023-07-27 12:27:10.168 SDM630: SDM630 Modbus Data
2023-07-27 12:27:10.168 SDM630: Total kWh: 81.025 kWh
2023-07-27 12:28:10.160 SDM630: SDM630 Modbus Data
2023-07-27 12:28:10.160 SDM630: Total kWh: 81.083 kWh
2023-07-27 12:29:10.156 SDM630: SDM630 Modbus Data
2023-07-27 12:29:10.156 SDM630: Total kWh: 81.142 kWh
2023-07-27 12:30:10.149 SDM630: SDM630 Modbus Data
2023-07-27 12:30:10.149 SDM630: Total kWh: 81.201 kWh
2023-07-27 12:31:10.145 SDM630: SDM630 Modbus Data
2023-07-27 12:31:10.145 SDM630: Total kWh: 81.258 kWh 
Any help appreciated. Did not find info on the wiki about the syntax how update a device.. :oops:

Thnx in advance!
Synology with Domoticz build (V2024.7) in Docker
simat
Posts: 33
Joined: Thursday 04 November 2021 21:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by simat »

@Pieter, did you get your SDM630 working ?
Raspberry Pi4, Sunny Boy 4000TL, Victron Multiplus II 10kw ESS, 44kWh LiFEPO4, Batrium BMS, NodeRED on Cerbo GX
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

simat wrote: Monday 14 August 2023 11:44 @Pieter, did you get your SDM630 working ?
Some devices yes. But strugling with how to get the right graphics for energy. I want bars, no lines. No idea how to create a virtual device RFXMeter with RFXMeter counter. :?
But that's for next weekend.
Synology with Domoticz build (V2024.7) in Docker
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by waltervl »

PieterS wrote: Tuesday 15 August 2023 9:04
simat wrote: Monday 14 August 2023 11:44 @Pieter, did you get your SDM630 working ?
Some devices yes. But strugling with how to get the right graphics for energy. I want bars, no lines. No idea how to create a virtual device RFXMeter with RFXMeter counter. :?
But that's for next weekend.
Check https://www.domoticz.com/wiki/Dummy_for ... es#Counter

But better to use Electricity (instant and counter) https://www.domoticz.com/wiki/Dummy_for ... counter.29
Watts (usage) are reported in lines, Wh or kWh (used or generated energy) are reported in bars. No way to change this.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
simat
Posts: 33
Joined: Thursday 04 November 2021 21:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by simat »

In my plugin, its the line

Devices[2].Update(0,str(Total_System_Power)+";"+str(Import_Wh*1000))

That puts 2 values to display, the kWh and the current Watts load.

Total_kWh = self.rs485.read_float(342, 4, 2) is only going to pull out the kWh reading and not the current load. Sorry i didn't have time to read the whole post, is that what you where after ?
Raspberry Pi4, Sunny Boy 4000TL, Victron Multiplus II 10kw ESS, 44kWh LiFEPO4, Batrium BMS, NodeRED on Cerbo GX
simat
Posts: 33
Joined: Thursday 04 November 2021 21:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: UK
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by simat »

Like this ?

Its type 243 - Domoticz.Device(Name="Import Wh", Unit=2,Type=243,Subtype=29,Used=0).Create()
Attachments
Screenshot 2023-08-15 084930.jpg
Screenshot 2023-08-15 084930.jpg (110.11 KiB) Viewed 2120 times
Screenshot 2023-08-15 084829.jpg
Screenshot 2023-08-15 084829.jpg (33.65 KiB) Viewed 2121 times
Raspberry Pi4, Sunny Boy 4000TL, Victron Multiplus II 10kw ESS, 44kWh LiFEPO4, Batrium BMS, NodeRED on Cerbo GX
PieterS
Posts: 195
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by PieterS »

[/quote]
Check https://www.domoticz.com/wiki/Dummy_for ... es#Counter

But better to use Electricity (instant and counter) https://www.domoticz.com/wiki/Dummy_for ... counter.29
Watts (usage) are reported in lines, Wh or kWh (used or generated energy) are reported in bars. No way to change this.
[/quote]
@waltervl: thanks for hint.
I checked and created a new virtual device you suggested (Instant and Counter). But that has no indicator of measurement in the top. Did I do something wrong?
Second case:
I want to send data by MQTT to that virtual device. It arrives, but it does not seem to represented..

This is the info that passes by in MQTT Explorer:

Code: Select all

{"command":"udevice","idx":76,"nvalue":0,"svalue":"152.36"}
This is in Domoticz..
Image
Image

Running Domoticz Build 15459..

Any idea what's wrong?
Synology with Domoticz build (V2024.7) in Docker
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python plugin: Modbus RTU / ASCII / TCP/IP

Post by waltervl »

It needs 2 sValues: POWER;ENERGY
POWER = current power (Watt)
ENERGY = total (lifetime) cumulative energy counter in Watt-hours (Wh).

Code: Select all

{"command":"udevice","idx":76,"nvalue":0,"svalue":"152;12345678"}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest