Hi All,
I am looking to setup a flow as follows.
Every minute, get two values from a database, if value target is lower then last_reading, then turn on the hot water,
When it gets to a preset value (60 in my case) then turn off.
send a telegraph message when changing states from off to on, and on to off.
That process works, but I then get lots of duplicate notifications via telegraph.
I've tried to setup throttle, but am having problems with setting up msg.reset for the throttle, and not carrying out onward processing.
flow for ref is attached:
[{"id":"16b40f2c9d6a8226","type":"function","z":"b32e0571792d7b62","name":"","func":"var sensor = '28-7ee0c31d64ff';\nvar temprature= msg.payload;\n\nmsg.topic = \"select last_reading,target from current where sensor = '\"+sensor+\"';\"\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":300,"wires":[["0884cea35ae60ff2"]]},{"id":"1e16d02a449bfe1b","type":"inject","z":"b32e0571792d7b62","name":"","props":[{"p":"payload"}],"repeat":"60","crontab":"","once":true,"onceDelay":"5","topic":"","payloadType":"date","x":130,"y":300,"wires":[["16b40f2c9d6a8226"]]},{"id":"0884cea35ae60ff2","type":"mysql","z":"b32e0571792d7b62","mydb":"81dd10f6410922fe","name":"","x":420,"y":300,"wires":[["66b648ca6ff8741e"]]},{"id":"b4782609be35343f","type":"throttle","z":"b32e0571792d7b62","name":"","throttleType":"block","timeLimit":"5","timeLimitType":"seconds","countLimit":"1","blockSize":"1","locked":false,"x":810,"y":400,"wires":[["035c7d8be5655196","138220852667d178"]]},{"id":"66b648ca6ff8741e","type":"change","z":"b32e0571792d7b62","name":"","rules":[{"t":"set","p":"hot_water_temp","pt":"msg","to":"msg.payload[0].last_reading","tot":"msg"},{"t":"set","p":"hot_water_target","pt":"msg","to":"msg.payload[0].target","tot":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":300,"wires":[["f3aa1a630417f661","4570f679ad3737c2"]]},{"id":"f3aa1a630417f661","type":"switch","z":"b32e0571792d7b62","name":"","property":"hot_water_temp","propertyType":"msg","rules":[{"t":"gte","v":"60","vt":"num"},{"t":"lt","v":"hot_water_target","vt":"msg"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":300,"wires":[["56fe8de4ca0accc2","f2ecdcadaf2dc5f9"],["b4782609be35343f","1767d305b38e1869"]]},{"id":"035c7d8be5655196","type":"function","z":"b32e0571792d7b62","name":"Prepare Telegram","func":"var tel_chat_id = global.get('Telegram_chat');\n\nvar chatIds = [];\nchatIds.push(-tel_chat_id);\n//chatIds.push(-nnnnnnnnnnnnnn);\n\nmsg.payload = {chatId: chatIds, type : 'message', content : \"Hot Water is Low.\"};\n\n// activate markdown\nmsg.payload.options = {disable_web_page_preview : true, parse_mode : \"Markdown\"};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1190,"y":300,"wires":[["55a8f641702a115f"]],"icon":"font-awesome/fa-pencil-square-o"},{"id":"55a8f641702a115f","type":"telegram sender","z":"b32e0571792d7b62","name":"Send (HotWater)","bot":"f9ed343b.599e58","haserroroutput":false,"outputs":1,"x":1410,"y":300,"wires":[[]]},{"id":"138220852667d178","type":"function","z":"b32e0571792d7b62","name":"","func":"var sensor = '28-021nosensor6';\n//var sensor = '28-7ee0c31d64ff';\nvar target_temp = 21;\nvar target_max = 21.5;\nvar target_min = 20.5;\n\nmsg.topic = \"update current set target=\"+target_temp+\" where sensor = \"+\"'\"+sensor+\"';\\\n update current set max_target=\"+target_max+\" where sensor = \"+\"'\"+sensor+\"';\\\n update current set min_target=\"+target_min+\" where sensor = \"+\"'\"+sensor+\"';\\\n commit;\"\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":460,"wires":[["1dca25dfb1522534"]]},{"id":"1dca25dfb1522534","type":"mysql","z":"b32e0571792d7b62","mydb":"81dd10f6410922fe","name":"","x":1020,"y":380,"wires":[["ee0e78a9fd186260"]]},{"id":"ee0e78a9fd186260","type":"function","z":"b32e0571792d7b62","name":"Prepare Telegram","func":"var tel_chat_id = global.get('Telegram_chat');\n\nvar chatIds = [];\nchatIds.push(-tel_chat_id);\n//chatIds.push(-nnnnnnnnnnnnnn);\n\nmsg.payload = {chatId: chatIds, type : 'message', content : \"Hot Water target changed.\"};\n\n// activate markdown\nmsg.payload.options = {disable_web_page_preview : true, parse_mode : \"Markdown\"};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1190,"y":380,"wires":[["55a8f641702a115f"]],"icon":"font-awesome/fa-pencil-square-o"},{"id":"56fe8de4ca0accc2","type":"throttle","z":"b32e0571792d7b62","name":"","throttleType":"block","timeLimit":"5","timeLimitType":"seconds","countLimit":"1","blockSize":"1","locked":false,"x":810,"y":240,"wires":[["236f372b74a37ee7"]]},{"id":"236f372b74a37ee7","type":"function","z":"b32e0571792d7b62","name":"","func":"var sensor = '28-021nosensor6';\n//var sensor = '28-7ee0c31d64ff';\nvar target_temp = 18;\nvar target_max = 18.5;\nvar target_min = 17.5;\n\nmsg.topic = \"update current set target=\"+target_temp+\" where sensor = \"+\"'\"+sensor+\"';\\\n update current set max_target=\"+target_max+\" where sensor = \"+\"'\"+sensor+\"';\\\n update current set min_target=\"+target_min+\" where sensor = \"+\"'\"+sensor+\"';\\\n commit;\"\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":860,"y":200,"wires":[["963c579f1f2147cf"]]},{"id":"f6b9e1edd0f3c7ff","type":"function","z":"b32e0571792d7b62","name":"Prepare Telegram","func":"var tel_chat_id = global.get('Telegram_chat');\n\nvar chatIds = [];\nchatIds.push(-tel_chat_id);\n//chatIds.push(-nnnnnnnnnnnnnn);\n\nmsg.payload = {chatId: chatIds, type : 'message', content : \"Hot Water is Hot.\"};\n\n// activate markdown\nmsg.payload.options = {disable_web_page_preview : true, parse_mode : \"Markdown\"};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1190,"y":200,"wires":[["55a8f641702a115f"]],"icon":"font-awesome/fa-pencil-square-o"},{"id":"963c579f1f2147cf","type":"mysql","z":"b32e0571792d7b62","mydb":"81dd10f6410922fe","name":"","x":1020,"y":200,"wires":[["f6b9e1edd0f3c7ff"]]},{"id":"f2ecdcadaf2dc5f9","type":"debug","z":"b32e0571792d7b62","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":260,"wires":[]},{"id":"1767d305b38e1869","type":"debug","z":"b32e0571792d7b62","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":300,"wires":[]},{"id":"4570f679ad3737c2","type":"debug","z":"b32e0571792d7b62","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":440,"y":420,"wires":[]},{"id":"81dd10f6410922fe","type":"MySQLdatabase","name":"","host":"192.168.1.1","port":"3306","test":"test","tz":"","charset":"UTF8"},{"id":"f9ed343b.599e58","type":"telegram bot","botname":"TestBot","usernames":"xxxx","chatids":"-xxxx","baseapiurl":"","updatemode":"polling","pollinterval":"1000","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":true}]
I have tried using the output of throttle from the top to reset throttle at the bottom, but the messages then flow for at least one occurrence on both, causing issues. So how can I issue a reset, but stop onward processing of that message from throttle?