Hi,
Is there is a better way of calling the function every 1 second, and send the appropriate message to a mqtt node?
Maybe something like an interrupt in the coding world? That only operates when the global variables change..
[{"id":"2d3eddbc.3f19f2","type":"function","z":"2a6827d4.9b5e18","name":"function","func":"\n//Retrieve global variables\nvar houseArmedState = global.get(\"houseArmed\");\nvar sentryModeState = global.get(\"sentryMode\");\n\n\n//If house is NOT set, AND sentry Mode enabled, proceed.... \nif (houseArmedState == '0' & sentryModeState == '1') \n{\n msg.payload = \"red\";\n}\n\nelse \n{\n msg.payload = \"off\";\n \n}\n\n\n//Send the message to MQTT node\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1480,"y":1610,"wires":[["361f31e5.70550e"]]},{"id":"20be1d8c.31f772","type":"inject","z":"2a6827d4.9b5e18","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1610,"wires":[["2d3eddbc.3f19f2"]]},{"id":"361f31e5.70550e","type":"debug","z":"2a6827d4.9b5e18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1710,"y":1610,"wires":[]}]