|
本帖最后由 姚远 于 2020-6-5 10:16 编辑
家里好几个小度音箱,一直想接入自动化流程进行语音播报。之前,hass的小度dlna有问题,就搁置了下来。新版hass已经可以正常使用小度dlna了,于是又重新燃起了接入node-red自动化的想法。在网上查了好多dlna相关内容,越来越懵圈。昨天试着论坛教程安装Airplay TTS,可惜没有成功。这个dlna到底是啥东西?小度音箱还能不能接入node-red了?我就想搞个语音播报,也没啥奢求啊。今天下定决心,搞出这个流程。走捷径,直接在Node-red里调用hass服务。
调用方法,参考大神的小爱tts语音播报:https://bbs.hassbian.com/thread-6424-1-2.html
前提:可以在hass下调用tts服务播报到dlna音箱
流程:
上图
流程json
[{"id":"cb734470.d12928","type":"inject","z":"640378a7.2a5608","name":"","topic":"","payload":"哈喽,我是小度","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":260,"wires":[["2fdae6ec.fe672a"]]},{"id":"92beaf55.c447c","type":"api-call-service","z":"640378a7.2a5608","name":"语音播报","server":"bab09590.5967f8","version":1,"debugenabled":true,"service_domain":"tts","service":"baidu_say","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":880,"y":260,"wires":[[]]},{"id":"2fdae6ec.fe672a","type":"function","z":"640378a7.2a5608","name":"tts播报数据","func":"// 获取上一个流程的msg信息,构建服务百度tts服务的数据\n\na = msg.payload;\nmsg.payload = {};\nmsg.payload.data = {\n "entity_id": "media_player.xiao_du_zhi_neng_yin_xiang_2811",\n "message":a,\n "cache":"false"}\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":260,"wires":[["92beaf55.c447c","5aca69d0.023328"]]},{"id":"5aca69d0.023328","type":"debug","z":"640378a7.2a5608","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":220,"wires":[]},{"id":"bab09590.5967f8","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
应用示例
示例 json
[{"id":"628f2437.a7bd4c","type":"debug","z":"47279dd.c1ef264","name":"显示调试信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1680,"y":420,"wires":[]},{"id":"f8d52d6f.f629e","type":"api-call-service","z":"47279dd.c1ef264","name":"语音播报","server":"bab09590.5967f8","version":1,"debugenabled":true,"service_domain":"tts","service":"baidu_say","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1670,"y":460,"wires":[[]]},{"id":"3203e39a.b2f21c","type":"function","z":"47279dd.c1ef264","name":"tts播报数据","func":"a = "现在播报测试信息。厨房湿度差值是" + msg.payload;\nmsg.payload = {};\nmsg.payload.data = {\n "entity_id": "media_player.xiao_du_zhi_neng_yin_xiang_2811",\n "message":a,\n "cache":"false"}\nreturn msg;","outputs":1,"noerr":0,"x":1490,"y":460,"wires":[["f8d52d6f.f629e","628f2437.a7bd4c"]]},{"id":"a5af4f27.4afce","type":"comment","z":"47279dd.c1ef264","name":"语音提示测试信息","info":"在主卧小度音箱上,收听“可以驱动后续路程”的温度差值\n限定在非睡眠时间范围内\n属于临时性播报","x":1430,"y":420,"wires":[]},{"id":"bab09590.5967f8","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
小度音箱终于可以接入Node-red了
太奇怪了,贴在这里的json竟然不可用。补上文件
|
|