All Aqara sensors in NodeRED
I'm taking all Aqara ZigBee sensors to NodeRED to see what hidden information is sent via ZigBee 3.0 and use it in Home automation to your advantage.
Featuring:
- Aqara Contact sensor (door and window sensor) (AmazonUS, AmazonUK, AliExpress, Banggood)
- Aqara Temp & Humidity (AmazonUS, AmazonUK, AliExpress, Banggood)
- Aqara Vibration Sensor (AmazonUS, AmazonUK, AliExpress, Banggood)
- Aqara Leak Sensor (AmazonUS, AmazonUK, AliExpress, Banggood)
- Aqara PIR with Luminosity (AmazonUS, AmazonUK, AliExpress, Banggood)
Dashboard:
Requirements
- node-red-dashboard
- Guide to adding ZigBee devices to your network
- Guide to adding unsupported ZigBee devices to your network
- CC2531 (flash guide) shop: https://shrsl.com/25xc4
Settings
Please make sure that MQTT topics are filled with your device's ID
More about me:
If you want to get the latest updates to this project you can follow me via your preferred social media:
And if you feeling like buying me a coffee or supporting me in a more continuous way:
I hope you have enjoyed the project!
[{"id":"5b5ca77a.f14fb8","type":"tab","label":"Aqara Sensors in NodeRED","disabled":false,"info":"\n![enter image description here](https://notenoughtech.com/wp-content/uploads/2021/05/Aqara-sensors-in-NodeRED.jpg)\nI'm taking all Aqara ZigBee sensors to NodeRED to see what hidden information is sent via ZigBee 3.0 and use it in Home automation to your advantage.\n\n - [Complete instructions](https://notenoughtech.com/home-automation/all-aqara-sensors-in-nodered/)\n\n**Featuring**:\n- Aqara Contact sensor (door and window sensor) ([AmazonUS](https://amzn.to/3wy84wt), [AmazonUK](https://amzn.to/3fNPWc8), [AliExpress](https://s.click.aliexpress.com/e/_9APIBK), [Banggood](https://www.banggood.com/custlink/v3KdLp8DJw))\n- Aqara Temp & Humidity ([AmazonUS](https://amzn.to/3wy84wt), [AmazonUK](https://amzn.to/3cV3zEj), [AliExpress](https://s.click.aliexpress.com/e/_9GA312), [Banggood](https://www.banggood.com/custlink/mDGhLCIDtH))\n- Aqara Vibration Sensor ([AmazonUS](https://amzn.to/31PiB8b), [AmazonUK](https://amzn.to/3rQYu4l), [AliExpress](https://s.click.aliexpress.com/e/_AErBgY), [Banggood](https://www.banggood.com/custlink/m3DROJiKHc))\n- Aqara Leak Sensor (AmazonUS, [AmazonUK](https://amzn.to/3wzHnr1), [AliExpress](https://s.click.aliexpress.com/e/_AqnIfK), [Banggood](https://www.banggood.com/custlink/mKmdjWIDPG))\n- Aqara PIR with Luminosity ([AmazonUS](https://amzn.to/3rQY6Tr), [AmazonUK](https://amzn.to/2Q225z8), [AliExpress](https://s.click.aliexpress.com/e/_9zYIBS), [Banggood](https://www.banggood.com/custlink/vDDEjpS3ri))\n\nDashboard:\n![enter image description here](https://notenoughtech.com/wp-content/uploads/2021/05/2021-05-13-21_55_15-Node-RED-Dashboard.jpg)\n\n## Requirements\n\n - node-red-dashboard\n - [Guide to adding ZigBee devices to your network](https://notenoughtech.com/home-automation/adding-devices-to-zigbee2mqtt-the-easy-way/)\n - [Guide to adding unsupported ZigBee devices to your network](https://notenoughtech.com/home-automation/adding-new-devices-to-zigbee2mqtt/)\n - CC2531 [(flash guide)](https://notenoughtech.com/home-automation/flashing-cc2531-without-cc-debugger/) shop: https://shrsl.com/25xc4\n\n# Settings\nPlease make sure that MQTT topics are filled with your device's ID\n \n ## More about me:\n\nIf you want to get the latest updates to this project you can follow me via your preferred social media:\n\n- [Facebook](https://www.facebook.com/NotEnoughTECH/)\n- [Twitter](https://twitter.com/NotEnoughTECH)\n- [Instagram](https://www.instagram.com/notenoughtech/)\n- [YouTube](https://www.youtube.com/user/Polepositionpage)\n\nAnd if you feeling like buying me a coffee or supporting me in a more continuous way:\n\n- [Paypal](https://www.paypal.me/notenoughtech)\n- [Patreon](https://www.patreon.com/NotEnoughTECH)\n\nI hope you have enjoyed the project!\n\n "},{"id":"571865a8.d6961c","type":"group","z":"5b5ca77a.f14fb8","name":"Temp, Humidity & Pressure","style":{"stroke":"#92d04f","fill":"#e3f3d3","label":true,"label-position":"n","color":"#000000"},"nodes":["fd72c2f2.c8444","6e7fb1a3.23099","b3740fc7.d28e2","2d35f941.e518b6","10e84b00.1f3095","98b729fd.490f08","a8e20fdb.a4906","2d6f2c3b.46b504","ef1c9c44.6ea2a","2876ffdc.2104f","40086181.83fe3"],"x":234,"y":259,"w":792,"h":322},{"id":"8e51635e.86845","type":"group","z":"5b5ca77a.f14fb8","name":"Vibration Sensor","style":{"stroke":"#001f60","fill":"#bfdbef","label":true,"label-position":"n","color":"#ffffff"},"nodes":["26a0255e.c51dea","642ec015.807d7","648747a3.5f5ca8","53707c12.48fde4","ad98122c.cff81"],"x":234,"y":1039,"w":752,"h":142},{"id":"9860e8b3.327588","type":"group","z":"5b5ca77a.f14fb8","name":"PIR & Luminosity","style":{"stroke":"#ffC000","fill":"#ffefbf","label":true,"label-position":"n","color":"#001f60"},"nodes":["a5742c29.c46fc","72855938.3d70f8","8b0c7be1.19f388","af043f9d.2969b","5e12023a.c7ae6c","f18b6855.d8d5a8","db26535c.da95a","6b59a4f0.fac24c"],"x":234,"y":39,"w":652,"h":202},{"id":"e80ac6e0.658d58","type":"group","z":"5b5ca77a.f14fb8","name":"Water Leak sensor","style":{"stroke":"#6f2fa0","fill":"#dbcbe7","label":true,"label-position":"n","color":"#000000"},"nodes":["7380dba6.2affc4","4e88fe5f.bdefc","d631b76d.8d62f8","b8847485.f0f1b8","37e76e43.ecfe32","76c170ac.b7fa5","d93bd6e9.558798"],"x":234,"y":799,"w":752,"h":162},{"id":"e84745dd.f0c5c8","type":"group","z":"5b5ca77a.f14fb8","name":"","style":{"stroke":"#0070c0","fill":"#bfdbef","label":true,"label-position":"n","color":"#000000"},"nodes":["dc2065af.1e5898","d3f6a9ce.1a0f68","bf6aa330.9bbe2","1cc6f054.4caf5","bf0d7151.074ad","5706cf0a.ef38b","8fc041f.2fd54c"],"x":234,"y":599,"w":572,"h":162},{"id":"a5742c29.c46fc","type":"mqtt in","z":"5b5ca77a.f14fb8","g":"9860e8b3.327588","name":"PIR","topic":"zigbee2mqtt/0x00158d00067c2970","qos":"0","datatype":"json","broker":"24720c3b.ea60e4","nl":false,"rap":true,"rh":0,"x":310,"y":140,"wires":[["8b0c7be1.19f388","f18b6855.d8d5a8","6b59a4f0.fac24c","2adc95ae.92dc8a"]]},{"id":"72855938.3d70f8","type":"ui_chart","z":"5b5ca77a.f14fb8","g":"9860e8b3.327588","name":"","group":"a16a53a9.053db","order":3,"width":0,"height":0,"label":"Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":770,"y":160,"wires":[[]]},{"id":"8b0c7be1.19f388","type":"function","z":"5b5ca77a.f14fb8","g":"9860e8b3.327588","name":"Get data","func":"var data = msg.payload;\n\n//Luminosity\nvar msg1 = {payload: data.illuminance_lux, topic: \"luminosity\"};\n\n//temperature\nvar msg2 = {payload: data.temperature, topic: \"temperature\"};\n\n\nreturn [msg1, msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":140,"wires":[["af043f9d.2969b"],["72855938.3d70f8"]]},{"id":"af043f9d.2969b","type":"ui_chart","z":"5b5ca77a.f14fb8","g":"9860e8b3.327588","name":"","group":"a16a53a9.053db","order":4,"width":0,"height":0,"label":"Luminosity","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":770,"y":120,"wires":[[]]},{"id":"5e12023a.c7ae6c","type":"ui_template","z":"5b5ca77a.f14fb8","g":"9860e8b3.327588","group":"a16a53a9.053db","name":"Link and Battery","order":1,"width":6,"height":2,"format":"<ng-md-icon icon={{msg.icon}} style={{msg.colour}} size=\"50\"></ng-md-icon>\n\n<div ng-bind-html=\"msg.batteryP\"></div>\n<div ng-bind-html=\"msg.batteryV\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":780,"y":200,"wires":[[]]},{"id":"f18b6855.d8d5a8","type":"function","z":"5b5ca77a.f14fb8","g":"9860e8b3.327588","name":"Range Fromat","func":"var range = msg.payload.linkquality;\nvar batteryV = msg.payload.voltage / 1000;\nvar batteryP = msg.payload.battery;\n\n//strong 130+\nif(range >= 130){\n msg.icon = \"signal_wifi_3_bar\";\n msg.colour = \"fill: green\";\n}\n//good 90-129\nif(range >= 90 && range < 130){\n msg.icon = \"signal_wifi_2_bar\";\n msg.colour = \"fill: blue\";\n}\n//medium 50-89\nif(range >= 50 && range < 90){\n msg.icon = \"signal_wifi_1_bar\";\n msg.colour = \"fill: orange\";\n}\n//low below <49\nif(range < 50){\n msg.icon = \"signal_wifi_0_bar\";\n msg.colour = \"fill: red\";\n}\n\nmsg.batteryP = \"Battery: \" + batteryP + \"%\";\nmsg.batteryV = \"Battery voltage: \" + batteryV + \"V\";\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":200,"wires":[["5e12023a.c7ae6c"]]},{"id":"db26535c.da95a","type":"ui_text","z":"5b5ca77a.f14fb8","g":"9860e8b3.327588","group":"a16a53a9.053db","order":2,"width":0,"height":0,"name":"Last event","label":"Last event: ","format":"{{msg.payload}}","layout":"row-spread","x":770,"y":80,"wires":[]},{"id":"6b59a4f0.fac24c","type":"function","z":"5b5ca77a.f14fb8","g":"9860e8b3.327588","name":"Get trigger time","func":"if(msg.payload.occupancy === true) {\n var date = new Date();\n \n msg.payload = \"Day: \" + date.getDate() +\"/\"+ date.getMonth()+ \" Time: \"+ date.getHours() +\":\"+date.getMinutes();\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":80,"wires":[["db26535c.da95a"]]},{"id":"fd72c2f2.c8444","type":"mqtt in","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"Temp & Humidity","topic":"zigbee2mqtt/0x00158d0002531a71","qos":"0","datatype":"json","broker":"24720c3b.ea60e4","nl":false,"rap":true,"rh":0,"x":340,"y":420,"wires":[["6e7fb1a3.23099","b3740fc7.d28e2","40086181.83fe3","1dd61a2a.e56076"]]},{"id":"6e7fb1a3.23099","type":"function","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"F to C","func":"var units = flow.get(\"tempSensorUnit\");\nvar tempC = msg.payload.temperature;\n\n// formula (0°C × 9/5) + 32 = 32°F\nvar tempF = tempC * (9/5) +32;\nvar temp;\n\nif(units === true){temp = tempC; msg.unit = \"℃\";}\nelse {temp = tempF; msg.unit = \"F\";}\n\nmsg.payload = temp\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":420,"wires":[["2876ffdc.2104f"]]},{"id":"b3740fc7.d28e2","type":"function","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"Range Fromat","func":"var range = msg.payload.linkquality;\nvar batteryV = msg.payload.voltage / 1000;\nvar batteryP = msg.payload.battery;\n\n//strong 130+\nif(range >= 130){\n msg.icon = \"signal_wifi_3_bar\";\n msg.colour = \"fill: green\";\n}\n//good 90-129\nif(range >= 90 && range < 130){\n msg.icon = \"signal_wifi_2_bar\";\n msg.colour = \"fill: blue\";\n}\n//medium 50-89\nif(range >= 50 && range < 90){\n msg.icon = \"signal_wifi_1_bar\";\n msg.colour = \"fill: orange\";\n}\n//low below <49\nif(range < 50){\n msg.icon = \"signal_wifi_0_bar\";\n msg.colour = \"fill: red\";\n}\n\nmsg.batteryP = \"Battery: \" + batteryP + \"%\";\nmsg.batteryV = \"Battery voltage: \" + batteryV + \"V\";\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":360,"wires":[["2d35f941.e518b6"]]},{"id":"2d35f941.e518b6","type":"ui_template","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","group":"4cfeefb0.f6aee","name":"Link and Battery","order":1,"width":6,"height":2,"format":"<ng-md-icon icon={{msg.icon}} style={{msg.colour}} size=\"50\"></ng-md-icon>\n\n<div ng-bind-html=\"msg.batteryP\"></div>\n<div ng-bind-html=\"msg.batteryV\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":800,"y":360,"wires":[[]]},{"id":"10e84b00.1f3095","type":"ui_chart","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"Pressure","group":"4cfeefb0.f6aee","order":4,"width":0,"height":0,"label":"Pressure hPa","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":780,"y":460,"wires":[[]]},{"id":"98b729fd.490f08","type":"ui_chart","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"Temperature","group":"4cfeefb0.f6aee","order":5,"width":0,"height":0,"label":"Temperature {{msg.unit}}","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":790,"y":500,"wires":[[]]},{"id":"a8e20fdb.a4906","type":"ui_chart","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"Humidity ","group":"4cfeefb0.f6aee","order":6,"width":0,"height":0,"label":"Humidity %","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":780,"y":540,"wires":[[]]},{"id":"2d6f2c3b.46b504","type":"ui_switch","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"","label":"F/℃","tooltip":"","group":"4cfeefb0.f6aee","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":true,"x":790,"y":300,"wires":[["ef1c9c44.6ea2a"]]},{"id":"ef1c9c44.6ea2a","type":"function","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"","func":"\n// true for ℃\nflow.set (\"tempSensorUnit\", msg.payload);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":300,"wires":[[]]},{"id":"2876ffdc.2104f","type":"ui_text","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","group":"4cfeefb0.f6aee","order":3,"width":0,"height":0,"name":"","label":"Current Temperature","format":"{{msg.payload}} {{msg.unit}}","layout":"row-spread","x":820,"y":420,"wires":[]},{"id":"40086181.83fe3","type":"function","z":"5b5ca77a.f14fb8","g":"571865a8.d6961c","name":"Get data","func":"var data = msg.payload;\nvar units = flow.get(\"tempSensorUnit\");\n\nvar tempC = data.temperature;\n\n\nvar tempF = tempC * (9/5) +32;\n\nvar temp;\nif(units === true){temp = tempC; msg.unit = \"℃\";}\nelse {temp = tempF; msg.unit = \"F\";}\n\n//Luminosity\nvar msg1 = {payload: data.pressure, topic: \"Pressure\"};\n\n//temperature\nvar msg2 = {payload: temp, topic: \"Temperature\"};\n\n//temperature\nvar msg3 = {payload: data.humidity, topic: \"Humidity\"};\n\n\nreturn [msg1, msg2, msg3];\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":480,"wires":[["10e84b00.1f3095"],["98b729fd.490f08"],["a8e20fdb.a4906"]]},{"id":"dc2065af.1e5898","type":"mqtt in","z":"5b5ca77a.f14fb8","g":"e84745dd.f0c5c8","name":"Contact","topic":"zigbee2mqtt/0x00158d00044fd168","qos":"0","datatype":"json","broker":"24720c3b.ea60e4","nl":false,"rap":true,"rh":0,"x":310,"y":680,"wires":[["d3f6a9ce.1a0f68","bf0d7151.074ad","5706cf0a.ef38b","9a83b89f.b3b018"]]},{"id":"d3f6a9ce.1a0f68","type":"function","z":"5b5ca77a.f14fb8","g":"e84745dd.f0c5c8","name":"Range Fromat","func":"var range = msg.payload.linkquality;\nvar batteryV = msg.payload.voltage / 1000;\nvar batteryP = msg.payload.battery;\n\n//strong 130+\nif(range >= 130){\n msg.icon = \"signal_wifi_3_bar\";\n msg.colour = \"fill: green\";\n}\n//good 90-129\nif(range >= 90 && range < 130){\n msg.icon = \"signal_wifi_2_bar\";\n msg.colour = \"fill: blue\";\n}\n//medium 50-89\nif(range >= 50 && range < 90){\n msg.icon = \"signal_wifi_1_bar\";\n msg.colour = \"fill: orange\";\n}\n//low below <49\nif(range < 50){\n msg.icon = \"signal_wifi_0_bar\";\n msg.colour = \"fill: red\";\n}\n\nmsg.batteryP = \"Battery: \" + batteryP + \"%\";\nmsg.batteryV = \"Battery voltage: \" + batteryV + \"V\";\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":680,"wires":[["bf6aa330.9bbe2"]]},{"id":"bf6aa330.9bbe2","type":"ui_template","z":"5b5ca77a.f14fb8","g":"e84745dd.f0c5c8","group":"30a2768d.b4ef4a","name":"Link and Battery","order":1,"width":6,"height":2,"format":"<ng-md-icon icon={{msg.icon}} style={{msg.colour}} size=\"50\"></ng-md-icon>\n\n<div ng-bind-html=\"msg.batteryP\"></div>\n<div ng-bind-html=\"msg.batteryV\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":700,"y":680,"wires":[[]]},{"id":"1cc6f054.4caf5","type":"ui_text","z":"5b5ca77a.f14fb8","g":"e84745dd.f0c5c8","group":"30a2768d.b4ef4a","order":2,"width":0,"height":0,"name":"Last event","label":"Last event: ","format":"{{msg.payload}}","layout":"row-spread","x":690,"y":640,"wires":[]},{"id":"bf0d7151.074ad","type":"function","z":"5b5ca77a.f14fb8","g":"e84745dd.f0c5c8","name":"Get trigger time","func":"if(msg.payload.contact === false) {\n var date = new Date();\n \n msg.payload = \"Opened: \" + date.getDate() +\"/\"+ date.getMonth()+ \" Time: \"+ date.getHours() +\":\"+date.getMinutes();\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":640,"wires":[["1cc6f054.4caf5"]]},{"id":"5706cf0a.ef38b","type":"function","z":"5b5ca77a.f14fb8","g":"e84745dd.f0c5c8","name":"Get data","func":"var data = msg.payload;\n\n//temperature\nvar msg1 = {payload: data.temperature, topic: \"temperature\"};\n\nreturn [msg1];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":720,"wires":[["8fc041f.2fd54c"]]},{"id":"8fc041f.2fd54c","type":"ui_chart","z":"5b5ca77a.f14fb8","g":"e84745dd.f0c5c8","name":"","group":"30a2768d.b4ef4a","order":3,"width":0,"height":0,"label":"Temperature","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":690,"y":720,"wires":[[]]},{"id":"7380dba6.2affc4","type":"mqtt in","z":"5b5ca77a.f14fb8","g":"e80ac6e0.658d58","name":"Water Leak Sensor","topic":"zigbee2mqtt/0x00158d00065a49cd","qos":"0","datatype":"json","broker":"24720c3b.ea60e4","nl":false,"rap":true,"rh":0,"x":350,"y":860,"wires":[["4e88fe5f.bdefc","b8847485.f0f1b8","76c170ac.b7fa5","3b47b4d3.32a19c"]]},{"id":"4e88fe5f.bdefc","type":"function","z":"5b5ca77a.f14fb8","g":"e80ac6e0.658d58","name":"Get trigger time","func":"if(msg.payload.water_leak === true) {\n var date = new Date();\n \n msg.payload = \"Water damage possible: \" + date.getDate() +\"/\"+ date.getMonth()+ \" Time: \"+ date.getHours() +\":\"+date.getMinutes();\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":880,"wires":[["d631b76d.8d62f8"]]},{"id":"d631b76d.8d62f8","type":"ui_text","z":"5b5ca77a.f14fb8","g":"e80ac6e0.658d58","group":"f3d1f402.7d8d18","order":2,"width":0,"height":0,"name":"Last event","label":"Last event: ","format":"{{msg.payload}}","layout":"row-spread","x":870,"y":880,"wires":[]},{"id":"b8847485.f0f1b8","type":"function","z":"5b5ca77a.f14fb8","g":"e80ac6e0.658d58","name":"Tamper","func":"if(msg.payload.tamper === false) {\n msg.payload = \"device functional\";\n \n}\nelse{\n msg.payload = \"water ingress\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":840,"wires":[["37e76e43.ecfe32"]]},{"id":"37e76e43.ecfe32","type":"ui_text","z":"5b5ca77a.f14fb8","g":"e80ac6e0.658d58","group":"f3d1f402.7d8d18","order":3,"width":0,"height":0,"name":"Tamper","label":"Device","format":"{{msg.payload}}","layout":"row-spread","x":860,"y":840,"wires":[]},{"id":"76c170ac.b7fa5","type":"function","z":"5b5ca77a.f14fb8","g":"e80ac6e0.658d58","name":"Range Fromat","func":"var range = msg.payload.linkquality;\nvar batteryV = msg.payload.voltage / 1000;\nvar batteryP = msg.payload.battery;\n\n//strong 130+\nif(range >= 130){\n msg.icon = \"signal_wifi_3_bar\";\n msg.colour = \"fill: green\";\n}\n//good 90-129\nif(range >= 90 && range < 130){\n msg.icon = \"signal_wifi_2_bar\";\n msg.colour = \"fill: blue\";\n}\n//medium 50-89\nif(range >= 50 && range < 90){\n msg.icon = \"signal_wifi_1_bar\";\n msg.colour = \"fill: orange\";\n}\n//low below <49\nif(range < 50){\n msg.icon = \"signal_wifi_0_bar\";\n msg.colour = \"fill: red\";\n}\n\nmsg.batteryP = \"Battery: \" + batteryP + \"%\";\nmsg.batteryV = \"Battery voltage: \" + batteryV + \"V\";\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":920,"wires":[["d93bd6e9.558798"]]},{"id":"d93bd6e9.558798","type":"ui_template","z":"5b5ca77a.f14fb8","g":"e80ac6e0.658d58","group":"f3d1f402.7d8d18","name":"Link and Battery","order":1,"width":6,"height":2,"format":"<ng-md-icon icon={{msg.icon}} style={{msg.colour}} size=\"50\"></ng-md-icon>\n\n<div ng-bind-html=\"msg.batteryP\"></div>\n<div ng-bind-html=\"msg.batteryV\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":880,"y":920,"wires":[[]]},{"id":"26a0255e.c51dea","type":"mqtt in","z":"5b5ca77a.f14fb8","g":"8e51635e.86845","name":"Vibration Sensor","topic":"zigbee2mqtt/0x00158d0001ddceb0","qos":"0","datatype":"json","broker":"24720c3b.ea60e4","nl":false,"rap":true,"rh":0,"x":340,"y":1120,"wires":[["642ec015.807d7","ad98122c.cff81","24816f0b.65e5e"]]},{"id":"642ec015.807d7","type":"function","z":"5b5ca77a.f14fb8","g":"8e51635e.86845","name":"Range Fromat","func":"var range = msg.payload.linkquality;\nvar batteryV = msg.payload.voltage / 1000;\nvar batteryP = msg.payload.battery;\n\n//strong 130+\nif(range >= 130){\n msg.icon = \"signal_wifi_3_bar\";\n msg.colour = \"fill: green\";\n}\n//good 90-129\nif(range >= 90 && range < 130){\n msg.icon = \"signal_wifi_2_bar\";\n msg.colour = \"fill: blue\";\n}\n//medium 50-89\nif(range >= 50 && range < 90){\n msg.icon = \"signal_wifi_1_bar\";\n msg.colour = \"fill: orange\";\n}\n//low below <49\nif(range < 50){\n msg.icon = \"signal_wifi_0_bar\";\n msg.colour = \"fill: red\";\n}\n\nmsg.batteryP = \"Battery: \" + batteryP + \"%\";\nmsg.batteryV = \"Battery voltage: \" + batteryV + \"V\";\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":1140,"wires":[["648747a3.5f5ca8"]]},{"id":"648747a3.5f5ca8","type":"ui_template","z":"5b5ca77a.f14fb8","g":"8e51635e.86845","group":"781fb3de.d369cc","name":"Link and Battery","order":1,"width":6,"height":2,"format":"<ng-md-icon icon={{msg.icon}} style={{msg.colour}} size=\"50\"></ng-md-icon>\n\n<div ng-bind-html=\"msg.batteryP\"></div>\n<div ng-bind-html=\"msg.batteryV\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":880,"y":1140,"wires":[[]]},{"id":"53707c12.48fde4","type":"ui_template","z":"5b5ca77a.f14fb8","g":"8e51635e.86845","group":"781fb3de.d369cc","name":"Position","order":1,"width":6,"height":2,"format":"\n\n<div ng-bind-html=\"msg.action\"></div>\n<div ng-bind-html=\"msg.time\"></div>\n<div ng-bind-html=\"msg.position\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":860,"y":1080,"wires":[[]]},{"id":"ad98122c.cff81","type":"function","z":"5b5ca77a.f14fb8","g":"8e51635e.86845","name":"Get trigger time","func":"if(msg.payload.action !== undefined){\n msg.action = \"Last action: \" + msg.payload.action;\n}\n\n\n\nvar date = new Date();\nmsg.time = \"Moved: \" + date.getDate() +\"/\"+ date.getMonth()+ \" Time: \"+ date.getHours() +\":\"+date.getMinutes();\nmsg.position = \"Position: X:\"+msg.payload.angle_x +\" | Y: \"+msg.payload.angle_y+\" | Z: \"+ msg.payload.angle_z \n+\"<br>\"+ \"Absolute: X: \"+msg.payload.angle_x_absolute +\" | Y: \" +msg.payload.angle_y_absolute;\n \nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":1080,"wires":[["53707c12.48fde4"]]},{"id":"2adc95ae.92dc8a","type":"debug","z":"5b5ca77a.f14fb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1410,"y":140,"wires":[]},{"id":"1dd61a2a.e56076","type":"debug","z":"5b5ca77a.f14fb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1430,"y":400,"wires":[]},{"id":"9a83b89f.b3b018","type":"debug","z":"5b5ca77a.f14fb8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1410,"y":640,"wires":[]},{"id":"3b47b4d3.32a19c","type":"debug","z":"5b5ca77a.f14fb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1430,"y":860,"wires":[]},{"id":"24816f0b.65e5e","type":"debug","z":"5b5ca77a.f14fb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1430,"y":1100,"wires":[]},{"id":"24720c3b.ea60e4","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"a16a53a9.053db","type":"ui_group","name":"Aqara PIR sensor","tab":"66618e35.02598","order":1,"disp":true,"width":"6","collapse":false},{"id":"4cfeefb0.f6aee","type":"ui_group","name":"Temperature Sensor","tab":"66618e35.02598","order":2,"disp":true,"width":"6","collapse":false},{"id":"30a2768d.b4ef4a","type":"ui_group","name":"Contact Sensor","tab":"66618e35.02598","order":3,"disp":true,"width":"6","collapse":false},{"id":"f3d1f402.7d8d18","type":"ui_group","name":"Water Leak","tab":"66618e35.02598","order":4,"disp":true,"width":"6","collapse":false},{"id":"781fb3de.d369cc","type":"ui_group","name":"Vibration sensor","tab":"66618e35.02598","order":5,"disp":true,"width":"6","collapse":false},{"id":"66618e35.02598","type":"ui_tab","name":"Aqara Sensors","icon":"dashboard","disabled":false,"hidden":false}]