With respect to your question in viewtopic.php?f=69&t=27588&start=180.
Please find below the answer:
The flow looks as follows:
Change the configuration of the MQTT nodes, called "Domoticz Out" and "Domoticz In"
Change also the IDX number in the "Switch" node, so that it matches your IDX number (9), currently 11.
Change also the configuration of the Smart Nora node, so that it fits yours (currently "smartnora config")
For simplicity you will find the contents of the first "Function" ( Domoticz to Google Home) node below:
Code: Select all
msg.topic = msg.payload.idx;
if (msg.payload.nvalue === 1) {
msg.payload = {
openPercent : 100
}
return msg;
}
else if (msg.payload.nvalue === 0) {
msg.payload = {
openPercent : 0
}
return msg;
}
else if (msg.payload.nvalue === 2) {
msg.payload = {
openPercent : msg.payload.svalue1
}
return msg;
}
else {return null}
Code: Select all
var idx = parseInt(msg.topic);
if (msg.payload.openPercent === 100) {
msg.payload = { "command": "switchlight", "idx": idx, "switchcmd": "On"};
}
else if (msg.payload.openPercent === 0) {
msg.payload = { "command": "switchlight", "idx": idx, "switchcmd": "Off"};
}
else {
msg.payload = {"command": "switchlight", "idx": idx, "switchcmd": "Set Level", "level": msg.payload.openPercent};
}
return msg
PLease find the complete flow below:
Code: Select all
[{"id":"e109e3fb.fb1b2","type":"tab","label":"Test","disabled":false,"info":""},{"id":"f8f35d1c.17aa48","type":"mqtt in","z":"e109e3fb.fb1b2","name":"Domoticz Out","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":false,"x":110,"y":380,"wires":[["b1e44280.bfcc98"]]},{"id":"b1e44280.bfcc98","type":"switch","z":"e109e3fb.fb1b2","name":"Filter Shutter Switch","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"11","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":320,"y":380,"wires":[["7e15f7f9.c65418"]]},{"id":"471ebff2.8f1778","type":"noraf-blinds","z":"e109e3fb.fb1b2","devicename":"Persiana comedor","roomhint":"Menjador","name":"Persiana comedor","passthru":false,"invert":false,"nora":"1c76c7bf.6c61e","topic":"9","x":770,"y":380,"wires":[["7bb24be6.735324"]]},{"id":"88a266be.046a2","type":"mqtt out","z":"e109e3fb.fb1b2","name":"Domoticz In","topic":"domoticz/in","qos":"2","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":1210,"y":380,"wires":[]},{"id":"7e15f7f9.c65418","type":"function","z":"e109e3fb.fb1b2","name":"Function Shutter In","func":"msg.topic = msg.payload.idx;\n\nif (msg.payload.nvalue === 1) {\n msg.payload = {\n openPercent : 100\n }\nreturn msg; \n}\n\nelse if (msg.payload.nvalue === 0) {\n msg.payload = {\n openPercent : 0\n }\nreturn msg;\n}\nelse if (msg.payload.nvalue === 2) {\n msg.payload = {\n openPercent : msg.payload.svalue1\n }\nreturn msg;\n}\nelse {return null}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":380,"wires":[["471ebff2.8f1778"]]},{"id":"7bb24be6.735324","type":"function","z":"e109e3fb.fb1b2","name":"Function Shutter Out","func":"var idx = parseInt(msg.topic);\n\nif (msg.payload.openPercent === 100) {\n msg.payload = { \"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"On\"};\n }\nelse if (msg.payload.openPercent === 0) {\n msg.payload = { \"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"Off\"};\n }\n else {\n msg.payload = {\"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"Set Level\", \"level\": msg.payload.openPercent};\n }\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1000,"y":380,"wires":[["88a266be.046a2"]]},{"id":"f9f13036.e28b58","type":"mqtt-broker","name":"localhost","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"1c76c7bf.6c61e","type":"noraf-config","name":"smartnora config","group":"Test92","twofactor":"off","twofactorpin":"","localexecution":true,"structure":"Test"}]
Regards