播报当前时间的流程
[{"id":"3f6343d0.30c6ac","type":"subflow","name":"判断时间段","info":"## 判断时间段\n1. 判断当前时间段,早上/下午/晚上\n2. 输出相应问候语到msg.timerange","category":"","in":[{"x":140,"y":920,"wires":[{"id":"71f3064d.b0f058"}]}],"out":[{"x":400,"y":920,"wires":[{"id":"71f3064d.b0f058","port":0}]}]},{"id":"71f3064d.b0f058","type":"function","z":"3f6343d0.30c6ac","name":"判断时间段","func":"\nvar before_dawn = ['你见过凌晨四点的洛杉矶吗?','夜深了,早点休息'];\nvar morning = ['早上好','早安','早啊','早','Good morning','早上好,送你清新的问候'];\nvar noon = ['中午好','午安','good afternoon'];\nvar afternoon = ['下午好','午安','Good afternoon'];\nvar night = ['晚上好','宁静的夜晚,美丽的天空,丝丝的微风','万家灯火,是夜晚最美的风景'];\nfunction rnd(start, end){\n return Math.floor(Math.random() * (end - start) + start);\n}\nvar now = new Date();\nvar hour = now.getHours();\nif (hour >= 0 && hour < 5){\n msg.timerange = before_dawn[rnd(0,before_dawn.length)];\n}\nelse if (hour >= 5 && hour < 11){\n msg.timerange = morning[rnd(0,morning.length)];\n}\nelse if (hour >=11 && hour < 13){\n msg.timerange = noon[rnd(0,noon.length)];\n}\nelse if (hour >= 13 && hour < 18){\n msg.timerange = afternoon[rnd(0,afternoon.length)];\n}\nelse if (hour >= 18 && hour < 24){\n msg.timerange = night[rnd(0,night.length)];\n}\nelse {\n msg.timerange = '你好';\n}\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":920,"wires":[[]]},{"id":"44c572f5.aaf18c","type":"function","z":"6d166cb8.fefd14","name":"获取当前时间戳","func":"var now = new Date();\nvar timestamp = Date.parse(new Date());\nmsg.timestamp = timestamp;\nreturn msg","outputs":1,"noerr":0,"x":760,"y":400,"wires":[["62ce87ad.b14c98"]]},{"id":"62ce87ad.b14c98","type":"moment","z":"6d166cb8.fefd14","name":"转换时间格式","topic":"","input":"timestamp","inputType":"msg","inTz":"Asia/Shanghai","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm","locale":"C","output":"time","outputType":"msg","outTz":"Asia/Shanghai","x":980,"y":400,"wires":[["6a3a204f.32a02","280ebeb6.06da52"]]},{"id":"a666eb0b.feb8c8","type":"inject","z":"6d166cb8.fefd14","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":580,"y":400,"wires":[["44c572f5.aaf18c"]]},{"id":"6a3a204f.32a02","type":"debug","z":"6d166cb8.fefd14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1510,"y":460,"wires":[]},{"id":"90d179df.90b448","type":"api-call-service","z":"6d166cb8.fefd14","name":"小爱TTS","server":"94f0c0a9.629b6","service_domain":"hello_miai","service":"add2msgqueue","data":"","render_data":false,"mergecontext":"","x":1540,"y":400,"wires":[[]]},{"id":"e810cc7a.5a12f","type":"function","z":"6d166cb8.fefd14","name":"推送内容","func":"\nvar message = `${msg.timerange},现在时间是${msg.time}`;\nmsg.payload = {};\nmsg.payload.data = {\"message\":message,\"miai_num\":\"0\"};\nreturn msg;","outputs":1,"noerr":0,"x":1360,"y":400,"wires":[["90d179df.90b448","6a3a204f.32a02"]]},{"id":"280ebeb6.06da52","type":"subflow:3f6343d0.30c6ac","z":"6d166cb8.fefd14","name":"","x":1190,"y":400,"wires":[["e810cc7a.5a12f"]]},{"id":"94f0c0a9.629b6","type":"server","z":"","name":"Home Assistant","legacy":true,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]
开启电视并播报当前节目的流程
修改频道id