[{"id":"7c197322.4a461c","type":"tab","label":"开门播报温湿度","disabled":false,"info":""},{"id":"7f426214.3934ac","type":"api-current-state","z":"7c197322.4a461c","name":"获取室内温度","server":"5d51d3bd.9c86fc","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.4c65a8d0b061_temperature","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":980,"y":220,"wires":[["3be3eef7.4d5332"]]},{"id":"48b9cd54.e89c84","type":"api-current-state","z":"7c197322.4a461c","name":"获取室内湿度","server":"5d51d3bd.9c86fc","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.4c65a8d0b061_humidity","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":980,"y":280,"wires":[["d1a55952.33b9d8"]]},{"id":"3be3eef7.4d5332","type":"function","z":"7c197322.4a461c","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,"initialize":"","finalize":"","x":1170,"y":220,"wires":[["d1c941a9.52593"]]},{"id":"d1a55952.33b9d8","type":"function","z":"7c197322.4a461c","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,"initialize":"","finalize":"","x":1170,"y":280,"wires":[["d1c941a9.52593"]]},{"id":"a583519b.c8397","type":"api-call-service","z":"7c197322.4a461c","name":"小爱播报","server":"5d51d3bd.9c86fc","version":1,"debugenabled":false,"service_domain":"hello_miai","service":"force_send","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1500,"y":280,"wires":[["7c69c737.cca0f8"]]},{"id":"1bfadb64.9eb5a5","type":"function","z":"7c197322.4a461c","name":"播报内容","func":"var wisdom = flow.get('wisdom');\n\n\nvar message = `欢迎回家:现在室内温度${msg.payload.temperature},湿度为百分之${msg.payload.humidity}。${wisdom}`;\nmsg.payload = {};\nmsg.payload.data = {"message":message};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1340,"y":280,"wires":[["a583519b.c8397"]]},{"id":"d1c941a9.52593","type":"join","z":"7c197322.4a461c","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":1320,"y":240,"wires":[["1bfadb64.9eb5a5"]]},{"id":"7051732.489678c","type":"server-state-changed","z":"7c197322.4a461c","name":"监测大门状态","server":"5d51d3bd.9c86fc","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.e4aaec372d90_contact","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":70,"y":340,"wires":[["b0d0837f.90c33"]]},{"id":"f2134b3d.fcfde8","type":"switch","z":"7c197322.4a461c","name":"大门新状态为开启","property":"data.new_state.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":340,"wires":[["2deae646.e72e1a"]]},{"id":"b0d0837f.90c33","type":"switch","z":"7c197322.4a461c","name":"大门原状态为关闭","property":"data.old_state.state","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":340,"wires":[["f2134b3d.fcfde8"]]},{"id":"45d250f3.aa2a6","type":"api-current-state","z":"7c197322.4a461c","name":"获取客厅光照度","server":"5d51d3bd.9c86fc","version":1,"outputs":2,"halt_if":"20","halt_if_type":"num","halt_if_compare":"lte","override_topic":false,"entity_id":"sensor.0x4cf8cdf3c7cbe0b_illuminance","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":980,"y":360,"wires":[["14bf6c6a.b51f94"],[]]},{"id":"80610ff5.d5bb8","type":"api-call-service","z":"7c197322.4a461c","name":"打开客厅灯","server":"5d51d3bd.9c86fc","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.74a34ad52dc8_light","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1430,"y":360,"wires":[["7c69c737.cca0f8"]]},{"id":"9c104446.36be18","type":"api-call-service","z":"7c197322.4a461c","name":"小爱提醒门未关","server":"5d51d3bd.9c86fc","version":1,"debugenabled":false,"service_domain":"hello_miai","service":"add2msgqueue","entityId":"","data":"{"miai_num":0,"message":"大门未关,请查看"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1220,"y":460,"wires":[["7c69c737.cca0f8"]]},{"id":"ea2db4d3.5c92b8","type":"comment","z":"7c197322.4a461c","name":"开门播报室内温湿度","info":"","x":110,"y":260,"wires":[]},{"id":"2deae646.e72e1a","type":"switch","z":"7c197322.4a461c","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":610,"y":340,"wires":[["413cdd72.968574","d6d351d1.e332e"],[]]},{"id":"14bf6c6a.b51f94","type":"api-current-state","z":"7c197322.4a461c","name":"判断客厅灯是否关闭","server":"5d51d3bd.9c86fc","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.74a34ad52dc8_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1220,"y":360,"wires":[["80610ff5.d5bb8"],[]]},{"id":"d6d351d1.e332e","type":"api-current-state","z":"7c197322.4a461c","name":"判断家中是否有人","server":"5d51d3bd.9c86fc","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.54ef44e1ec2d_motion","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":730,"y":260,"wires":[["7f426214.3934ac","48b9cd54.e89c84","45d250f3.aa2a6"],[]]},{"id":"7c69c737.cca0f8","type":"e-mail","z":"7c197322.4a461c","server":"192.168.1.8","port":"25","secure":false,"tls":false,"name":"[email protected]","dname":"群晖node-red通知","x":1490,"y":640,"wires":[]},{"id":"29ae6f58.2f92f","type":"function","z":"7c197322.4a461c","name":"保存格言到flow变量","func":"flow.set('wisdom',msg.payload.title + msg.payload.author + msg.payload.lines);\nreturn null;","outputs":0,"noerr":0,"initialize":"","finalize":"","x":730,"y":80,"wires":[]},{"id":"7a8303dc.d7df8c","type":"inject","z":"7c197322.4a461c","name":"每小时获取一次唐诗","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"0 8-19 * * *","once":true,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":140,"y":80,"wires":[["79bdc8e1.b0ba18"]]},{"id":"73abf441.99b68c","type":"comment","z":"7c197322.4a461c","name":"获取名言flow变量","info":"flow变量名为 token\n获取方法 msg.access_token = flow.get('token');","x":97.83332824707031,"y":35.666561126708984,"wires":[]},{"id":"79bdc8e1.b0ba18","type":"http request","z":"7c197322.4a461c","name":"名言api","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://gxy.me/tangshi?format=json","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":80,"wires":[["af48674b.0d7588"]]},{"id":"af48674b.0d7588","type":"json","z":"7c197322.4a461c","name":"","property":"payload","action":"","pretty":false,"x":550,"y":80,"wires":[["29ae6f58.2f92f"]]},{"id":"1c19043d.30928c","type":"api-call-service","z":"7c197322.4a461c","name":"小爱TTS","server":"5d51d3bd.9c86fc","version":1,"debugenabled":false,"service_domain":"hello_miai","service":"add2msgqueue","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1240,"y":540,"wires":[[]]},{"id":"246f0a69.091b56","type":"function","z":"7c197322.4a461c","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,"initialize":"","finalize":"","x":1060,"y":540,"wires":[["1c19043d.30928c"]]},{"id":"413cdd72.968574","type":"delay","z":"7c197322.4a461c","name":"延迟8分钟","pauseType":"delay","timeout":"8","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":710,"y":460,"wires":[["c239513e.34649"]]},{"id":"c239513e.34649","type":"api-current-state","z":"7c197322.4a461c","name":"大门","server":"5d51d3bd.9c86fc","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.e4aaec372d90_contact","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":850,"y":460,"wires":[["3ca39684.91a6da"]]},{"id":"3ca39684.91a6da","type":"switch","z":"7c197322.4a461c","name":"大门状态","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":980,"y":460,"wires":[["9c104446.36be18"],[]]},{"id":"89c5efbc.d34ae","type":"server-state-changed","z":"7c197322.4a461c","name":"客厅无人状态","server":"5d51d3bd.9c86fc","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.54ef44e1ec2d_motion","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"10","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":90,"y":640,"wires":[["c80ad7f.cad7828"],[]]},{"id":"c80ad7f.cad7828","type":"api-current-state","z":"7c197322.4a461c","name":"判断客厅灯是否开启","server":"5d51d3bd.9c86fc","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.74a34ad52dc8_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":280,"y":640,"wires":[["8a9a9950.d0afa8"],[]]},{"id":"3d076971.47cab6","type":"api-call-service","z":"7c197322.4a461c","name":"客厅灯关闭","server":"5d51d3bd.9c86fc","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.74a34ad52dc8_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":750,"y":640,"wires":[["7c69c737.cca0f8"]]},{"id":"8a9a9950.d0afa8","type":"api-current-state","z":"7c197322.4a461c","name":"再次判断是否有人","server":"5d51d3bd.9c86fc","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.54ef44e1ec2d_motion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":530,"y":640,"wires":[["3d076971.47cab6"],[]]},{"id":"5d51d3bd.9c86fc","type":"server","name":"金星中央城","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]