I used the original Plugwise2py, now i use the Plugwise2py container gruijter/Plugwise2py
What sensor device do you have configured (Your IDX 110)? Idx110 is VerbruikDroger
Cant get info in node red at the moment, but this is the ouput in mqtt analyzer:
{"power8s": 0.0, "powerts": 0, "name": "droger", "schedule": "?", "requid": "unset", "power1s": 0.0, "switchreq": "?", "readonly": false, "interval": 60, "switch": "on", "mac": "000D6F00003FF1DD", "production": false, "monitor": true, "lastseen": 1649963532, "power1h": 0.0, "online": true, "savelog": true, "type": 2, "reverse_pol": true, "schedname": "__PW2PY__test-alternate", "location": "zolder"}
Code: Select all
[
{
"id": "82652e5a2a4c0381",
"type": "tab",
"label": "WasMachine",
"disabled": false,
"info": ""
},
{
"id": "4809f7337329137c",
"type": "function",
"z": "82652e5a2a4c0381",
"name": "Plugwise2 Energy to Domoticz",
"func": "//\n// Relay Plugwise MQTT energy message to Domoticz HTTP\n//\nnode.log (\"Relay Plugwise MQTT energy message to Domoticz HTTP\");\nvar sensor_url = context.flow.plugwiseCfg.sensor_base_url;\nvar pwJSON = JSON.parse(msg.payload);\nvar state = context.flow.plugwiseState[pwJSON.mac];\nvar pvalue = pwJSON.power;\nvar evalue = pwJSON.cum_energy;\npvalue = pvalue\nevalue = evalue\n//if (state)\n// if (state.state.production) {\n// pvalue = pvalue;\n// evalue = evalue;\n// }\n\n///json.htm?type=command¶m=udevice&hid=$HID&did=$DID&dunit=$DUNIT&dtype=$DTYPE&dsubtype=$DSUBTYPE&nvalue=$NVALUE&svalue=$SVALUE\"\nmsg.url = sensor_url + \"did=E\"+pwJSON.mac.substr(9,7)+\"&dunit=1&dtype=243&dsubtype=29&nvalue=&svalue=\"+pvalue+\";\"+evalue;\nreturn msg;",
"outputs": "1",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 590,
"y": 160,
"wires": [
[
"8ac8a87748f3ab6a",
"28684f2a4d4c9a9e"
]
]
},
{
"id": "d8cdc15371ef0cd2",
"type": "function",
"z": "82652e5a2a4c0381",
"name": "Plugwise2 Power to Domoticz",
"func": "//\n// Relay Plugwise MQTT power message to Domoticz HTTP\n//\nnode.log (\"Relay Plugwise MQTT power message to Domoticz HTTP\");\nvar sensor_url = context.flow.plugwiseCfg.sensor_base_url;\nvar pwJSON = JSON.parse(msg.payload);\n\nvar state = context.flow.plugwiseState[pwJSON.mac];\nvar value = pwJSON.power;\nvalue = value;\n//if (state)\n// if (state.state.production)\n// value = value;\n\n///json.htm?type=command¶m=udevice&hid=$HID&did=$DID&dunit=$DUNIT&dtype=$DTYPE&dsubtype=$DSUBTYPE&nvalue=$NVALUE&svalue=$SVALUE\"\nmsg.url = sensor_url + \"did=F\"+pwJSON.mac.substr(9,7)+\"&dunit=1&dtype=248&dsubtype=1&nvalue=&svalue=\"+value+\";0\";\n\nreturn msg;",
"outputs": "1",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 590,
"y": 220,
"wires": [
[
"8ac8a87748f3ab6a",
"7b4650360b558276"
]
]
},
{
"id": "153d9f697dfbfb42",
"type": "function",
"z": "82652e5a2a4c0381",
"name": "Plugwise2 State to Domoticz",
"func": "//\n// Relay Plugwise MQTT state/circle message to Domoticz HTTP\n//\nnode.log (\"Relay Plugwise MQTT state/circle message to Domoticz HTTP\");\nvar switch_url = context.flow.plugwiseCfg.switch_base_url;\nvar sensor_url = context.flow.plugwiseCfg.sensor_base_url;\nvar pwJSON = JSON.parse(msg.payload);\nvar pwSwitch = 0;\nif (pwJSON.switch.toLowerCase() == \"on\")\n pwSwitch = 1;\nvar pwSchedule = 0;\nif (pwJSON.schedule.toLowerCase() == \"on\")\n pwSchedule = 1;\nvar info = \"\";\nif (pwJSON.schedname.length > 0)\n info += \"schedule: \" + pwJSON.schedname;\nif (!pwJSON.online) {\n if (info.length > 0)\n info += \", \";\n info += \"offline\";\n}\n\n///json.htm?type=command¶m=udevice&hid=$HID&did=$DID&dunit=$DUNIT&dtype=$DTYPE&dsubtype=$DSUBTYPE&nvalue=$NVALUE&svalue=$SVALUE\"\nvar switch_msg = {};\nvar schedule_msg = {};\nvar status_msg = {};\nswitch_msg.url = switch_url + \"did=B\"+pwJSON.mac.substr(9,7)+\"&dunit=1&dtype=17&dsubtype=0&nvalue=\" + pwSwitch + \"&svalue=15\";\nschedule_msg.url = switch_url + \"did=C\"+pwJSON.mac.substr(9,7)+\"&dunit=1&dtype=17&dsubtype=0&nvalue=\" + pwSchedule + \"&svalue=15\";\nstatus_msg.url = sensor_url + \"did=A\"+pwJSON.mac.substr(9,7)+\"&dunit=1&dtype=243&dsubtype=19&nvalue=&svalue=\"+info;\n\n//discard state messages as reply to a domoticz switch command\nif (pwJSON.requid == context.flow.plugwiseReqUID + 0) {\n context.flow.plugwiseState[pwJSON.mac] = { ts: Date.now(), state: pwJSON, update: \"schedule\" };\n return [null, schedule_msg, status_msg];\n}\nelse if (pwJSON.requid == context.flow.plugwiseReqUID + 1) {\n context.flow.plugwiseState[pwJSON.mac] = { ts: Date.now(), state: pwJSON, update: \"switch\" };\n return [switch_msg, null, status_msg];\n}\ncontext.flow.plugwiseState[pwJSON.mac] = { ts: Date.now(), state: pwJSON, update: \"both\" };\n\n//return [msg, context.global.plugwiseState[pwJSON.mac]];\nreturn [switch_msg, schedule_msg, status_msg];\n\n\n\n",
"outputs": "3",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 585,
"y": 291,
"wires": [
[
"8ac8a87748f3ab6a",
"f4156d8f7e3c0f8a"
],
[
"8ac8a87748f3ab6a",
"eaa3eb9f61fa974b"
],
[
"8ac8a87748f3ab6a",
"1da7c7c6b1e34cbc"
]
]
},
{
"id": "7b4650360b558276",
"type": "debug",
"z": "82652e5a2a4c0381",
"name": "msg.url",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": false,
"complete": "url",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 980,
"y": 200,
"wires": []
},
{
"id": "8ac8a87748f3ab6a",
"type": "http request",
"z": "82652e5a2a4c0381",
"name": "Domoticz",
"method": "use",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 820,
"y": 220,
"wires": [
[]
]
},
{
"id": "6ad7415bc25b5496",
"type": "inject",
"z": "82652e5a2a4c0381",
"name": "run at startup",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "",
"topic": "",
"payloadType": "str",
"x": 197,
"y": 94,
"wires": [
[
"454361baa2f7cba1"
]
]
},
{
"id": "454361baa2f7cba1",
"type": "function",
"z": "82652e5a2a4c0381",
"name": "Initialise global context",
"func": "//edit the following variables to match your configuration:\ndomoticz_ip = \"127.0.0.1\";\ndomoticz_port = \"9091\";\nvirtual_hardware_id = 80;\nvirtual_switch_id = 80;\n//end config section\n\n//initialize plugwise-domoticz bridge global variables\nif (!context.flow.plugwiseCfg) {\n context.flow.plugwiseCfg = {};\n}\nif (!context.flow.plugwiseState) {\n context.flow.plugwiseState = [];\n}\nif (!context.flow.plugwiseReqUID) {\n context.flow.plugwiseReqUID = Date.now().toString();\n}\n\ncontext.flow.plugwiseCfg.sensor_base_url = \"http://\" + domoticz_ip + \":\" + domoticz_port + \"/json.htm?type=command¶m=udevice&idx=\" + virtual_hardware_id +\"&\";\ncontext.flow.plugwiseCfg.switch_base_url = \"http://\" + domoticz_ip + \":\" + domoticz_port + \"/json.htm?type=command¶m=udevice&idx=\" + virtual_switch_id +\"&\";\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 423,
"y": 94,
"wires": [
[]
]
},
{
"id": "dae90e375208e84c",
"type": "switch",
"z": "82652e5a2a4c0381",
"name": "",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "energy",
"vt": "str"
},
{
"t": "cont",
"v": "power",
"vt": "str"
},
{
"t": "cont",
"v": "circle",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 361,
"y": 226,
"wires": [
[
"4809f7337329137c"
],
[
"d8cdc15371ef0cd2"
],
[
"153d9f697dfbfb42"
]
]
},
{
"id": "5ae572159845d151",
"type": "mqtt in",
"z": "82652e5a2a4c0381",
"name": "",
"topic": "plugwise2py/state/#",
"qos": "2",
"datatype": "auto",
"broker": "541cd84c.f2963",
"nl": false,
"rap": false,
"x": 150,
"y": 300,
"wires": [
[
"5bdb33b04011242b"
]
]
},
{
"id": "1da7c7c6b1e34cbc",
"type": "debug",
"z": "82652e5a2a4c0381",
"name": "msg.url",
"active": false,
"tosidebar": true,
"console": true,
"complete": "url",
"x": 978,
"y": 313,
"wires": []
},
{
"id": "eaa3eb9f61fa974b",
"type": "debug",
"z": "82652e5a2a4c0381",
"name": "msg.url",
"active": false,
"console": "true",
"complete": "url",
"x": 977,
"y": 274,
"wires": []
},
{
"id": "f4156d8f7e3c0f8a",
"type": "debug",
"z": "82652e5a2a4c0381",
"name": "msg.url",
"active": false,
"console": "true",
"complete": "url",
"x": 976,
"y": 235,
"wires": []
},
{
"id": "28684f2a4d4c9a9e",
"type": "debug",
"z": "82652e5a2a4c0381",
"name": "msg.url",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "url",
"targetType": "msg",
"statusVal": "url",
"statusType": "auto",
"x": 978,
"y": 158,
"wires": []
},
{
"id": "6c54e77f193801cb",
"type": "debug",
"z": "82652e5a2a4c0381",
"name": "",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 440,
"y": 440,
"wires": []
},
{
"id": "5bdb33b04011242b",
"type": "switch",
"z": "82652e5a2a4c0381",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "FD2F9",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 250,
"y": 440,
"wires": [
[
"dae90e375208e84c",
"6c54e77f193801cb"
]
]
},
{
"id": "541cd84c.f2963",
"type": "mqtt-broker",
"name": "",
"broker": "127.0.0.1",
"port": "1883",
"clientid": "",
"usetls": false,
"protocolVersion": "4",
"keepalive": "15",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
}
]