Last active
March 22, 2021 12:42
-
-
Save sstratoti/27145d25cd8dbc50363ee81b73745933 to your computer and use it in GitHub Desktop.
RoomAssistant Node Red Flow
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":"2c868d6d.c2ee2a","type":"http request","z":"b2a0a.3b747df7","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.150:6415/entities","tls":"","persist":false,"proxy":"","authType":"","x":710,"y":520,"wires":[["af857cc.d8fa8"]]},{"id":"c50bc7c8.db9c08","type":"inject","z":"b2a0a.3b747df7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":230,"y":580,"wires":[["2c868d6d.c2ee2a"]]},{"id":"af857cc.d8fa8","type":"function","z":"b2a0a.3b747df7","name":"","func":"msg.notification = '';\nmsg.notification_in = '';\n\nfor (i=0; i < msg.payload.length; i++){\n \n if (msg.payload[i].name == \"Steves-iPhone-BLE Room Presence\"){\n\n if (msg.payload[i].distances['Living Room'].outOfRange) {\n msg.notification += \"<br> Living Room Out Of Range (\" + msg.payload[i].distances['Living Room'].distance + \")\";\n } else {\n msg.notification_in += \" <br> Living Room (\" + msg.payload[i].distances['Living Room'].distance + \")\";\n }\n \n if (msg.payload[i].distances['Kitchen'].outOfRange) {\n msg.notification += \" <br> Kitchen Out Of Range (\" + msg.payload[i].distances['Kitchen'].distance + \")\";\n } else {\n msg.notification_in += \" <br> Kitchen (\" + msg.payload[i].distances['Kitchen'].distance + \")\";\n }\n \n if (msg.payload[i].distances['Basement'].outOfRange) {\n msg.notification += \" <br> Basement Out Of Range (\" + msg.payload[i].distances['Basement'].distance + \")\";\n } else {\n msg.notification_in += \" <br> Basement (\" + msg.payload[i].distances['Basement'].distance + \")\";\n }\n \n if (msg.payload[i].distances['Master Bedroom'].outOfRange) {\n msg.notification += \" <br> Master Bedroom Out Of Range (\" + msg.payload[i].distances['Master Bedroom'].distance + \")\";\n } else {\n msg.notification_in += \" <br> Master Bedroom (\" + msg.payload[i].distances['Master Bedroom'].distance + \")\";\n }\n \n if (msg.payload[i].distances['Nursery'].outOfRange) {\n msg.notification += \"<br> Nursery Out Of Range (\" + msg.payload[i].distances['Nursery'].distance + \")\";\n } else {\n msg.notification_in += \"<br> Nursery (\" + msg.payload[i].distances['Nursery'].distance + \")\";\n }\n \n if (msg.payload[i].distances['Office'].outOfRange) {\n msg.notification += \"<br> Office Out Of Range (\" + msg.payload[i].distances['Office'].distance + \")\";\n } else {\n msg.notification_in += \"<br> Office (\" + msg.payload[i].distances['Office'].distance + \")\";\n }\n \n }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":640,"wires":[["4bbd0c40.2a7d84","899b8cd3.96889"]]},{"id":"4bbd0c40.2a7d84","type":"ha-entity","z":"b2a0a.3b747df7","name":"ra_ble_tracker_in","server":"74f36281.ae094c","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"ra_ble_tracker_in"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"notification_in","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1070,"y":640,"wires":[[]]},{"id":"899b8cd3.96889","type":"ha-entity","z":"b2a0a.3b747df7","name":"ra_ble_tracker","server":"74f36281.ae094c","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"ra_ble_tracker"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"notification","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1060,"y":700,"wires":[[]]},{"id":"df632531.eb0868","type":"server-state-changed","z":"b2a0a.3b747df7","name":"BLE State Change","server":"74f36281.ae094c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.steves_iphone_ble_room_presence","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is_not","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":180,"y":640,"wires":[["96006fe5.6d955"]]},{"id":"96006fe5.6d955","type":"change","z":"b2a0a.3b747df7","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":640,"wires":[["af28cfb5.329258"]]},{"id":"af28cfb5.329258","type":"looptimer","z":"b2a0a.3b747df7","duration":"20","units":"Second","maxloops":"100","maxtimeout":"1","maxtimeoutunits":"Hour","name":"","x":600,"y":580,"wires":[["2c868d6d.c2ee2a"],[]]},{"id":"74f36281.ae094c","type":"server","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment