[{"id":"c964194d.7ad5e8","type":"ha-api","z":"ffbd7f06.4a014","name":"areas","debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\": \"config/area_registry/list\"}","dataType":"json","location":"areas","locationType":"msg","responseType":"json","x":514,"y":944,"wires":[["4b011603.4c27f8"]]},{"id":"832ebec4.0d4a4","type":"inject","z":"ffbd7f06.4a014","name":"Manual Update","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":320,"y":944,"wires":[["c964194d.7ad5e8"]]},{"id":"4b011603.4c27f8","type":"ha-api","z":"ffbd7f06.4a014","name":"devices","debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\": \"config/device_registry/list\"}","dataType":"json","location":"devices","locationType":"msg","responseType":"json","x":654,"y":944,"wires":[["4be8b708.430ec8"]]},{"id":"4be8b708.430ec8","type":"ha-api","z":"ffbd7f06.4a014","name":"entities","debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\"type\": \"config/entity_registry/list\"}","dataType":"json","location":"entities","locationType":"msg","responseType":"json","x":798,"y":944,"wires":[["59e18ea8.03287"]]},{"id":"2538006.71ef4","type":"debug","z":"ffbd7f06.4a014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1144,"y":944,"wires":[]},{"id":"81c8e84.471e218","type":"server-events","z":"ffbd7f06.4a014","name":"","event_type":"state_changed","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":308,"y":1040,"wires":[["6e177280.669dec"]]},{"id":"59e18ea8.03287","type":"function","z":"ffbd7f06.4a014","name":"","func":"const entities = {};\n\nmsg.entities.forEach(e => {\n if(!e.device_id) return;\n \n const device = msg.devices.find(d => d.id === e.device_id);\n const area = msg.areas.find(a => a.area_id === device.area_id);\n if(area) {\n entities[e.entity_id] = {\n area_id: area.area_id,\n name: area.name\n };\n }\n});\n\nmsg.payload = entities;\nmsg.update = true;\nreturn msg;","outputs":1,"noerr":0,"x":964,"y":944,"wires":[["2538006.71ef4","6e177280.669dec"]]},{"id":"6e177280.669dec","type":"function","z":"ffbd7f06.4a014","name":"set area","func":"if(msg.update) {\n node.status({fill:\"green\", shape: \"dot\", text: \"Area Data Loaded\", })\n context.set(\"data\", msg.payload);\n return;\n}\nconst data = context.get(\"data\");\n\nif(!data) {\n node.status({fill:\"red\", shape: \"ring\", text: \"No Area Data\", })\n return;\n}\n\nconst area = data[msg.payload.entity_id];\nif(!area) return;\n\nmsg.area = area.name.toLowerCase(); \nnode.status({text: msg.area});\n\nreturn msg;","outputs":1,"noerr":0,"x":524,"y":1040,"wires":[["86100cd0.de8c5"]]},{"id":"582c98e0.5cd328","type":"debug","z":"ffbd7f06.4a014","name":"Kitchen","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":828,"y":1024,"wires":[]},{"id":"b60ead00.b4aaa","type":"debug","z":"ffbd7f06.4a014","name":"Bedroom","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":828,"y":1072,"wires":[]},{"id":"86100cd0.de8c5","type":"switch","z":"ffbd7f06.4a014","name":"","property":"area","propertyType":"msg","rules":[{"t":"eq","v":"kitchen","vt":"str"},{"t":"eq","v":"bedroom","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":656,"y":1040,"wires":[["582c98e0.5cd328"],["b60ead00.b4aaa"]]},{"id":"94d81549.f88148","type":"server-events","z":"ffbd7f06.4a014","name":"On Connect","event_type":"home_assistant_client","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":278,"y":896,"wires":[["72ef46c0.dbbce8"]]},{"id":"72ef46c0.dbbce8","type":"switch","z":"ffbd7f06.4a014","name":"connected","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"connected","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":896,"wires":[["c964194d.7ad5e8"]]},{"id":"47aad143.f438c","type":"server-events","z":"ffbd7f06.4a014","name":"entity_registry_updated","event_type":"entity_registry_updated","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":308,"y":752,"wires":[["c7d0582b.715958"]]},{"id":"58d3bcdb.d39014","type":"server-events","z":"ffbd7f06.4a014","name":"device_registry_updated","event_type":"device_registry_updated","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":318,"y":800,"wires":[["c7d0582b.715958"]]},{"id":"8a9f192c.425718","type":"server-events","z":"ffbd7f06.4a014","name":"area_registry_updated","event_type":"area_registry_updated","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":308,"y":848,"wires":[["c7d0582b.715958"]]},{"id":"c7d0582b.715958","type":"trigger","z":"ffbd7f06.4a014","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"Update at most every 10 secs","x":610,"y":800,"wires":[["c964194d.7ad5e8"]]}]