-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"id":"d00bf2f4.065a6","type":"tab","label":"流程1","disabled":false,"info":""},{"id":"ef681dc8.d925d","type":"http in","z":"d00bf2f4.065a6","name":"","url":"/xiaoai_hook/event","method":"post","upload":false,"swaggerDoc":"","x":1950,"y":320,"wires":[["4b2767a0.b5b7d8","206a348f.0a664c","50314ca8.255e24"]]},{"id":"d74ed5df.70e278","type":"debug","z":"d00bf2f4.065a6","name":"全局调试","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2420,"y":400,"wires":[]},{"id":"73005c96.da10e4","type":"http in","z":"d00bf2f4.065a6","name":"","url":"/xiaoai_hook/keyword","method":"get","upload":false,"swaggerDoc":"","x":1950,"y":480,"wires":[["1dbc59d1.310b76"]]},{"id":"869b1c46.24f34","type":"http response","z":"d00bf2f4.065a6","name":"","statusCode":"200","headers":{},"x":2420,"y":480,"wires":[]},{"id":"1dbc59d1.310b76","type":"function","z":"d00bf2f4.065a6","name":"小爱拦截词","func":"// 多个关键词以竖线分割\nmsg.payload = `厕所|卫生间`\nreturn msg","outputs":1,"noerr":0,"x":2230,"y":480,"wires":[["869b1c46.24f34"]]},{"id":"4b2767a0.b5b7d8","type":"function","z":"d00bf2f4.065a6","name":"处理捕获指令","func":"// 指令词列表\n// 一行一个设备,对于一个设备的多个指令词可用,分割\nconst list = [\n '厕所有人吗,卫生间有人吗',\n]\n\n\n// === 以下内容大多数情况不用改 ====\nlet queries = []\ntry {\n queries = JSON.parse(msg.payload.res).response.answer[0].text;\n} catch (e) {\n}\nmsg.queries = queries\nmsg.list = list\nmsg.matched = !!list.filter((item, index) => {\n matched = ~item.indexOf(queries).length\n matched && (msg.matched_index = index)\n return matched\n}).length\n\nreturn msg;","outputs":1,"noerr":0,"x":2240,"y":320,"wires":[["378f06e8.9822da"]]},{"id":"7df9fe57.47dcf","type":"switch","z":"d00bf2f4.065a6","name":"","property":"matched_index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2590,"y":620,"wires":[["263d7b44.fbe094"]]},{"id":"7b246ac2.9611e4","type":"comment","z":"d00bf2f4.065a6","name":"在这里统一配置响应词以及TTS文案","info":"","x":2300,"y":240,"wires":[]},{"id":"378f06e8.9822da","type":"switch","z":"d00bf2f4.065a6","name":"","property":"matched","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","repair":false,"outputs":2,"x":2430,"y":320,"wires":[["2beaee9a.e73382"],["7df9fe57.47dcf"]]},{"id":"6d18ab6b.c01194","type":"comment","z":"d00bf2f4.065a6","name":"在这里配置小爱的拦截词","info":"","x":2270,"y":520,"wires":[]},{"id":"8ae85959.3aba48","type":"comment","z":"d00bf2f4.065a6","name":"卫生间有人吗","info":"","x":2770,"y":400,"wires":[]},{"id":"2beaee9a.e73382","type":"function","z":"d00bf2f4.065a6","name":"默认回复","func":"answer = msg.payload.answer || '你说的是啥'\nmsg.payload ={method: \"TTS\", jsonrpc: \"2.0\", id: 0, params: {token: \"123456\", msg: answer}}\nreturn msg","outputs":1,"noerr":0,"x":2920,"y":320,"wires":[["76dd1275.20d05c"]]},{"id":"206a348f.0a664c","type":"http response","z":"d00bf2f4.065a6","name":"","statusCode":"200","headers":{},"x":2220,"y":280,"wires":[]},{"id":"263d7b44.fbe094","type":"api-current-state","z":"d00bf2f4.065a6","name":"厕所灯","server":"5811c904.4fe268","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.wall_switch_right_158d0003a23208","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":2770,"y":440,"wires":[["8dcb9b4.86b8f68"],["a8bc775a.7aa448"]]},{"id":"8dcb9b4.86b8f68","type":"function","z":"d00bf2f4.065a6","name":"有人","func":"place = msg.queries.startsWith(\"厕\") ? \"厕所\" : \"卫生间\"\nmsg.payload ={method: \"TTS\", jsonrpc: \"2.0\", id: 0, params: {token: \"123456\", msg: `${place}有人,空闲时我会提醒你的`}}\nreturn msg;","outputs":1,"noerr":0,"x":2930,"y":420,"wires":[["76dd1275.20d05c","d27e8eb5.d38dc"]]},{"id":"96e6e537.5a0538","type":"debug","z":"d00bf2f4.065a6","name":"全局调试","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3300,"y":620,"wires":[]},{"id":"76dd1275.20d05c","type":"http request","z":"d00bf2f4.065a6","name":"TTS","method":"POST","ret":"obj","paytoqs":false,"url":"http://172.16.1.15:18888/jsonrpc","tls":"","persist":false,"proxy":"","authType":"","x":3150,"y":620,"wires":[["96e6e537.5a0538"]]},{"id":"a8bc775a.7aa448","type":"function","z":"d00bf2f4.065a6","name":"没人","func":"place = msg.queries.startsWith(\"厕\") ? \"厕所\" : \"卫生间\"\nmsg.payload ={method: \"TTS\", jsonrpc: \"2.0\", id: 0, params: {token: \"123456\", msg: `${place}没人`}}\n\nreturn msg;","outputs":1,"noerr":0,"x":2930,"y":460,"wires":[["76dd1275.20d05c"]]},{"id":"50314ca8.255e24","type":"json","z":"d00bf2f4.065a6","name":"","property":"payload.res","action":"","pretty":false,"x":2230,"y":400,"wires":[["d74ed5df.70e278"]]},{"id":"d27e8eb5.d38dc","type":"ha-wait-until","z":"d00bf2f4.065a6","name":"等待厕所没人","server":"5811c904.4fe268","outputs":1,"entityId":"switch.wall_switch_right_158d0003a23208","entityIdFilterType":"exact","property":"state","comparator":"is","value":"off","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":3140,"y":420,"wires":[["1e54ee5c.93e382"]]},{"id":"1e54ee5c.93e382","type":"function","z":"d00bf2f4.065a6","name":"提示停止占用","func":"place = msg.querie.startsWith(\"厕\") ? \"厕所\" : \"卫生间\"\nmsg.payload ={method: \"TTS\", jsonrpc: \"2.0\", id: 0, params: {token: \"123456\", msg: `${place}没人了,快去吧`}}\nreturn msg;","outputs":1,"noerr":0,"x":3320,"y":420,"wires":[["76dd1275.20d05c"]]},{"id":"5811c904.4fe268","type":"server","z":"","name":"Home Assistant","addon":true}] | ||
[{"id":"b942fdc6.591d3","type":"tab","label":"流程1","disabled":false,"info":""},{"id":"e09c6f09.32737","type":"http in","z":"b942fdc6.591d3","name":"","url":"/xiaoai_hook/event","method":"post","upload":false,"swaggerDoc":"","x":1950,"y":320,"wires":[["da9d03b7.b6914","df4d043e.f5c8a8","65a073c8.be1aec"]]},{"id":"5dc48208.d6b39c","type":"debug","z":"b942fdc6.591d3","name":"全局调试","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2440,"y":400,"wires":[]},{"id":"f3cb369d.333f08","type":"http in","z":"b942fdc6.591d3","name":"","url":"/xiaoai_hook/keyword","method":"get","upload":false,"swaggerDoc":"","x":1950,"y":480,"wires":[["483fc3e5.f5c01c"]]},{"id":"496a57cf.81fe68","type":"http response","z":"b942fdc6.591d3","name":"","statusCode":"200","headers":{},"x":2420,"y":480,"wires":[]},{"id":"483fc3e5.f5c01c","type":"function","z":"b942fdc6.591d3","name":"小爱拦截词","func":"// 多个关键词以竖线分割\nmsg.payload = `厕所|卫生间`\nreturn msg","outputs":1,"noerr":0,"x":2230,"y":480,"wires":[["496a57cf.81fe68"]]},{"id":"da9d03b7.b6914","type":"function","z":"b942fdc6.591d3","name":"处理捕获指令","func":"// 指令词列表\n// 一行一个设备,对于一个设备的多个指令词可用,分割\nconst list = [\n '厕所有人吗,卫生间有人吗',\n]\n\n\n// === 以下内容大多数情况不用改 ====\nlet queries = \"\";\ntry {\n queries = JSON.parse(msg.payload.res).response.answer[0].intention.query;\n} catch (e) {\n}\nmsg.queries = queries\nmsg.list = list\nmsg.matched=list.map( keys => keys.split(',').some(k => msg.queries.indexOf(k) > -1) ).indexOf(true);\nreturn msg;","outputs":1,"noerr":0,"x":2240,"y":320,"wires":[["b4e8cf73.06b12","5dc48208.d6b39c"]]},{"id":"ff73c9ae.50b1c8","type":"comment","z":"b942fdc6.591d3","name":"在这里统一配置响应词以及TTS文案","info":"","x":2300,"y":240,"wires":[]},{"id":"b4e8cf73.06b12","type":"switch","z":"b942fdc6.591d3","name":"","property":"matched","propertyType":"msg","rules":[{"t":"eq","v":"-1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2590,"y":320,"wires":[["d5b7d6e4.6bf618"],["96560f39.c35b4"]]},{"id":"b2076bf3.868a28","type":"comment","z":"b942fdc6.591d3","name":"在这里配置小爱的拦截词","info":"","x":2270,"y":520,"wires":[]},{"id":"15903827.e9afb8","type":"comment","z":"b942fdc6.591d3","name":"卫生间有人吗","info":"","x":2770,"y":400,"wires":[]},{"id":"d5b7d6e4.6bf618","type":"function","z":"b942fdc6.591d3","name":"默认回复","func":"answer = msg.payload.answer || '你说的是啥'\nmsg.payload ={method: \"TTS\", jsonrpc: \"2.0\", id: 0, params: {token: \"123456\", msg: answer}}\nreturn msg","outputs":1,"noerr":0,"x":2920,"y":320,"wires":[["6bca25c3.7220cc"]]},{"id":"df4d043e.f5c8a8","type":"http response","z":"b942fdc6.591d3","name":"","statusCode":"200","headers":{},"x":2220,"y":280,"wires":[]},{"id":"96560f39.c35b4","type":"api-current-state","z":"b942fdc6.591d3","name":"厕所灯","server":"5811c904.4fe268","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.wall_switch_right_158d0003a23208","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":true,"x":2770,"y":440,"wires":[["a54d97d9.082348"],["ea7bcb5c.c72188"]]},{"id":"a54d97d9.082348","type":"function","z":"b942fdc6.591d3","name":"有人","func":"place = msg.queries.startsWith(\"厕\") ? \"厕所\" : \"卫生间\"\nmsg.payload ={method: \"TTS\", jsonrpc: \"2.0\", id: 0, params: {token: \"123456\", msg: `${place}有人空闲时我会提醒你的`}}\nreturn msg;","outputs":1,"noerr":0,"x":2930,"y":420,"wires":[["6bca25c3.7220cc","8f95fa01.0c74c8"]]},{"id":"2fe9023a.b51dee","type":"debug","z":"b942fdc6.591d3","name":"全局调试","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3300,"y":620,"wires":[]},{"id":"6bca25c3.7220cc","type":"http request","z":"b942fdc6.591d3","name":"TTS","method":"POST","ret":"obj","paytoqs":false,"url":"http://172.16.1.200:18888/","tls":"","persist":false,"proxy":"","authType":"","x":3150,"y":620,"wires":[["2fe9023a.b51dee"]]},{"id":"ea7bcb5c.c72188","type":"function","z":"b942fdc6.591d3","name":"没人","func":"place = msg.queries.startsWith(\"厕\") ? \"厕所\" : \"卫生间\"\nmsg.payload ={method: \"TTS\", jsonrpc: \"2.0\", id: 0, params: {token: \"123456\", msg: `${place}没人`}}\n\nreturn msg;","outputs":1,"noerr":0,"x":2930,"y":460,"wires":[["6bca25c3.7220cc"]]},{"id":"65a073c8.be1aec","type":"json","z":"b942fdc6.591d3","name":"","property":"payload.res","action":"","pretty":false,"x":2230,"y":400,"wires":[[]]},{"id":"8f95fa01.0c74c8","type":"ha-wait-until","z":"b942fdc6.591d3","name":"等待厕所没人","server":"5811c904.4fe268","outputs":1,"entityId":"switch.wall_switch_right_158d0003a23208","entityIdFilterType":"exact","property":"state","comparator":"is","value":"off","valueType":"str","timeout":0,"timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":3140,"y":420,"wires":[["6c37670c.990088"]]},{"id":"6c37670c.990088","type":"function","z":"b942fdc6.591d3","name":"提示停止占用","func":"place = msg.queries.startsWith(\"厕\") ? \"厕所\" : \"卫生间\"\nmsg.payload ={method: \"TTS\", jsonrpc: \"2.0\", id: 0, params: {token: \"123456\", msg: `${place}没人了快去吧`}}\nreturn msg;","outputs":1,"noerr":0,"x":3320,"y":420,"wires":[["6bca25c3.7220cc"]]},{"id":"2dc6130b.20bbcc","type":"inject","z":"b942fdc6.591d3","name":"","topic":"","payload":"{\"method\": \"TTS\", \"jsonrpc\": \"2.0\", \"id\": 0, \"params\": {\"token\": \"123456\", \"msg\": \"hello\"}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":2830,"y":620,"wires":[["6bca25c3.7220cc"]]},{"id":"5811c904.4fe268","type":"server","z":"","name":"Home Assistant","addon":true}] |