Last active
November 15, 2017 10:06
-
-
Save baflo/665bbd7af11c1076bbeb501a64157bd8 to your computer and use it in GitHub Desktop.
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":"dc3c225.be403e","type":"function","z":"302fd027.c80be","name":"Value","func":"const intent = msg.payload;\n\nfunction captured(re) {\n const match = re.exec(msg.payload);\n return match && match[1];\n}\n\nfunction findInIntent(termsMap) {\n for (let key in termsMap) {\n let t, re, cap;\n let terms = termsMap[key].slice();\n\n do {\n t = terms.shift();\n re = new RegExp(t, 'i');\n cap = captured(re);\n } while (t && !re.test(intent));\n \n if (t) return (cap || key);\n }\n}\n\nmsg.payload = findInIntent({\n TV: ['TV', 'Fernsehen'],\n Game: ['Wii', 'Game'],\n Tuner: ['Radio'],\n Net: ['Internet', 'Internetradio'],\n Aux1: ['Amazon', 'Fire', 'Aux', 'VAux'],\n Cable: ['Chromecast', 'Netflix', 'Google', 'Music'],\n});\n \nreturn msg;","outputs":1,"noerr":0,"x":754.0000457763672,"y":116.00000476837158,"wires":[["2ae25842.f371c8"]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment