Example function if statement example
-
-
Save jhottell/417acf55128bbba870221c8cdf0aad17 to your computer and use it in GitHub Desktop.
Function If Statement Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"8fdf0634.fdc3b8","type":"inject","z":"2755f3c2.561704","name":"","topic":"","payload":"PumpOn","payloadType":"str","repeat":"","crontab":"","once":false,"x":112.76666259765625,"y":41.01667022705078,"wires":[["1f7e0169.8c6547","3e0a8cfb.fa66bc"]]},{"id":"c3f62387.fab968","type":"inject","z":"2755f3c2.561704","name":"","topic":"PumpTopic","payload":"PumpOff","payloadType":"str","repeat":"","crontab":"","once":false,"x":144.76666259765625,"y":90.01667022705078,"wires":[["1f7e0169.8c6547","3e0a8cfb.fa66bc"]]},{"id":"9d3a07c0.3dd1e8","type":"inject","z":"2755f3c2.561704","name":"","topic":"SomethingRandom","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":171.76666259765625,"y":140.01666259765625,"wires":[["1f7e0169.8c6547","3e0a8cfb.fa66bc"]]},{"id":"1f7e0169.8c6547","type":"function","z":"2755f3c2.561704","name":"Function","func":"if (msg.payload == 'PumpOn') \n {\n return {topic:'Pump01/',payload:'On'}; \n } \nelse if (msg.payload == 'PumpOff') \n {\n return {topic:'Pump01/',payload:'Off'}; \n }\nelse\n {\n return {topic:'Information/',payload:'Unknown command'}; \n }\n","outputs":1,"noerr":0,"x":387.76666259765625,"y":46.51667022705078,"wires":[["e01dcd06.291c78"]]},{"id":"e01dcd06.291c78","type":"debug","z":"2755f3c2.561704","name":"","active":true,"console":"false","complete":"true","x":530.7666625976562,"y":46.25000762939453,"wires":[]},{"id":"3e0a8cfb.fa66bc","type":"debug","z":"2755f3c2.561704","name":"","active":true,"console":"false","complete":"true","x":398.75,"y":91.8333511352539,"wires":[]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment