利用企业微信通过语音、文本方式控制homeassistant的设备

NR本人用得很少,首先是懒得折腾,其次是没有找到感兴趣的地方今天这个只是试试水,对我来说也没有多大实用性
需要的NR节点:
1、node-red-contrib-bizwechat https://bbs.iobroker.cn/t/topic/662/1
2、node-red-contrib-home-assistant-websocket
以上节点需要配置好
尤其是node-red-contrib-bizwechat需要注意配置好百度语音API相关参数

后面就根据你自身的实际情况设置switch里面的关键字词了
本打算全部做到function的,但是感觉不够直观,无法发挥NR这种傻瓜式操作的优势

[{"id":"4ac7ced5.541c68","type":"bizwechat-input","z":"1d0549d3.dc3ef6","name":"企业微信指令查询操作","bizwechat":"","x":100,"y":400,"wires":[["338d80a5.b3fed"]]},{"id":"338d80a5.b3fed","type":"function","z":"1d0549d3.dc3ef6","name":"指令类型判断","func":"//判断是语音还是文本指令\nvar MsgContent;\nif(msg.message.MsgType == \"text\"){\n\tMsgContent = msg.message.Content;\n}\nelse if(msg.message.MsgType == \"voice\"){\n\tMsgContent = msg.message.AsrContent[0];\n//\tMsgContent = MsgContent.substr(0, MsgContent.length - 1); \n}\n\nmsg.MsgContent = MsgContent;\n\nreturn msg;\n","outputs":1,"noerr":0,"x":300,"y":400,"wires":[["9cea068d.a6e8e8"]]},{"id":"9cea068d.a6e8e8","type":"switch","z":"1d0549d3.dc3ef6","name":"","property":"MsgContent","propertyType":"msg","rules":[{"t":"cont","v":"卧室的灯","vt":"str"},{"t":"cont","v":"卧室灯","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":450,"y":400,"wires":[["1b85c0ee.9d190f"],["1b85c0ee.9d190f"],["3fd955f4.12ac72"]]},{"id":"1b85c0ee.9d190f","type":"change","z":"1d0549d3.dc3ef6","name":"卧室灯","rules":[{"t":"set","p":"payload.data.entity_id","pt":"msg","to":"switch.livingroom_light","tot":"str"},{"t":"set","p":"payload.domain","pt":"msg","to":"switch","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":80,"wires":[["40c0bd1c.2bf82c"]]},{"id":"40c0bd1c.2bf82c","type":"switch","z":"1d0549d3.dc3ef6","name":"","property":"MsgContent","propertyType":"msg","rules":[{"t":"cont","v":"打开","vt":"str"},{"t":"cont","v":"关闭","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":80,"wires":[["adbfdab4.b755e"],["e1adf235.d1f76"]]},{"id":"adbfdab4.b755e","type":"change","z":"1d0549d3.dc3ef6","name":"","rules":[{"t":"set","p":"payload.service","pt":"msg","to":"turn_on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":60,"wires":[["ccb978b.236ef88"]]},{"id":"e1adf235.d1f76","type":"change","z":"1d0549d3.dc3ef6","name":"","rules":[{"t":"set","p":"payload.service","pt":"msg","to":"turn_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":100,"wires":[["ccb978b.236ef88"]]},{"id":"ccb978b.236ef88","type":"api-call-service","z":"1d0549d3.dc3ef6","name":"","server":"","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1090,"y":80,"wires":[["30727fdc.3b14b8"]]},{"id":"30727fdc.3b14b8","type":"function","z":"1d0549d3.dc3ef6","name":"执行成功","func":"msg.payload = {\n   \"touser\" : `${msg.message.FromUserName}`,\n   \"msgtype\" : \"text\",//消息类型\n   \"agentid\" : 1000002,//这里填你自建应用的AgentId\n   \"text\" : {\n\t   \"content\" : msg.MsgContent+\"执行成功!\"\n   },\n   \"safe\":0\n}\nreturn msg;","outputs":1,"noerr":0,"x":1260,"y":320,"wires":[["6040be3d.73de78"]]},{"id":"6040be3d.73de78","type":"bizwechat-push","z":"1d0549d3.dc3ef6","name":"","bizwechat":"c011217f.786c88","x":1400,"y":320,"wires":[[]]},{"id":"3fd955f4.12ac72","type":"function","z":"1d0549d3.dc3ef6","name":"无法识别指令","func":"msg.payload = {\n   \"touser\" : `${msg.message.FromUserName}`,\n   \"msgtype\" : \"text\",//消息类型\n   \"agentid\" : 1000002,//这里填你自建应用的AgentId\n   \"text\" : {\n\t   \"content\" : \"无法识别指令:\"+msg.MsgContent\n   },\n   \"safe\":0\n}\nreturn msg;","outputs":1,"noerr":0,"x":660,"y":640,"wires":[["3cabdf1e.ccbd78"]]},{"id":"3cabdf1e.ccbd78","type":"bizwechat-push","z":"1d0549d3.dc3ef6","name":"","bizwechat":"c011217f.786c88","x":860,"y":640,"wires":[[]]},{"id":"c011217f.786c88","type":"bizwechat-configurator","z":"","name":"企业微信推送","port":"","corpid":"","agentid":"","corpsecret":"","url":"","token":"","aeskey":"","client_id":"","client_secret":""}]

这里的代码可以重新粘贴一下吗?也是无法复制到node-red里,而且缺少node-red里的截图,如果是代码错误,照着截图或许也能设置出来,就是费点劲,现在是没有图片呢?

json已更新。请重新试一下

厉害,太好了。我一直没搞明白语音转文本,这个实例写的非常清楚

判断实体和服务的switch节点,可以用表达式吗,一条一条的写,如果设备多的话,太麻烦。
$match(msg.MsgContent,/“客厅窗帘”|‘客厅的窗帘’|‘客厅里的窗帘’|‘客厅里面的窗帘’/,1)
我这个表达式有问题,不管输入什么,都返回的是true的内容
大佬能指点下吗

请问大佬如何利用桌面端软件或网页通过语音甚至文字控制homeassistant?
使用场景是,我的雷蛇键盘有Hypershift功能,可设置一键启动任意程序或网页
当我需要小爱同学控制设备时,不再是喊小爱同学或拿出手机
而是通过一键启动程序或网页。利用PC 麦克风,或输入文本进行控制homeassistant的设备