Hi
My kWh meter displays a low and a high rate (counters).
I have an MQTT connection to Node Red.
When the high rate is active, I would like an LED light on my dashboard to flash. And the same applies when the low rate is active.
I have tried to create a program that reads the high rate; when this high rate (counter) is active, the counter reading increases (when there is a load, of course).
But the program didn't work, what did I wrong?
[
{
"id": "5402ec8d1874bad7",
"type": "function",
"z": "0e30872a391bd11c",
"name": "Low Rate Pulse",
"func": "const message = msg.payload\nlet lrpulse = flow.get(\"pulselr\") || 0\nlet lowr = flow.get(\"lowrate\")\n\nif (message == 1)\n{\n flow.set(\"lrtmphold\", lowr)\n flow.set(\"pulselr\",0)\n return\n}\n \nif (lowr == flow.get(\"lrtmphold\"))\n{\n flow.set(\"pulselr\",0)\n return\n}\n\nif (lowr > flow.get(\"lrtmphold\"))\n{\n flow.set(\"pulslr\",1)\n setTimeout(flow.set(\"lrtmphold\",lowr),1000)\n}\nreturn msg",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 460,
"wires": [
[]
]
},
{
"id": "d919a1f451322c97",
"type": "change",
"z": "0e30872a391bd11c",
"name": "read pulse",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "#:(file)::pulselr",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 290,
"y": 400,
"wires": [
[
"46e24baf577e33b1"
]
]
},
{
"id": "46e24baf577e33b1",
"type": "debug",
"z": "0e30872a391bd11c",
"name": "debug 12",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 480,
"y": 400,
"wires": []
},
{
"id": "343eadba06597da1",
"type": "inject",
"z": "0e30872a391bd11c",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "1",
"payloadType": "num",
"x": 90,
"y": 460,
"wires": [
[
"5402ec8d1874bad7",
"d919a1f451322c97"
]
]
}
]
