Map device id to name and vice versa

Hi, I really wanted to write up and explain (one of many) ways you could achieve this but TBH, I am fairly hungover and found it easier just to knock up a demo (picture/flow worth a thousand words etc)...

[{"id":"911d97ae.52d498","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"8a23298a.31ec48","type":"inject","z":"911d97ae.52d498","name":"Init pulse","topic":"","payload":"","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":120,"y":60,"wires":[["e7219648.327ce8"]]},{"id":"e7219648.327ce8","type":"function","z":"911d97ae.52d498","name":"Initialise lookups","func":"var lookups = {};\nlookups.name2id = {}\nlookups.id2name = {}\nfunction addLookup(id, name){\n    lookups.name2id[name] = id;\n    lookups.id2name[id] = name;\n}\naddLookup(\"AC/0x01010101/1\",\"light-kitchen\");\naddLookup(\"AC/0x01010101/2\",\"light-bedroom\");\nflow.set(\"lookups\",lookups);\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":60,"wires":[[]]},{"id":"f7ae7749.be0018","type":"function","z":"911d97ae.52d498","name":"Lookup msg.id or msg.name","func":"var lookups = flow.get(\"lookups\");\nif(msg.id){\n    msg.payload = lookups.id2name[msg.id]; \n    return msg;\n}\nif(msg.name){\n    msg.payload = lookups.name2id[msg.name]; \n    return msg;\n}\nif(msg.topic == \"id\"){\n    msg.payload = lookups.id2name[msg.payload];\n    return msg;\n}\nif(msg.topic == \"name\"){\n    msg.payload = lookups.name2id[msg.payload]; \n    return msg;\n}\nnode.warn(`msg doesnt contain id or name - or - topic is not set to id or msg`);","outputs":1,"noerr":0,"x":540,"y":200,"wires":[["c2586736.09aee8"]]},{"id":"44b36164.832bb","type":"comment","z":"911d97ae.52d498","name":"Send msg.id & get name in msg.payload output","info":"","x":600,"y":140,"wires":[]},{"id":"5e148952.f5db18","type":"comment","z":"911d97ae.52d498","name":"OR Send msg.name & get id in msg.payload output","info":"","x":610,"y":170,"wires":[]},{"id":"42368843.ae3358","type":"inject","z":"911d97ae.52d498","name":"AC/0x01010101/1 (topic + payload)","topic":"id","payload":"AC/0x01010101/1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":120,"wires":[["f7ae7749.be0018"]]},{"id":"3ddcbdfc.723f22","type":"inject","z":"911d97ae.52d498","name":"inject","topic":"id","payload":"AC/0x01010101/1","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":200,"wires":[["d132b532.5fa188"]]},{"id":"d132b532.5fa188","type":"change","z":"911d97ae.52d498","name":"msg.id = AC/0x01010101/2","rules":[{"t":"set","p":"id","pt":"msg","to":"AC/0x01010101/2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":240,"wires":[["f7ae7749.be0018"]]},{"id":"e365d7ca.71d098","type":"inject","z":"911d97ae.52d498","name":"light-kitchen (topic + payload)","topic":"name","payload":"light-kitchen","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":160,"wires":[["f7ae7749.be0018"]]},{"id":"dc9efbb5.8f0fe8","type":"inject","z":"911d97ae.52d498","name":"inject","topic":"id","payload":"AC/0x01010101/1","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":280,"wires":[["5f332c43.24d824"]]},{"id":"5f332c43.24d824","type":"change","z":"911d97ae.52d498","name":"msg.name = light-bedroom","rules":[{"t":"set","p":"name","pt":"msg","to":"light-bedroom","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":320,"wires":[["f7ae7749.be0018"]]},{"id":"c2586736.09aee8","type":"debug","z":"911d97ae.52d498","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":540,"y":260,"wires":[]},{"id":"f8ad16a1.e11ce8","type":"comment","z":"911d97ae.52d498","name":"** Edit lookups here **","info":"","x":320,"y":20,"wires":[]}]

please take a look inside the nodes & understand the key parts (making a lookup object, storing it in flow context, retrieving it from flow context & retrieving values by name or id)