Hi All,
Im switching a fan on and off with a function node 'fan control' between to set points and now i would like to add a manual override function node 'Auto/Manual switch' but i just can't get it to work. would some one be able to show me where i am going wrong.
Cheers
Jez
[{"id":"4a78ae1a.0ffd8","type":"rpi-dht22","z":"ecea2ab1.faa898","name":"DHT22","topic":"rpi-dht22","dht":22,"pintype":"2","pin":"7","x":260,"y":180,"wires":[["e1353e0e.1a8d8"]]},{"id":"5f1b2230.c0db7c","type":"inject","z":"ecea2ab1.faa898","name":"Read DHT22","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":80,"y":180,"wires":[["4a78ae1a.0ffd8"]]},{"id":"e1353e0e.1a8d8","type":"function","z":"ecea2ab1.faa898","name":"temp","func":"msg.payload = msg.payload\nmsg.topic = \"Temp\"\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":180,"wires":[["5a17bd63.59e55c"]]},{"id":"5a17bd63.59e55c","type":"function","z":"ecea2ab1.faa898","name":"Fan control","func":"var Temp=msg.payload;\nif (Temp <= 24) {\n msg.payload = 0\n} else if (Temp >= 27) {\n msg.payload = 1\n} else {\n msg = null\n}\nreturn msg","outputs":1,"noerr":0,"x":570,"y":180,"wires":[["91b7acb7.cbeaa","c70a9133.6c9768"]]},{"id":"91b7acb7.cbeaa","type":"function","z":"ecea2ab1.faa898","name":"Auto/Manual switch","func":"var manual_switch = global.get(\"AutoManual_switch\");\nvar fan_control = global.get(\"fan_control\");\nvar OnOff_switch = global.get(\"OnOff_switch\");\n\nif (manual_switch === 0) {\n if (fan_control == 1) {\n msg.payload == 1;\n }\n else if (fan_control === 0) {\n msg.payload === 0;\n }\n}\nelse if (manual_switch == 1) {\n if (OnOff_switch === 0){\n msg.payload === 0;\n }\n else if (OnOff_switch == 1) {\n msg.payload == 1;\n }\n}\nreturn msg;\n ","outputs":1,"noerr":0,"x":780,"y":160,"wires":[["91f1d00a.bee9d8"]]},{"id":"c70a9133.6c9768","type":"change","z":"ecea2ab1.faa898","name":"Fan Control var","rules":[{"t":"set","p":"fan_control","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":200,"wires":[[]]},{"id":"91f1d00a.bee9d8","type":"rpi-gpio out","z":"ecea2ab1.faa898","name":"Fan","pin":"19","set":true,"level":"0","freq":"","out":"out","x":970,"y":180,"wires":[]},{"id":"624ce528.839134","type":"ui_switch","z":"ecea2ab1.faa898","name":"","label":"Fan Auto/Manual switch","tooltip":"","group":"e4fc1fd3.c1044","order":4,"width":5,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":110,"y":280,"wires":[["b04b1d9b.fd94a8","e7acc5e1.ab269"]]},{"id":"d3640ec8.fe883","type":"ui_switch","z":"ecea2ab1.faa898","name":"","label":"Fan On/Off switch","tooltip":"","group":"e4fc1fd3.c1044","order":4,"width":5,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":130,"y":380,"wires":[["db849e29.46fb1","866440c.b4269c"]]},{"id":"b04b1d9b.fd94a8","type":"change","z":"ecea2ab1.faa898","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"Auto","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"Manual","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":260,"wires":[["2f24b0ea.9d2cb8"]]},{"id":"e7acc5e1.ab269","type":"change","z":"ecea2ab1.faa898","name":"Auto/Manual var","rules":[{"t":"set","p":"AutoManual_switch","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":300,"wires":[[]]},{"id":"866440c.b4269c","type":"change","z":"ecea2ab1.faa898","name":"OnOff var","rules":[{"t":"set","p":"OnOff_switch","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":400,"wires":[[]]},{"id":"db849e29.46fb1","type":"change","z":"ecea2ab1.faa898","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"Off","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"On","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":360,"wires":[["d0a70e40.d38838"]]},{"id":"d0a70e40.d38838","type":"ui_text","z":"ecea2ab1.faa898","group":"e4fc1fd3.c1044","order":5,"width":2,"height":1,"name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":530,"y":380,"wires":[]},{"id":"2f24b0ea.9d2cb8","type":"ui_text","z":"ecea2ab1.faa898","group":"e4fc1fd3.c1044","order":5,"width":2,"height":1,"name":"","label":"","format":"{{msg.payload}}","layout":"row-spread","x":530,"y":280,"wires":[]},{"id":"e4fc1fd3.c1044","type":"ui_group","z":"","name":"Text","tab":"9caadd41.281e9","order":2,"disp":false,"width":7,"collapse":false},{"id":"9caadd41.281e9","type":"ui_tab","z":"","name":"Remote View","icon":"dashboard","disabled":false,"hidden":false}]