
However the Managed Counter (tyoe Gas for this try out) is not updated in Domoticz
What am I doing wrong?
Warning: Newbie on Node-Red and Domoticz

Moderator: leecollings
Code: Select all
[
{
"id": "76a5d1b7.ed381",
"type": "tab",
"label": "P1monitor Data Import",
"disabled": false,
"info": ""
},
{
"id": "8df1efad74bf4ddc",
"type": "mqtt out",
"z": "76a5d1b7.ed381",
"name": "Send MQTT to Domonticz",
"topic": "domoticz/In",
"qos": "2",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "f9f13036.e28b58",
"x": 790,
"y": 220,
"wires": []
},
{
"id": "910303dcec5d5d55",
"type": "function",
"z": "76a5d1b7.ed381",
"name": "Store IDX Power",
"func": "//if mpayload.P1_consumed \nmsg.payload = { \"command\": \"udevice\", \"idx\": 129, \"usage\": msg.payload.P1_consumed + \";0\", \"return\": msg.payload.P1_generated + \";0\" }\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 570,
"y": 260,
"wires": [
[]
]
},
{
"id": "0f45f1515688ccc7",
"type": "mqtt in",
"z": "76a5d1b7.ed381",
"name": "Read dsmr EL",
"topic": "test_dsmr/el",
"qos": "2",
"datatype": "auto-detect",
"broker": "f9f13036.e28b58",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 110,
"y": 80,
"wires": [
[]
]
},
{
"id": "04cfacc53718b421",
"type": "comment",
"z": "76a5d1b7.ed381",
"name": "Test DSMR for now",
"info": "",
"x": 110,
"y": 220,
"wires": []
},
{
"id": "4efba523b05ff7c6",
"type": "switch",
"z": "76a5d1b7.ed381",
"name": "Filter",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "gas_consumed",
"vt": "str"
},
{
"t": "eq",
"v": "P1_consumed",
"vt": "str"
},
{
"t": "eq",
"v": "P1_generated",
"vt": "str"
}
],
"checkall": "false",
"repair": true,
"outputs": 3,
"x": 390,
"y": 260,
"wires": [
[
"88737b2f75bb95ed"
],
[
"910303dcec5d5d55"
],
[]
]
},
{
"id": "a5f675ed14c7b626",
"type": "split",
"z": "76a5d1b7.ed381",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "topic",
"x": 270,
"y": 260,
"wires": [
[
"4efba523b05ff7c6"
]
]
},
{
"id": "b34696bab8933e0b",
"type": "mqtt in",
"z": "76a5d1b7.ed381",
"name": "Read dsmr Gas",
"topic": "test_dsmr/gas",
"qos": "2",
"datatype": "auto-detect",
"broker": "f9f13036.e28b58",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 120,
"y": 260,
"wires": [
[
"a5f675ed14c7b626",
"5ee7cd5893fdc546"
]
]
},
{
"id": "88737b2f75bb95ed",
"type": "function",
"z": "76a5d1b7.ed381",
"name": "Store IDX Gas",
"func": "//if (msg.topic == \"p1monitor/smartmeter/consumption_gas_m3\") {\n// msg.payload = { \"idx\": 10, \"svalue\": msg.payload.toString() };\n// return msg;\n//}\n\n// {\"command\":\"udevice\", \"idx\":1234, \"svalue\":\"3.45\", \"parse\": false}\nmsg.payload = { \"command\": \"udevice\", \"idx\": 135, \"svalue\": msg.payload, \"parse\": false};\nreturn msg;\n\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 200,
"wires": [
[
"8316c64589c8cfa5",
"8df1efad74bf4ddc"
]
]
},
{
"id": "8316c64589c8cfa5",
"type": "debug",
"z": "76a5d1b7.ed381",
"name": "debug 2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 140,
"wires": []
},
{
"id": "5ee7cd5893fdc546",
"type": "debug",
"z": "76a5d1b7.ed381",
"name": "debug 3",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 300,
"y": 160,
"wires": []
},
{
"id": "f9f13036.e28b58",
"type": "mqtt-broker",
"name": "Domoticz 192.168.2.7",
"broker": "192.168.2.7",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "5",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
Code: Select all
msg.payload = { "command": "udevice", "idx": 135, "svalue": msg.payload.gas_consumed.toString(), "parse": false};
return msg;
Code: Select all
[
{
"id": "8df1efad74bf4ddc",
"type": "mqtt out",
"z": "76a5d1b7.ed381",
"name": "Send MQTT to Domonticz",
"topic": "domoticz/In",
"qos": "2",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "f9f13036.e28b58",
"x": 1240,
"y": 160,
"wires": []
},
{
"id": "910303dcec5d5d55",
"type": "function",
"z": "76a5d1b7.ed381",
"name": "Store IDX Power",
"func": "//if mpayload.P1_consumed \nmsg.payload = { \"command\": \"udevice\", \"idx\": 129, \"usage\": msg.payload.P1_consumed + \";0\", \"return\": msg.payload.P1_generated + \";0\" }\nreturn msg;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1150,
"y": 240,
"wires": [
[]
]
},
{
"id": "04cfacc53718b421",
"type": "comment",
"z": "76a5d1b7.ed381",
"name": "Test DSMR for now",
"info": "",
"x": 530,
"y": 100,
"wires": []
},
{
"id": "4efba523b05ff7c6",
"type": "switch",
"z": "76a5d1b7.ed381",
"name": "Filter",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "test_dsmr/gas",
"vt": "str"
},
{
"t": "eq",
"v": "P1_consumed",
"vt": "str"
},
{
"t": "eq",
"v": "P1_generated",
"vt": "str"
}
],
"checkall": "false",
"repair": true,
"outputs": 3,
"x": 730,
"y": 180,
"wires": [
[
"88737b2f75bb95ed"
],
[
"910303dcec5d5d55"
],
[]
]
},
{
"id": "b34696bab8933e0b",
"type": "mqtt in",
"z": "76a5d1b7.ed381",
"d": true,
"name": "Read dsmr Gas",
"topic": "test_dsmr/gas",
"qos": "2",
"datatype": "auto-detect",
"broker": "f9f13036.e28b58",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 540,
"y": 140,
"wires": [
[
"5ee7cd5893fdc546"
]
]
},
{
"id": "88737b2f75bb95ed",
"type": "function",
"z": "76a5d1b7.ed381",
"name": "Store IDX Gas",
"func": "//if (msg.topic == \"p1monitor/smartmeter/consumption_gas_m3\") {\n// msg.payload = { \"idx\": 10, \"svalue\": msg.payload.toString() };\n// return msg;\n//}\n\n// {\"command\":\"udevice\", \"idx\":1234, \"svalue\":\"3.45\", \"parse\": false}\nmsg.payload = { \"command\": \"udevice\", \"idx\": 135, \"svalue\": msg.payload.gas_consumed.toString(), \"parse\": false};\nreturn msg;\n\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 160,
"wires": [
[
"8316c64589c8cfa5",
"8df1efad74bf4ddc"
]
]
},
{
"id": "8316c64589c8cfa5",
"type": "debug",
"z": "76a5d1b7.ed381",
"name": "debug 2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1180,
"y": 120,
"wires": []
},
{
"id": "5ee7cd5893fdc546",
"type": "debug",
"z": "76a5d1b7.ed381",
"name": "debug 3",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 120,
"wires": []
},
{
"id": "932850c4abfecca5",
"type": "inject",
"z": "76a5d1b7.ed381",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "test_dsmr/gas.",
"payload": "{\"gas_consumed\":10142194,\"serial\":\"33313137\",\"timestamp\":1677772436}",
"payloadType": "json",
"x": 550,
"y": 180,
"wires": [
[
"5ee7cd5893fdc546",
"4efba523b05ff7c6"
]
]
},
{
"id": "f9f13036.e28b58",
"type": "mqtt-broker",
"name": "Domoticz 192.168.2.7",
"broker": "192.168.2.7",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "5",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
OK, that clarifies a lot of my mistakes.See the flow below. Test it and let me know.
Note: current usage is wrong. Should be: actual production,P1 Smart meter
The P1 Smart meter sensor allows you to show you power consumption, low and high usage, low and high return, actual consumption and actual return.
{"command":"udevice", "idx":1234, "svalue":"lu;hu;lr;hr;ac;ar"}
where lu is low tariff usage (in Wh so 1000 is 1 kWh), hu is high tariff usage (in Wh), lr is low tariff return (in Wh), hr is high tariff return (in Wh), ac is actual consumption (in W) and ar is current usage (in W).
Code: Select all
let us1 = msg.payload.P1_consumed.toString();
let us2 = msg.payload.P2_consumed.toString();
let ret1 = msg.payload.P1_generated.toString();
let ret2 = msg.payload.P2_generated.toString();
let cons = msg.payload.xxxxxxxx.toString();
let prod = msg.payload.yyyyyyyy.toString();
msg.payload = {"command": "udevice", "idx": 129, "svalue": us1 + ";" + us2 + ";" + ret1 + ";" + ret2 + ";" + cons + ";" + prod};
return msg;
Code: Select all
[
{
"id": "8df1efad74bf4ddc",
"type": "mqtt out",
"z": "76a5d1b7.ed381",
"name": "Send MQTT to Domonticz",
"topic": "domoticz/In",
"qos": "2",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "f9f13036.e28b58",
"x": 1240,
"y": 180,
"wires": []
},
{
"id": "910303dcec5d5d55",
"type": "function",
"z": "76a5d1b7.ed381",
"name": "Store IDX Power",
"func": "let us1 = msg.payload.P1_consumed.toString();\nlet us2 = msg.payload.P2_consumed.toString();\nlet ret1 = msg.payload.P1_generated.toString();\nlet ret2 = msg.payload.P2_generated.toString();\nlet cons = msg.payload.xxxxxxxx.toString();\nlet prod = msg.payload.yyyyyyyy.toString();\n\nmsg.payload = {\"command\": \"udevice\", \"idx\": 129, \"svalue\": us1 + \";\" + us2 + \";\" + ret1 + \";\" + ret2 + \";\" + cons + \";\" + prod, \"parse\": false};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 200,
"wires": [
[
"8df1efad74bf4ddc"
]
]
},
{
"id": "04cfacc53718b421",
"type": "comment",
"z": "76a5d1b7.ed381",
"name": "Test DSMR for now",
"info": "",
"x": 530,
"y": 100,
"wires": []
},
{
"id": "4efba523b05ff7c6",
"type": "switch",
"z": "76a5d1b7.ed381",
"name": "Filter",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "test_dsmr/gas",
"vt": "str"
},
{
"t": "cont",
"v": "test_dsmr/el",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 730,
"y": 180,
"wires": [
[
"88737b2f75bb95ed"
],
[
"910303dcec5d5d55"
]
]
},
{
"id": "b34696bab8933e0b",
"type": "mqtt in",
"z": "76a5d1b7.ed381",
"d": true,
"name": "Read DSMR",
"topic": "test_dsmr/#",
"qos": "0",
"datatype": "auto-detect",
"broker": "f9f13036.e28b58",
"nl": false,
"rap": false,
"rh": 0,
"inputs": 0,
"x": 530,
"y": 140,
"wires": [
[
"5ee7cd5893fdc546"
]
]
},
{
"id": "88737b2f75bb95ed",
"type": "function",
"z": "76a5d1b7.ed381",
"name": "Store IDX Gas",
"func": "msg.payload = { \"command\": \"udevice\", \"idx\": 135, \"svalue\": msg.payload.gas_consumed.toString(), \"parse\": false};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 940,
"y": 160,
"wires": [
[
"8316c64589c8cfa5",
"8df1efad74bf4ddc"
]
]
},
{
"id": "8316c64589c8cfa5",
"type": "debug",
"z": "76a5d1b7.ed381",
"name": "debug 2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1180,
"y": 140,
"wires": []
},
{
"id": "5ee7cd5893fdc546",
"type": "debug",
"z": "76a5d1b7.ed381",
"name": "debug 3",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 120,
"wires": []
},
{
"id": "932850c4abfecca5",
"type": "inject",
"z": "76a5d1b7.ed381",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "test_dsmr/gas.",
"payload": "{\"gas_consumed\":10142194,\"serial\":\"33313137\",\"timestamp\":1677772436}",
"payloadType": "json",
"x": 550,
"y": 180,
"wires": [
[
"5ee7cd5893fdc546",
"4efba523b05ff7c6"
]
]
},
{
"id": "f9f13036.e28b58",
"type": "mqtt-broker",
"name": "Domoticz 192.168.2.7",
"broker": "192.168.2.7",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "5",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]
Code: Select all
{"P1_consumed":677.0,"P1_generated":0.0,"P2_consumed":56.0,"P2_generated":0.0,"P3_consumed":132.0,"P3_generated":0.0,"V1":231.0,"V1_sags":5,"V1_swells":0,"V2":234.0,"V2_sags":5,"V2_swells":0,"V3":233.0,"V3_sags":4,"V3_swells":0,"el_consumed":23679674.0,"el_returned":21097674.0,"long_power_failures":12,"p_consumed":866.0,"p_generated":0.0,"power_failures":1373,"serial":"33363137","timestamp":1677857885}
Ok, good to know, I was already planning to use the normal counter, still testing it.
Users browsing this forum: No registered users and 0 guests