原理简述
- 通过request获取农历及节假日json消息
- 通过moment节点转换时间需自行安装]
- 通过小爱TTS节点播报
小爱TTS节点
省略
流程
{"id":"cbb555dd.01e538","type":"function","z":"6469eaf7.924d94","name":"获取当前时间戳","func":"var now = new Date();\nvar timestamp = Date.parse(new Date());\nmsg.timestamp = timestamp;\nreturn msg","outputs":1,"noerr":0,"x":480,"y":1580,"wires":"2d75fb0c.814834"]]},{"id":"b514ae80.8dffb","type":"function","z":"6469eaf7.924d94","name":"记录内容","func":"msg.payload = {};\nmsg.payload = msg.time;\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":1580,"wires":"4dc16efa.b7e54"]]},{"id":"1db65ec7.117f61","type":"inject","z":"6469eaf7.924d94","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":1580,"wires":"cbb555dd.01e538"]]},{"id":"2d75fb0c.814834","type":"moment","z":"6469eaf7.924d94","name":"转换时间格式","topic":"","input":"timestamp","inputType":"msg","inTz":"Asia/Shanghai","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"C","output":"time","outputType":"msg","outTz":"Asia/Shanghai","x":680,"y":1580,"wires":"b514ae80.8dffb"]]},{"id":"4dc16efa.b7e54","type":"http request","z":"6469eaf7.924d94","name":"获取农历及节假日json","method":"GET","ret":"obj","paytoqs":false,"url":"https://www.sojson.com/open/api/lunar/json.shtml","tls":"","proxy":"","authType":"","x":1080,"y":1580,"wires":"6712b898.33c178","96a65c14.fa3"]]},{"id":"611eaa03.f300c4","type":"debug","z":"6469eaf7.924d94","name":"调式信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1520,"y":1540,"wires":]},{"id":"6712b898.33c178","type":"function","z":"6469eaf7.924d94","name":"推送农历及节日","func":"//获取节日列表\nvar festivalList = \"今天是\"];\nfor (var i = 0; i < msg.payload.data.festivalList.length; i++){\n festivalList.push(\" \" +msg.payload.data.festivalList* + \"\\n\");\n}\n//整合消息\nmsg.payload = `现在是${msg.time},农历${msg.payload.data.cnmonth}月${msg.payload.data.cnday},${msg.payload.data.cyclicalMonth}月${msg.payload.data.cyclicalDay}日,${festivalList}`;\nreturn msg;","outputs":1,"noerr":0,"x":1320,"y":1580,"wires":"611eaa03.f300c4","2f111501.70fbea"]]},{"id":"96a65c14.fa3","type":"debug","z":"6469eaf7.924d94","name":"调式信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1220,"y":1680,"wires":]},{"id":"2f111501.70fbea","type":"xiaoai-tts","z":"6469eaf7.924d94","name":"小爱TTS","xiaoai":"95f52ee1.d4703","tts":"","device":"小爱音箱设备id通过小爱设备列表节点获取","x":1560,"y":1580,"wires":],]]},{"id":"95f52ee1.d4703","type":"xiaoai-tts-configurator","z":"","name":"","username":"yourusername","password":"yourpassword"}]
```*