SML 1.04 ir adapter for DTZ-541 Stromzaehler

Moderator: leecollings

sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by sailmich »

FireWizard wrote: Tuesday 08 February 2022 15:24 Hello @ sailmich,

You might want to look at Node-RED. You can load the module: https://flows.nodered.org/node/node-red ... smartmeter
This smart-meter module is based on library: https://github.com/Apollon77/smartmeter-obis

If you read its README file you will see:
Supported Protocols:

SmlProtocol: SML (SmartMeterLanguage) as binary format
D0Protocol: D0 (based on IEC 62056-21:2002/IEC 61107/EN 61107) as ASCII format (binary protocol mode E not supported currently)
JsonEfrProtocol: OBIS data from EFR Smart Grid Hub (JSON format)
Try, if you can collect the data from your device in Node-RED. If so, it's quite easy to send the data to a virtual device in Domoticz by means of MQTT.

Regards
Hello FireWizard, now I got the values by using node red smartmeter but can't get the value to domoticz device :(.
Bildschirmfoto vom 2022-02-17 21-46-42.png
Bildschirmfoto vom 2022-02-17 21-46-42.png (18.33 KiB) Viewed 809 times

Code: Select all

[
    {
        "id": "72105072cc08744b",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "64a326b844326555",
        "type": "smartmeter",
        "z": "72105072cc08744b",
        "name": "",
        "datasource": "34d070e3e0bdda8b",
        "protocol": "SmlProtocol",
        "transport": "SerialRequestResponseTransport",
        "requestInterval": "0",
        "d0WakeupCharacters": "",
        "d0SignOnMessage": "",
        "d0BaudrateChangeoverOverwrite": "",
        "protocolSmlIgnoreInvalidCRC": false,
        "debugging": false,
        "x": 210,
        "y": 180,
        "wires": [
            [
                "d1759b9d40dccb60",
                "1e2fe4a524777dbe"
            ]
        ]
    },
    {
        "id": "1e2fe4a524777dbe",
        "type": "debug",
        "z": "72105072cc08744b",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 650,
        "y": 280,
        "wires": []
    },
    {
        "id": "1749491eac06311b",
        "type": "function",
        "z": "72105072cc08744b",
        "name": "",
        "func": "var newMsg1 = {payload: msg.payload[\"1-0:1.8.0*255\"].values[0].value };\nvar newMsg2 = {payload: msg.payload[\"1-0:16.7.0*255\"].values[0].value };\nreturn [[newMsg1,newMsg2]];\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 380,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "d1759b9d40dccb60",
        "type": "function",
        "z": "72105072cc08744b",
        "name": "",
        "func": "msg.payload = { \"command\": \"udevice\", \"idx\": 494, \"nvalue\": 0, \"svalue\": msg.payload[\"1-0:16.7.0*255\"].values[0].value};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 180,
        "wires": [
            [
                "1e2fe4a524777dbe",
                "9cb5ca45c95b831d"
            ]
        ]
    },
    {
        "id": "9cb5ca45c95b831d",
        "type": "mqtt out",
        "z": "72105072cc08744b",
        "name": "",
        "topic": "domoticz/in",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "f9f13036.e28b58",
        "x": 650,
        "y": 100,
        "wires": []
    },
    {
        "id": "34d070e3e0bdda8b",
        "type": "smartmeter-connection",
        "sourcetype": "serial",
        "serialport": "/dev/ttyUSB0",
        "serialbaud": "9600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "httphost": "localhost",
        "httpport": "80",
        "tcphost": "localhost",
        "tcpport": "502",
        "filepath": "/dev/null"
    },
    {
        "id": "f9f13036.e28b58",
        "type": "mqtt-broker",
        "name": "localhost",
        "broker": "127.0.0.1",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]
I do not understand why the device will not updated :( again I would appreciate your help.
Cheers
User avatar
FireWizard
Posts: 1893
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by FireWizard »

Hello @sailmich

The first screenshot (of the Debug pane) is not fully opened.Click on the arrow in front of { and all the subsequent arrows.
So I cannot check the full path.

However I see one thing that will prevent updating the sensor.
"svalue" has always to be a string (therefore svalue), compared to nvalue, which always should be a numerical value.
You can see, that 627 is a number (blue value) and not a string ("627" and a red value)

Change

Code: Select all

msg.payload = { "command": "udevice", "idx": 494, "nvalue": 0, "svalue": msg.payload["1-0:16.7.0*255"].values[0].value};
return msg;
into

Code: Select all

msg.payload = { "command": "udevice", "idx": 494, "nvalue": 0, "svalue": (msg.payload["1-0:16.7.0*255"].values[0].value).toString()};
return msg;
Try this first. If this does not give a result, open the tree and post a new picture.

Regards
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by sailmich »

That work! Thank you very much! And in addition especially for the explaniton!
Cheers
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by sailmich »

Hello, I would like to get the data into RFX counter just once a day and value for usage electric instantly. Instant and counter I don't want to use it because It does the same as the other two but not that accurate. I tried to implement the time stamp stuff from Firewizard within the nod red flow but can't get it together. I tried also several other timer without success.
Spoiler: show
[
{
"id": "0c833d4010de4b96",
"type": "tab",
"label": "Smartmeter",
"disabled": false,
"info": "",
"env": []
},
{
"id": "27421d68571a5c13",
"type": "function",
"z": "0c833d4010de4b96",
"name": "Usage/Electric idx500",
"func": "msg.payload = { \"command\": \"udevice\", \"idx\": 500, \"nvalue\": 0, \"svalue\": (msg.payload[\"1-0:16.7.0*255\"].values[0].value).toString()};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 620,
"y": 180,
"wires": [
[
"6698212646ef8d52"
]
]
},
{
"id": "6698212646ef8d52",
"type": "mqtt out",
"z": "0c833d4010de4b96",
"name": "",
"topic": "domoticz/in",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "f9f13036.e28b58",
"x": 870,
"y": 180,
"wires": []
},
{
"id": "808b95b995a23a6c",
"type": "function",
"z": "0c833d4010de4b96",
"name": "RFX Counter kWh idx501",
"func": "msg.payload = { \"command\": \"udevice\", \"idx\": 501, \"nvalue\": 0, \"svalue\": (msg.payload[\"1-0:1.8.0*255\"].values[0].value*1000).toString()};\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 630,
"y": 140,
"wires": [
[
"6698212646ef8d52"
]
]
},
{
"id": "9766711fe96fb15a",
"type": "function",
"z": "0c833d4010de4b96",
"name": "Instant and counter idx502",
"func": "msg.payload = { \"command\": \"udevice\", \"idx\": 502, \"nvalue\": 0, \"svalue\": (msg.payload[\"1-0:16.7.0*255\"].values[0].value).toString()};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 640,
"y": 220,
"wires": [
[]
]
},
{
"id": "a486b31175ce3ed2",
"type": "moment",
"z": "0c833d4010de4b96",
"name": "",
"topic": "",
"input": "",
"inputType": "msg",
"inTz": "",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "",
"locale": "",
"output": "",
"outputType": "msg",
"outTz": "",
"x": 360,
"y": 360,
"wires": [
[]
]
},
{
"id": "87e1523f31df2dd1",
"type": "debug",
"z": "0c833d4010de4b96",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 910,
"y": 80,
"wires": []
},
{
"id": "a8545f5933c44809",
"type": "smartmeter",
"z": "0c833d4010de4b96",
"name": "",
"datasource": "34d070e3e0bdda8b",
"protocol": "SmlProtocol",
"transport": "SerialRequestResponseTransport",
"requestInterval": 0,
"d0WakeupCharacters": "",
"d0SignOnMessage": "",
"d0BaudrateChangeoverOverwrite": "",
"protocolSmlIgnoreInvalidCRC": false,
"debugging": false,
"x": 290,
"y": 200,
"wires": [
[
"27421d68571a5c13",
"808b95b995a23a6c"
]
]
},
{
"id": "09f92eb3856504bd",
"type": "timerswitch",
"z": "0c833d4010de4b96",
"name": "",
"ontopic": "",
"offtopic": "",
"onpayload": "",
"offpayload": "",
"disabled": false,
"schedules": [],
"x": 470,
"y": 440,
"wires": [
[]
]
},
{
"id": "121501dc3c834f5e",
"type": "bigtimer",
"z": "0c833d4010de4b96",
"outtopic": "",
"outpayload1": "",
"outpayload2": "",
"name": "Big Timer",
"comment": "",
"lat": 0,
"lon": 0,
"starttime": 5001,
"endtime": 1425,
"starttime2": 0,
"endtime2": 0,
"startoff": 0,
"endoff": 0,
"startoff2": 0,
"endoff2": 0,
"offs": 0,
"outtext1": "",
"outtext2": "",
"timeout": 1440,
"sun": true,
"mon": true,
"tue": true,
"wed": true,
"thu": true,
"fri": true,
"sat": true,
"jan": true,
"feb": true,
"mar": true,
"apr": true,
"may": true,
"jun": true,
"jul": true,
"aug": true,
"sep": true,
"oct": true,
"nov": true,
"dec": true,
"day1": 0,
"month1": 0,
"day2": 0,
"month2": 0,
"day3": 0,
"month3": 0,
"day4": 0,
"month4": 0,
"day5": 0,
"month5": 0,
"day6": 0,
"month6": 0,
"day7": 0,
"month7": 0,
"day8": 0,
"month8": 0,
"day9": 0,
"month9": 0,
"day10": 0,
"month10": 0,
"day11": 0,
"month11": 0,
"day12": 0,
"month12": 0,
"d1": 0,
"w1": 0,
"d2": 0,
"w2": 0,
"d3": 0,
"w3": 0,
"d4": 0,
"w4": 0,
"d5": 0,
"w5": 0,
"d6": 0,
"w6": 0,
"xday1": 0,
"xmonth1": 0,
"xday2": 0,
"xmonth2": 0,
"xday3": 0,
"xmonth3": 0,
"xday4": 0,
"xmonth4": 0,
"xday5": 0,
"xmonth5": 0,
"xday6": 0,
"xmonth6": 0,
"xday7": 0,
"xmonth7": 0,
"xday8": 0,
"xmonth8": 0,
"xday9": 0,
"xmonth9": 0,
"xday10": 0,
"xmonth10": 0,
"xday11": 0,
"xmonth11": 0,
"xday12": 0,
"xmonth12": 0,
"xd1": 0,
"xw1": 0,
"xd2": 0,
"xw2": 0,
"xd3": 0,
"xw3": 0,
"xd4": 0,
"xw4": 0,
"xd5": 0,
"xw5": 0,
"xd6": 0,
"xw6": 0,
"suspend": false,
"random": false,
"randon1": false,
"randoff1": false,
"randon2": false,
"randoff2": false,
"repeat": true,
"atstart": true,
"odd": false,
"even": false,
"x": 620,
"y": 320,
"wires": [
[],
[],
[]
]
},
{
"id": "f9f13036.e28b58",
"type": "mqtt-broker",
"name": "localhost",
"broker": "127.0.0.1",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
},
{
"id": "34d070e3e0bdda8b",
"type": "smartmeter-connection",
"sourcetype": "serial",
"serialport": "/dev/ttyUSB0",
"serialbaud": "9600",
"databits": "8",
"parity": "none",
"stopbits": "1",
"httphost": "localhost",
"httpport": "80",
"tcphost": "localhost",
"tcpport": "502",
"filepath": "/dev/null"
}
]
Again any help appreciated!
User avatar
FireWizard
Posts: 1893
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by FireWizard »

Hello @sailmich

You wrote:
Hello, I would like to get the data into RFX counter just once a day
Usually the sensors are updated as soon as new data is flowing in from your SmartMeter. In Domoticz you can define that if you use the P1 Smart meter hardware component. In this case you have to do this in Node RED.

One option is to use the "throttle" node. See: https://flows.nodered.org/node/node-red ... b-throttle

The question, however, is what is the time you want to update the sensor?
If it is a specific time you can trigger that "throttle" node at that specific time.

You can use CRON for that trigger. See: https://flows.nodered.org/node/node-red ... -cron-plus
The simplest method would be to use the Inject node and inject a msg.reset at a specific time.

But I do not know the reason, why you want to update the RFX counter once a day nor the time, you want to update.
value for usage electric instantly
I think, looking to your flow, that this works.
I tried to implement the time stamp stuff from Firewizard within the nod red flow but can't get it together. I tried also several other timer without success.
Can you explain what the "time stamp stuff" should do?

Regards
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by sailmich »

@Firewizard, I thought it would be a good idea to limit the data flow. Therefore I would like to get the total value just once per day. Also today is not that important to see it instantly. A few post above you gave a solution for http but I can't get it running with the node red smartmeter.
Cheers
User avatar
FireWizard
Posts: 1893
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by FireWizard »

@sailmich,
I thought it would be a good idea to limit the data flow. Therefore I would like to get the total value just once per day.
In my opinion there exists no technical reason to limit the dataflow to once per day, even if you look at it only once a day. An update once every 10 seconds or even every seconds is a long time for a computer. I would go for 1 update per 10 seconds. It is identical to older versions of the Dutch Smart meter protocol.

I gave you the solution with the smartmeter node and that worked, at least on February 19, you said that.

You have to decide whether you want to use HTTP or MQTT. Both is possible but MQTT is more efficient. And also the type of the virtual sensor in Domoticz.

Regards
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by sailmich »

Hello @FireWizard I'll stay with mqtt. Thank you very much for your advise.
Cheers
User avatar
FireWizard
Posts: 1893
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by FireWizard »

Hi @sailmich

Is your issue solved now?

Regards
sailmich
Posts: 245
Joined: Wednesday 17 February 2016 22:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany
Contact:

Re: SML 1.04 ir adapter for DTZ-541 Stromzaehler

Post by sailmich »

Hello FireWizard, I had a look at the history log of RFX meter and saw that it store every hour. I was afraid that the values were store every second and the database become huge. I will stay with instant data. No need to change the interval!
Thanks again for your help!
Cheers
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest