|
发表于 2019-8-1 12:18:29
|
显示全部楼层
[{"id":"a3997102.a99ae","type":"function","z":"bdf6fb07.64fd48","name":"保存格言到flow变量","func":"flow.set('wisdom',msg.payload.info + msg.payload.author);\nreturn null;","outputs":0,"noerr":0,"x":2530,"y":4220,"wires":[]},{"id":"f06e376.5aeb3c8","type":"inject","z":"bdf6fb07.64fd48","name":"每小时获取一次名言","topic":"","payload":"{}","payloadType":"json","repeat":"3600","crontab":"","once":true,"onceDelay":0.1,"x":1920,"y":4220,"wires":[["7cb2402.cc4ffc"]]},{"id":"2059008f.5f398","type":"comment","z":"bdf6fb07.64fd48","name":"获取名言flow变量","info":"flow变量名为 token\n获取方法 msg.access_token = flow.get('token');","x":1897.8333282470703,"y":4175.666561126709,"wires":[]},{"id":"7cb2402.cc4ffc","type":"http request","z":"bdf6fb07.64fd48","name":"名言api","method":"GET","ret":"txt","url":"http://api.bunian.cn/yulu/?fun=json","tls":"","x":2160,"y":4220,"wires":[["890e20cf.7c3a8"]]},{"id":"890e20cf.7c3a8","type":"json","z":"bdf6fb07.64fd48","name":"","property":"payload","action":"","pretty":false,"x":2350,"y":4220,"wires":[["a3997102.a99ae"]]},{"id":"7f426214.3934ac","type":"api-current-state","z":"bdf6fb07.64fd48","name":"获取室内温度","server":"94f0c0a9.629b6","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.temperature_158d0000fd539c","state_type":"str","override_payload":true,"override_data":true,"x":2880,"y":4320,"wires":[["3be3eef7.4d5332","aa8942b8.c7e5c"]]},{"id":"48b9cd54.e89c84","type":"api-current-state","z":"bdf6fb07.64fd48","name":"获取室内湿度","server":"94f0c0a9.629b6","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.humidity_158d0000fd539c","state_type":"str","override_payload":true,"override_data":true,"x":2880,"y":4380,"wires":[["d1a55952.33b9d8"]]},{"id":"3be3eef7.4d5332","type":"function","z":"bdf6fb07.64fd48","name":"温度","func":"var result='';\nif(msg.data.state>=23){\n result = msg.data.state + '摄氏度,炎热'; \n}\nelse if(msg.data.state>=18 && msg.data.state<=23){\n result = msg.data.state + '摄氏度,舒适'; \n}\nelse if(msg.data.state>12 && msg.data.state<18){\n result = msg.data.state + '摄氏度,较冷';\n}\nelse{\n result = msg.data.state + '摄氏度,寒冷,请注意保暖';\n}\n\nmsg.payload = {"temperature":result};\nreturn msg;","outputs":1,"noerr":0,"x":3070,"y":4320,"wires":[["d1c941a9.52593"]]},{"id":"d1a55952.33b9d8","type":"function","z":"bdf6fb07.64fd48","name":"湿度","func":"var result='';\nif(msg.data.state>=60){\n result = msg.data.state + '潮湿'; \n}\nelse if(msg.data.state>30 && msg.data.state<60){\n result = msg.data.state + '适中';\n}\nelse{\n result = msg.data.state + '干燥';\n}\nmsg.payload = {"humidity":result};\nreturn msg;","outputs":1,"noerr":0,"x":3070,"y":4380,"wires":[["d1c941a9.52593"]]},{"id":"a583519b.c8397","type":"api-call-service","z":"bdf6fb07.64fd48","name":"小爱TTS","server":"94f0c0a9.629b6","service_domain":"hello_miai","service":"add2msgqueue","data":"","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":3640,"y":4360,"wires":[[]]},{"id":"1bfadb64.9eb5a5","type":"function","z":"bdf6fb07.64fd48","name":"TTS内容","func":"var wisdom = flow.get('wisdom');\n\n\nvar message = `欢迎回家:现在室内温度${msg.payload.temperature},湿度为百分之${msg.payload.humidity}。${wisdom}`;\nmsg.payload = {};\nmsg.payload.data = {"message":message,"miai_num":"0"};\nreturn msg;","outputs":1,"noerr":0,"x":3420,"y":4360,"wires":[["a583519b.c8397","71d25351.12058c"]]},{"id":"d1c941a9.52593","type":"join","z":"bdf6fb07.64fd48","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":3270,"y":4360,"wires":[["1bfadb64.9eb5a5"]]},{"id":"71d25351.12058c","type":"debug","z":"bdf6fb07.64fd48","name":"调式信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":3620,"y":4420,"wires":[]},{"id":"7051732.489678c","type":"server-state-changed","z":"bdf6fb07.64fd48","name":"监测大门状态","server":"94f0c0a9.629b6","entityidfilter":"binary_sensor.door_window_sensor_158d0000d6de14","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":1870,"y":4400,"wires":[["b0d0837f.90c33"]]},{"id":"f2134b3d.fcfde8","type":"switch","z":"bdf6fb07.64fd48","name":"大门新状态为开启","property":"data.new_state.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2330,"y":4400,"wires":[["3ae5dab8.d82b16"]]},{"id":"b0d0837f.90c33","type":"switch","z":"bdf6fb07.64fd48","name":"大门原状态为关闭","property":"data.old_state.state","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2110,"y":4400,"wires":[["f2134b3d.fcfde8"]]},{"id":"45d250f3.aa2a6","type":"api-current-state","z":"bdf6fb07.64fd48","name":"获取客厅光照度","server":"94f0c0a9.629b6","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.illumination_158d0001a2520d","state_type":"str","override_payload":true,"override_data":true,"x":2880,"y":4440,"wires":[["c72b5594.329e38"]]},{"id":"c72b5594.329e38","type":"switch","z":"bdf6fb07.64fd48","name":"低于20lx","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"20.0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":3100,"y":4440,"wires":[["80610ff5.d5bb8"]]},{"id":"80610ff5.d5bb8","type":"api-call-service","z":"bdf6fb07.64fd48","name":"打开客厅灯","server":"94f0c0a9.629b6","service_domain":"switch","service":"turn_on","data":"{"entity_id":"switch.wall_switch_right_158d00014cf47a"}","render_data":false,"mergecontext":"","x":3290,"y":4440,"wires":[[]]},{"id":"9c104446.36be18","type":"api-call-service","z":"bdf6fb07.64fd48","name":"小爱TTS","server":"94f0c0a9.629b6","service_domain":"hello_miai","service":"add2msgqueue","data":"","render_data":false,"mergecontext":"","x":3220,"y":4540,"wires":[[]]},{"id":"44aea020.1882d","type":"function","z":"bdf6fb07.64fd48","name":"推送内容","func":"var message = flow.get('wisdom');\n\nmsg.payload = {};\nmsg.payload.data = {"message":message,"miai_num":"0"};\nreturn msg;\n","outputs":1,"noerr":0,"x":2880,"y":4540,"wires":[["83b8982b.a5dae8"]]},{"id":"83b8982b.a5dae8","type":"trigger","z":"bdf6fb07.64fd48","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"10","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":3050,"y":4540,"wires":[["9c104446.36be18"]]},{"id":"ea2db4d3.5c92b8","type":"comment","z":"bdf6fb07.64fd48","name":"开门播报室内温湿度","info":"","x":1897.7777709960938,"y":4334.4443359375,"wires":[]},{"id":"3ae5dab8.d82b16","type":"api-current-state","z":"bdf6fb07.64fd48","name":"防盗门状态","server":"94f0c0a9.629b6","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.door_window_sensor_158d0001f34db6","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2490,"y":4320,"wires":[["2deae646.e72e1a"]]},{"id":"2deae646.e72e1a","type":"switch","z":"bdf6fb07.64fd48","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2630,"y":4380,"wires":[["7f426214.3934ac","48b9cd54.e89c84","45d250f3.aa2a6"],["44aea020.1882d"]]},{"id":"aa8942b8.c7e5c","type":"debug","z":"bdf6fb07.64fd48","name":"调式信息","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":3040,"y":4260,"wires":[]},{"id":"94f0c0a9.629b6","type":"server","z":"","name":"Home Assistant","legacy":true,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}] |
|