-
Notifications
You must be signed in to change notification settings - Fork 2
/
3-determine-room-to-clean.json
1 lines (1 loc) · 5.5 KB
/
3-determine-room-to-clean.json
1
[{"id":"a48833c0.872e2","type":"group","z":"bac0ac5d.f875f","name":"Find Room with Highest Debris.","style":{"label":true},"nodes":["d4f91b46.4766a","266459ff.512d76","f0b8d6bc.f13a8","a76937fc.7ae76","5676b99.f371248","f1b9c10.fe2624","2b613421.3640d4","2eed7f4b5df9bd9e"],"x":34,"y":719,"w":1282,"h":162},{"id":"d4f91b46.4766a","type":"api-current-state","z":"bac0ac5d.f875f","g":"a48833c0.872e2","name":"Highest debris","server":"a9289a5f.5ca3f8","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.debris_{{vacuum_name}}_next_room","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"maxdebris","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":200,"y":800,"wires":[["5676b99.f371248"]],"info":"Pull the highest debris value for the area this vacuum can clean. We can reverse engineer this information to determine which room segment it is."},{"id":"266459ff.512d76","type":"ha-get-entities","z":"bac0ac5d.f875f","g":"a48833c0.872e2","name":"Any Room","server":"a9289a5f.5ca3f8","version":0,"rules":[{"property":"entity_id","logic":"is","value":"^input_number.debris.*_level$","valueType":"re"},{"property":"state","logic":"is","value":"maxdebris","valueType":"msg"}],"output_type":"random","output_empty_results":false,"output_location_type":"msg","output_location":"room","output_results_count":1,"x":590,"y":760,"wires":[["2b613421.3640d4"]],"info":"Find the room that matches the highest debris. "},{"id":"f0b8d6bc.f13a8","type":"link in","z":"bac0ac5d.f875f","g":"a48833c0.872e2","name":"","links":["7d6c1fbb.3e0ea8","8155ceb1.ae44c","284ab485.c77244","5fab1766.230fb8"],"x":75,"y":800,"wires":[["d4f91b46.4766a"]]},{"id":"a76937fc.7ae76","type":"link out","z":"bac0ac5d.f875f","g":"a48833c0.872e2","name":"","links":["9b14d54.ca737a8"],"x":1275,"y":800,"wires":[]},{"id":"5676b99.f371248","type":"api-current-state","z":"bac0ac5d.f875f","g":"a48833c0.872e2","name":"Request Queue?","server":"a9289a5f.5ca3f8","version":2,"outputs":2,"halt_if":"0","halt_if_type":"num","halt_if_compare":"gt","entity_id":"counter.vacuum_{{vacuum_name}}_cleaning_queue","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":390,"y":800,"wires":[["266459ff.512d76"],["f1b9c10.fe2624"]],"info":"If the current vacuum was triggered by the queue counter, use the upper path. The upper path allows rooms with less than 1.0 debris to be valid cleaning targets."},{"id":"f1b9c10.fe2624","type":"ha-get-entities","z":"bac0ac5d.f875f","g":"a48833c0.872e2","name":"Dirty Rooms","server":"a9289a5f.5ca3f8","version":0,"rules":[{"property":"entity_id","logic":"is","value":"^input_number.debris.*_level$","valueType":"re"},{"property":"state","logic":"is","value":"maxdebris","valueType":"msg"},{"property":"state","logic":"gte","value":"1.0","valueType":"num"}],"output_type":"random","output_empty_results":false,"output_location_type":"msg","output_location":"room","output_results_count":1,"x":590,"y":840,"wires":[["2b613421.3640d4"]],"info":"Find the room that matches the highest debris, but only if it is above 1.0. If it is less than 1.0 the payload is blocked and the vacuum will not run."},{"id":"2b613421.3640d4","type":"function","z":"bac0ac5d.f875f","g":"a48833c0.872e2","name":"Room Segments","func":"// Using the name of the entity from the previous node, text is stripped\n// away until we are left with a simple room name. \nmsg.room = msg.room.entity_id.replace(\"_level\",\"\").replace(\"input_number.debris_\",\"\")\nflow.set(msg.vacuum_name + \"_room\",msg.room)\n\n// Figure out which segment(s). You will need to add the segment numbers manually.\n// See the segment finder flow for information on determining the segments.\nvar segments = {\n // Upper level - Shadow\n\t\"upper_hall\": 16,\n \"upper_office\": 17,\n \"bedroom\": [20,22],\n \"bathroom\": 21,\n \"guest_bathroom\": 19,\n \"guest_room\": 0, // Not defined\n\n // Main level - Maxine\n \"foyer\": 17,\n \"dining_room\": 18,\n \"living_room\": 21,\n \"kitchen_bar\": 24,\n \"kitchen_prep\": 20,\n\n // Lower level - Rose\n \"washroom\": 2,\n \"utility_hall\": 18,\n \"utility_room\": 20,\n \"family_room\": 16,\n \"office\": 17\n};\nmsg.segment = segments[msg.room]\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":890,"y":800,"wires":[["a76937fc.7ae76"]]},{"id":"2eed7f4b5df9bd9e","type":"comment","z":"bac0ac5d.f875f","g":"a48833c0.872e2","name":"","info":"This section determines which room to vacuum. If it is a request queue, it takes the upper path that does not have a minimum debris requirement. \n\nYou'll need to add your rooms to the room segment function. They should be formatted as they are in the debris entities; all lower case and with underscores instead of spaces such as \"living_room\" or \"dining room\". Mine are grouped by vacuum.","x":900,"y":760,"wires":[]},{"id":"a9289a5f.5ca3f8","type":"server","name":"Aldersgate","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]