It works both ways, from domoticz to google and from google to domoticz.
you have to change the nora key in both devices, change the rooms in the devices and the device id's
this script is working for on/off devices
success!
Code: Select all
[
{
"id": "ff1ab690.7fb988",
"type": "tab",
"label": "test pvk nodered ga",
"disabled": false,
"info": ""
},
{
"id": "5b802f42.439f6",
"type": "switch",
"z": "ff1ab690.7fb988",
"name": "domoticz_idx_check",
"property": "topic",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "1002",
"vt": "str"
},
{
"t": "eq",
"v": "997",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 180,
"y": 400,
"wires": [
[
"233c4df8.0001b2",
"3008424e.ff7c2e"
],
[
"8ac4121.3f617f",
"3008424e.ff7c2e"
]
]
},
{
"id": "4889f435.b43f8c",
"type": "function",
"z": "ff1ab690.7fb988",
"name": "Function out On/Off",
"func": "var idx = parseInt(msg.topic);\nif ( msg.payload === true )\n{\nmsg.payload = { \"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"On\" };\n}\nelse if ( msg.payload === false )\n{\nmsg.payload = { \"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"Off\" };\n}\nreturn msg\n",
"outputs": 1,
"noerr": 0,
"x": 1073,
"y": 480,
"wires": [
[
"d001ff86.4058c"
]
],
"info": "van msg.topic (dat is idx) \nen msg.payload = true or fale \neen domoticz mqtt bericht maken"
},
{
"id": "d001ff86.4058c",
"type": "json",
"z": "ff1ab690.7fb988",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 1035,
"y": 629,
"wires": [
[
"63bcc86e.eae6b8"
]
]
},
{
"id": "8ac4121.3f617f",
"type": "nora-switch",
"z": "ff1ab690.7fb988",
"devicename": "lamp_tv_links",
"roomhint": "Woonkamer",
"name": "lamp tv links",
"passthru": false,
"nora": "xxxx",
"topic": "997",
"onvalue": "true",
"onvalueType": "bool",
"offvalue": "false",
"offvalueType": "bool",
"x": 770,
"y": 100,
"wires": [
[
"4889f435.b43f8c",
"e80c1f02.6a0ce"
]
]
},
{
"id": "233c4df8.0001b2",
"type": "nora-switch",
"z": "ff1ab690.7fb988",
"devicename": "Lantaarn",
"roomhint": "Woonkamer",
"name": "Lantaarn",
"passthru": false,
"nora": "xxxx",
"topic": "1002",
"onvalue": "true",
"onvalueType": "bool",
"offvalue": "false",
"offvalueType": "bool",
"x": 760,
"y": 40,
"wires": [
[
"4889f435.b43f8c",
"e80c1f02.6a0ce"
]
]
},
{
"id": "79bc0ca4.de6f54",
"type": "comment",
"z": "ff1ab690.7fb988",
"name": "Useful links",
"info": "https://www.domoticz.com/forum/viewtopic.php?f=69&t=27588\nhttps://flows.nodered.org/node/node-red-contrib-nora\nhttps://discourse.nodered.org/t/node-red-google-home-integration/4829\ndomoticz mqtt publish is / en out\nhttps://node-red-google-home.herokuapp.com/login\n\n\n{\n \"Battery\" : 255,\n \"RSSI\" : 12,\n \"description\" : \"\",\n \"dtype\" : \"Lighting 2\",\n \"id\" : \"0E672C2\",\n \"idx\" : 1002,\n \"name\" : \"lantaarn\",\n \"nvalue\" : 1,\n \"stype\" : \"AC\",\n \"svalue1\" : \"15\",\n \"switchType\" : \"On/Off\",\n \"unit\" : 3\n}\n\nzie ook flow voor de overige types zoals dimmers en scenes",
"x": 110,
"y": 40,
"wires": []
},
{
"id": "99c79ab.238b368",
"type": "mqtt in",
"z": "ff1ab690.7fb988",
"name": "Bericht van domoticz (UIT) naar GA",
"topic": "domoticz/out",
"qos": "0",
"datatype": "auto",
"broker": "465cbf12.c733c",
"x": 140,
"y": 760,
"wires": [
[
"d2403aae.6599f8"
]
]
},
{
"id": "8cc7ec95.8a166",
"type": "debug",
"z": "ff1ab690.7fb988",
"name": "debugging",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 726,
"y": 556,
"wires": []
},
{
"id": "d2403aae.6599f8",
"type": "json",
"z": "ff1ab690.7fb988",
"name": "json convert",
"property": "payload",
"action": "",
"pretty": false,
"x": 150,
"y": 664,
"wires": [
[
"c2f5ef39.2136f",
"11d01ad2.fe5bb5"
]
]
},
{
"id": "c2f5ef39.2136f",
"type": "switch",
"z": "ff1ab690.7fb988",
"name": "switchtype_check",
"property": "payload.switchType",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "On/Off",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 170,
"y": 564,
"wires": [
[
"51ef0358.4f7b4c",
"8cc7ec95.8a166"
]
]
},
{
"id": "38ca2451.c7292c",
"type": "comment",
"z": "ff1ab690.7fb988",
"name": "er is een pakket met switchtype On/Off",
"info": "kijkt naar switchtype \"On/Off\"",
"x": 470,
"y": 564,
"wires": []
},
{
"id": "51ef0358.4f7b4c",
"type": "function",
"z": "ff1ab690.7fb988",
"name": "convert message",
"func": "msg.topic = msg.payload.idx\nif (msg.payload.nvalue == 1)\n{\n msg.payload = true\n}\nelse if (msg.payload.nvalue === 0)\n{\n msg.payload = false\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 170,
"y": 480,
"wires": [
[
"5b802f42.439f6",
"6cf9129.e9a20ec"
]
]
},
{
"id": "e80c1f02.6a0ce",
"type": "debug",
"z": "ff1ab690.7fb988",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 1040,
"y": 80,
"wires": []
},
{
"id": "1a3fdd48.9efbd3",
"type": "comment",
"z": "ff1ab690.7fb988",
"name": "GA heeft false of true nodig in de body",
"info": "een GA bericht maken\nbevat msg.payload = false or true\ntopic = idx\ningeval een switch",
"x": 490,
"y": 480,
"wires": []
},
{
"id": "63bcc86e.eae6b8",
"type": "mqtt out",
"z": "ff1ab690.7fb988",
"name": "Bericht van GA naar domoticz (IN) ",
"topic": "domoticz/in",
"qos": "1",
"retain": "",
"broker": "465cbf12.c733c",
"x": 1122,
"y": 744,
"wires": []
},
{
"id": "4bfdd274.023e6c",
"type": "comment",
"z": "ff1ab690.7fb988",
"name": "uit domoticz naar google naar boven",
"info": "bericht uit domoticz",
"x": 481.5,
"y": 761,
"wires": []
},
{
"id": "11d01ad2.fe5bb5",
"type": "debug",
"z": "ff1ab690.7fb988",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 726.5,
"y": 657,
"wires": []
},
{
"id": "6cf9129.e9a20ec",
"type": "debug",
"z": "ff1ab690.7fb988",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 725.5,
"y": 471,
"wires": []
},
{
"id": "3008424e.ff7c2e",
"type": "debug",
"z": "ff1ab690.7fb988",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 728.5,
"y": 394,
"wires": []
},
{
"id": "fb6542cd.d21da",
"type": "nora-config",
"z": "",
"name": "nora pvk key",
"group": "",
"notify": false
},
{
"id": "465cbf12.c733c",
"type": "mqtt-broker",
"z": "",
"name": "mqttdomoticz",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]