-
Notifications
You must be signed in to change notification settings - Fork 1
/
nodered-flows.json
1 lines (1 loc) · 2.41 KB
/
nodered-flows.json
1
[{"id":"58f7cca0.a64874","type":"tab","label":"Home Air Quality ","disabled":false,"info":""},{"id":"5b4f280e.15dbf","type":"mqtt in","z":"58f7cca0.a64874","name":"Particle matter sensor","topic":"home/livingroom/airquality","qos":"2","datatype":"utf8","broker":"bd67eac8.672bc","x":180,"y":120,"wires":[["482abea2.73cb58"]]},{"id":"482abea2.73cb58","type":"function","z":"58f7cca0.a64874","name":"Extract AQI Data","func":"var data = JSON.parse(msg.payload);\n\nvar lastRange = context.get('range');\n\nif (data.aqi_main_libelle === lastRange) {\n // Relay message only when range change\n return;\n}\n\nvar message;\nif (lastRange && data.aqi_main_libelle === \"Good\") {\n message = `Take a deep breath, air quality is back to normal! (AQI: ${data.aqi_main_value}). Enjoy`;\n} else {\n message = `Current air condition just changed to ${data.aqi_main_libelle} (AQI: ${data.aqi_main_value}). Stay safe!`;\n}\n\ncontext.set('range', data.aqi_main_libelle);\nreturn {\"payload\": {\"chatId\": \"1537861516\", \"type\":\"message\", \"content\": message}};","outputs":1,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is deployed.\ncontext.set('range', null);","finalize":"","x":430,"y":120,"wires":[["7082ca55.129cdc","9c4bfc92.1a0cd8"]]},{"id":"9c4bfc92.1a0cd8","type":"telegram sender","z":"58f7cca0.a64874","name":"","bot":"38c85d72.d238e2","haserroroutput":false,"outputs":1,"x":710,"y":80,"wires":[[]]},{"id":"7082ca55.129cdc","type":"debug","z":"58f7cca0.a64874","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":160,"wires":[]},{"id":"bd67eac8.672bc","type":"mqtt-broker","name":"","broker":"mqtt.b4bz.io","port":"8883","tls":"","clientid":"","usetls":true,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"38c85d72.d238e2","type":"telegram bot","botname":"b4bzBot","usernames":"b4stien","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]