IMHO The simplest way out is to use functions to generate urls and send them to domoticz via the api via httprequest.
Code: Select all
[
{
"id": "e8b186eeed6d8d71",
"type": "tab",
"label": "test",
"disabled": false,
"info": "",
"env": []
},
{
"id": "fd9f4408dc22bd21",
"type": "http request",
"z": "e8b186eeed6d8d71",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "query",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 790,
"y": 220,
"wires": [
[
"1b4ee2b471fc7a65"
]
]
},
{
"id": "5c238b8245232ab8",
"type": "inject",
"z": "e8b186eeed6d8d71",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"P\":250,\"Avg\":201,\"GP\":0, \"CP\":20}",
"payloadType": "json",
"x": 180,
"y": 260,
"wires": [
[
"618321cdba5d4011",
"d3b830622281f514"
]
]
},
{
"id": "618321cdba5d4011",
"type": "debug",
"z": "e8b186eeed6d8d71",
"name": "debug 9",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 300,
"y": 160,
"wires": []
},
{
"id": "d3b830622281f514",
"type": "function",
"z": "e8b186eeed6d8d71",
"name": "Power func",
"func": "if (!msg.payload || typeof msg.payload.P === 'undefined') {\n return { payload: \"Error: Power undefined\" };\n} else {\n const power = msg.payload.P; // \n const sensorIdx = \"108\"; // Idx of Domoticz sensor\n \n const apiUrl = `/json.htm?type=command¶m=udevice&idx=${encodeURIComponent(sensorIdx)}&nvalue=0&svalue=${encodeURIComponent(power)}`;\n// url\nmsg.url = `http://127.0.0.1:8080${apiUrl}`;\n}\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 470,
"y": 220,
"wires": [
[
"199de00895426b37",
"fd9f4408dc22bd21"
]
]
},
{
"id": "199de00895426b37",
"type": "debug",
"z": "e8b186eeed6d8d71",
"name": "debug 10",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 600,
"y": 120,
"wires": []
},
{
"id": "1b4ee2b471fc7a65",
"type": "debug",
"z": "e8b186eeed6d8d71",
"name": "debug 11",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 920,
"y": 120,
"wires": []
}
]