With respect to your question in viewtopic.php?t=27588&start=180
This can be solved in a similar way as with the blinds, percentage inverted.:
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 (or extend the "Switch" node, so that it matches your IDX numbers), currently 12.
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 = {
on: true,
brightness: msg.payload.Level
}
return msg;
}
else if (msg.payload.nvalue === 0) {
msg.payload = {
on: false,
brightness: msg.payload.Level
}
return msg;
}
else if (msg.payload.nvalue === 2) {
msg.payload = {
on: true,
brightness: msg.payload.Level
}
return msg;
}
else {return null}
Code: Select all
var idx = parseInt(msg.topic);
if (msg.payload.on === false) {
msg.payload = {"command": "switchlight", "idx": idx, "switchcmd": "Off"};
}
else if (msg.payload.on === true) {
msg.payload = {"command": "switchlight", "idx": idx, "switchcmd": "Set Level", "level": msg.payload.brightness};
}
return msg
PLease find the complete flow below:
Code: Select all
[{"id":"28ff27c.48b42d8","type":"mqtt in","z":"39c679f3.99d346","name":"","topic":"domoticz/out","qos":"2","datatype":"json","broker":"f9f13036.e28b58","nl":false,"rap":false,"x":170,"y":900,"wires":[["db646b64.02bd28"]]},{"id":"db646b64.02bd28","type":"switch","z":"39c679f3.99d346","name":"Filter Dimmer Switch","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"12","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":380,"y":900,"wires":[["56d40f73.5d5f28"]]},{"id":"3ac29d27.3994da","type":"noraf-light","z":"39c679f3.99d346","devicename":"Light","lightcolor":false,"brightnesscontrol":true,"commandonlycolor":false,"turnonwhenbrightnesschanges":false,"passthru":false,"statepayload":false,"brightnessoverride":"","roomhint":"","name":"","colortype":"hsv","nora":"1c76c7bf.6c61e","topic":"12","onvalue":"true","onvalueType":"bool","offvalue":"false","offvalueType":"bool","temperaturemin":"2700","temperaturemax":"5500","x":810,"y":900,"wires":[["d013350d.fba66"]]},{"id":"56d40f73.5d5f28","type":"function","z":"39c679f3.99d346","name":"Function Dimmer In","func":"msg.topic = msg.payload.idx;\n\nif (msg.payload.nvalue === 1) {\n msg.payload = {\n on: true,\n brightness: msg.payload.Level\n }\nreturn msg; \n}\n\nelse if (msg.payload.nvalue === 0) {\n msg.payload = {\n on: false,\n brightness: msg.payload.Level\n }\nreturn msg;\n}\nelse if (msg.payload.nvalue === 2) {\n msg.payload = {\n on: true,\n brightness: msg.payload.Level\n }\nreturn msg;\n}\nelse {return null}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":900,"wires":[["3ac29d27.3994da"]]},{"id":"d013350d.fba66","type":"function","z":"39c679f3.99d346","name":"Function out Dimmer","func":"var idx = parseInt(msg.topic);\n\nif (msg.payload.on === false) {\n msg.payload = {\"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"Off\"};\n}\nelse if (msg.payload.on === true) {\n msg.payload = {\"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"Set Level\", \"level\": msg.payload.brightness};\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1000,"y":900,"wires":[["562c8b7a.8e6bb4"]]},{"id":"562c8b7a.8e6bb4","type":"mqtt out","z":"39c679f3.99d346","name":"","topic":"domoticz/in","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f9f13036.e28b58","x":1210,"y":900,"wires":[]},{"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"}]
1. After your MQTT Input node, called domoticz/out, you have a JSON node.
This is not necessary, as you can set this in the MQTT by setting "Output" to "a parsed JSON Object" in the drop-down selector.
2. You have a line creating a short-cut between the JSON node and the "Function Dimmer" node.
I assume that this is used during debugging, but should be removed in the final flow.
3. Everything in your post tells me that you want to use a dimmer only, so no WW/CW or RGB controls
In this case you should "untick" the setting: "Send/receive complete state as payload:"
4. From your "Function out Dimmer" node, you have created 2 outputs that go to the JSON node (1 input).
This is not necessary. So I created the "Function" node with 1 output.
5. The JSON node before the MQTT Output node is useless, as we send already a JSON object to the MQTT Output node.
Regards