In the past, I created a lot of integrations through node-red, where I used following syntax to send a switchlight command to MQTT (topic: domoticz/in) to control my lights:
IN A FUNCTION NODE:
Code: Select all
msg.payload = {};
msg.payload.idx = 33;
msg.payload.command = "switchlight";
msg.payload.switchcmd = "On"
return msg;
Code: Select all
msg.payload = {};
msg.payload.type = "command";
msg.payload.param = "switchlight";
msg.payload.idx = 33;
msg.payload.switchcmd = "Off"
return msg;
When sending above request from node-red,
I see following on MQTT:
I get following error in domoticz log:domoticz/in {"type":"command","param":"switchlight","idx":33,"switchcmd":"Off"}
Here the node-red flow:2024-01-19 18:22:15.482 Error: MQTT: Invalid/Unhandled data received! (Topic: domoticz/in, Message: {"type":"command","param":"switchlight","idx":33,"switchcmd":"Off"})
Code: Select all
[
{
"id": "399e202d616e91e9",
"type": "function",
"z": "35f4467d68b3c595",
"name": "Zet in Domoticz \"Tuin Keuken\" op \"Off\"",
"func": "msg.payload = {};\nmsg.payload.type = \"command\";\nmsg.payload.idx = 45;\nmsg.payload.command = \"switchlight\";\nmsg.payload.switchcmd = \"Off\"\nreturn msg;\n\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 570,
"y": 500,
"wires": [
[
"c198600e81073ebe"
]
]
},
{
"id": "1405e5993c0f8323",
"type": "function",
"z": "35f4467d68b3c595",
"name": "Zet in Domoticz \"Tuin Keuken\" op \"On\"",
"func": "msg.payload = {};\nmsg.payload.type = \"command\";\nmsg.payload.idx = 45;\nmsg.payload.param = \"switchlight\";\nmsg.payload.switchcmd = \"On\"\nreturn msg;\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 570,
"y": 540,
"wires": [
[
"c198600e81073ebe"
]
]
},
{
"id": "c198600e81073ebe",
"type": "mqtt out",
"z": "35f4467d68b3c595",
"name": "Stuur naar Domoticz",
"topic": "domoticz/in",
"qos": "1",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "ad2b25c9.9ea728",
"x": 860,
"y": 500,
"wires": []
},
{
"id": "f7c3e4766f38afa8",
"type": "inject",
"z": "35f4467d68b3c595",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 220,
"y": 480,
"wires": [
[
"399e202d616e91e9"
]
]
},
{
"id": "f4b583af62a14f02",
"type": "inject",
"z": "35f4467d68b3c595",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 220,
"y": 540,
"wires": [
[
"1405e5993c0f8323"
]
]
},
{
"id": "ad2b25c9.9ea728",
"type": "mqtt-broker",
"name": "MQTT",
"broker": "mqtt",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]