[{"id":"709b5b90.c2a054","type":"subflow","name":"微信-推送","info":"","category":"","in":[{"x":140,"y":140,"wires":[{"id":"2090304f.f4255"}]}],"out":[{"x":1020,"y":140,"wires":[{"id":"ca371cef.38a17","port":0},{"id":"dce1b576.145138","port":0},{"id":"1bf3db0b.53df65","port":0}]}],"env":[]},{"id":"cd2d75dd.ae3f48","type":"function","z":"709b5b90.c2a054","name":"微信推送","func":"\n//文本消息text 文本1\n//图文消息news 文本卡片2\n//纯图片image 3\n//图文消息mpnews 图文消息最全4\nvar titlemsg=msg.title; \n\n//消息提醒标题\n//if (temp>41)\n//{messages =`今天太阳能水温为${temp}°C,可以使用太阳能热水洗澡`;}\n//\n//{ messages =`今天太阳能水温为${temp}°C,洗澡有点冷,勇者上`;}\n//正文内容\nvar contentmsg=msg.content;\n\n//消息描述\nvar digestmsg=msg.descrmsg;\n\n//链接地址\nvar urlmsg=msg.url;\n\n//应用id\nvar procid=msg.prcid; //1000002 和1000004,1000005两个\n\n//消息类型 1、text文本消息 2、news图文消息 文本卡片 3、image纯图片 4、mpnews图文消息\n\nvar messagestay=msg.sendtype;\n\n//var messagestay=Number(flow.get('nowseletct'));\n\nif (messagestay==1)\n{\nmsg.payload = {\n // "touser" : `${msg.message.FromUserName}`,\n "touser" : "@all", //成员ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送\n "agentid" : procid,//这里填你自建应用的AgentId\n "msgtype" : "text",//消息类型\n "text" : {\n\t "content" : contentmsg,\n },\n "safe":0\n};\n}\n\nelse if(messagestay==2)\n{\nmsg.payload = {\n "touser" : "@all", \n "msgtype" : "news", \n "agentid" : procid,\n "news" : {\n "articles":[\n {\n "title" : titlemsg,\n "description" : digestmsg,\n "url" : urlmsg,\n "picurl" : urlmsg\n }\n ]\n },\n "safe":0\n} ; \n}\n\nelse if(messagestay==3)\n{\nmsg.payload = {\n "touser" : "@all", //成员ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送\n //"toparty" : "PartyID1 | PartyID2", //部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数\n //"totag": "TagID1 | TagID2", //标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数\n "msgtype" : "image",\n "agentid" : procid,\n "image" : {\n "media_id" : msg.payload.media_id\n },\n}; \n}\nelse if(messagestay==4) //需要配置长传素材\n{\n msg.payload = {\n "touser" : "@all", \n "agentid" : procid, //企业应用的id,整型。企业内部开发,可在应用的设置页面查看\n\n "msgtype" : "mpnews", \n "mpnews" : {\n "articles":[ //图文消息,一个图文消息支持1到8条图文,即下方一个{}表示一条消息\n {\n "title": titlemsg,\n "thumb_media_id": msg.payload.media_id,\n "author": "Hunter_Fox",\n "content_source_url": urlmsg,\n "content": contentmsg,\n "digest": digestmsg\n }\n ]\n },\n "safe":0\n} ; \n}\n\nif (procid==1000002)\n{return [msg,null,null];}\nif (procid==1000004)\n{return [null,msg,null];}\nif (procid==1000005)\n{return [null,null,msg];}\n","outputs":3,"noerr":0,"x":720,"y":140,"wires":[["ca371cef.38a17"],["1bf3db0b.53df65"],["dce1b576.145138"]]},{"id":"ca371cef.38a17","type":"bizwechat-push","z":"709b5b90.c2a054","name":"微信-1000002","bizwechat":"7c423bd.46154c4","x":880,"y":100,"wires":[[]]},{"id":"2090304f.f4255","type":"http request","z":"709b5b90.c2a054","name":"得到图片地址","method":"GET","ret":"bin","paytoqs":false,"url":"","tls":"","proxy":"","authType":"","x":260,"y":140,"wires":[["243cd79e.12dfe8"]]},{"id":"243cd79e.12dfe8","type":"function","z":"709b5b90.c2a054","name":"","func":"\nmsg.type = "image"\nmsg.filename = "xxxxxx.jpg"\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":140,"wires":[["4225c88d.d03438"]]},{"id":"4225c88d.d03438","type":"bizwechat-upload","z":"709b5b90.c2a054","name":"","bizwechat":"bc6228ac.695488","x":560,"y":140,"wires":[["cd2d75dd.ae3f48"]]},{"id":"dce1b576.145138","type":"bizwechat-push","z":"709b5b90.c2a054","name":"微信-1000005","bizwechat":"bc6228ac.695488","x":880,"y":180,"wires":[[]]},{"id":"1bf3db0b.53df65","type":"bizwechat-push","z":"709b5b90.c2a054","name":"微信-1000004","bizwechat":"a99957b3.d06d58","x":880,"y":140,"wires":[[]]},{"id":"7c423bd.46154c4","type":"bizwechat-configurator","z":"","name":"企业微信-1000002","port":"8286","corpid":"ww9e0a366d607552de","agentid":"1000002","corpsecret":"oW5niaFbDUNHfIxRRmvOfSLDyTPLUrIZvWw4rgUji3M","url":"http://myhomehunterfox.51vip.biz:8286","token":"S8RS1mwkz4alG","aeskey":"4pLiKTwqF93x4UVWEfVWTjnFIFaijgtGet7KYPVIM3s","client_id":"RF5yeQ9loLtGfwPOoMcdaY20","client_secret":"ykpCxeBFFaclFTy2UqfrUsk4Za0Ggij1"},{"id":"bc6228ac.695488","type":"bizwechat-configurator","z":"","name":"企业微信-1000005","port":"8285","corpid":"ww9e0a366d607552de","agentid":"1000005","corpsecret":"xYhr8nVcEM_OdrpMg41RuVMebMpM8_1js-4kF4qCZTs","url":"http://myhomehunterfox.51vip.biz:8285","token":"aGls29ebysy4xHY","aeskey":"RaD6COAZpJpmkmMmnkbD5fCc7ybHdhjfcMKpAEvWJRd","client_id":"","client_secret":""},{"id":"a99957b3.d06d58","type":"bizwechat-configurator","z":"","name":"企业微信-1000004","port":"8287","corpid":"ww9e0a366d607552de","agentid":"1000004","corpsecret":"rV8z_abtVpDav7oaWTkwmKdLZCfmjYzBi_mmv9WW9uU","url":"http://myhomehunterfox.51vip.biz:8287","token":"A51KiRJg1jsAUP8WAnUGu","aeskey":"dMTB3UEvFy0Tx5OOJJFD6KJGbIrW9k5D7Z5T1mMYtVp","client_id":"","client_secret":""},{"id":"7f44ddf8.74b024","type":"mqtt out","z":"293a5f3e.89d5e","name":"洗衣机","topic":"a/sensor/home_Washing/home/state","qos":"","retain":"","broker":"37541fbf.c8804","x":770,"y":880,"wires":[]},{"id":"93ad66fe.eaa138","type":"function","z":"293a5f3e.89d5e","name":"倒计时,并发出停止tigger命令","func":"var msg1={};\n\nvar relast=flow.get('washtime')\nrelast=relast-5;\nflow.set('washtime',relast);\n\nif (relast===0)\n{msg.payload="完成"\nmsg1.payload="stop"\nreturn [msg,msg1]\n}\nelse\n{\nmsg.payload=relast;\nreturn msg;\n}","outputs":2,"noerr":0,"x":510,"y":1020,"wires":[["7f44ddf8.74b024"],["f542ea33.610be8","eefd20d8.7f287"]]},{"id":"f542ea33.610be8","type":"trigger","z":"293a5f3e.89d5e","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-5","extend":false,"units":"min","reset":"stop","bytopic":"all","name":"","x":530,"y":920,"wires":[["93ad66fe.eaa138"]]},{"id":"ef8d4312.d66be","type":"change","z":"293a5f3e.89d5e","name":"设定洗衣时间","rules":[{"t":"set","p":"washtime","pt":"flow","to":"50","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":960,"wires":[["f542ea33.610be8"]]},{"id":"5eb3c889.9a2618","type":"server-state-changed","z":"293a5f3e.89d5e","name":"开关洗衣机门","server":"2b887588.e131fa","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.door_window_sensor_158d00035b1fb4","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":110,"y":900,"wires":[["dfda7edd.e9811"],["ef8d4312.d66be"]]},{"id":"dfda7edd.e9811","type":"change","z":"293a5f3e.89d5e","name":"初始化","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":880,"wires":[["f542ea33.610be8","5d100db9.96e6c4"]]},{"id":"5d100db9.96e6c4","type":"function","z":"293a5f3e.89d5e","name":"刷传感器到“待机“状态","func":"\nmsg.payload="待机";\nreturn msg;","outputs":1,"noerr":0,"x":560,"y":860,"wires":[["7f44ddf8.74b024"]]},{"id":"eefd20d8.7f287","type":"api-call-service","z":"293a5f3e.89d5e","name":"小米网关-洗衣完成","server":"2b887588.e131fa","version":1,"debugenabled":false,"service_domain":"xiaomi_aqara","service":"play_ringtone","entityId":"","data":"{"gw_mac":"04CF8CA9CB57","ringtone_id":10016,"ringtone_vol":30}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":790,"y":1020,"wires":[["dc68d082.7bc93"]]},{"id":"8b5d5271.d4f06","type":"comment","z":"293a5f3e.89d5e","name":"洗衣机","info":"","x":110,"y":840,"wires":[]},{"id":"76ebd9a.ca6f228","type":"subflow:709b5b90.c2a054","z":"293a5f3e.89d5e","name":"","env":[],"x":980,"y":940,"wires":[[]]},{"id":"dc68d082.7bc93","type":"function","z":"293a5f3e.89d5e","name":"信息整理","func":"var a,b;\na=msg.payload;\nb=msg.upwater;\nvar messages ="提醒:洗衣机已完成,请及时晾晒";\nvar msg1= {};\nmsg1.title='【洗衣机完成】'\nmsg1.content=messages;\nmsg1.descrmsg=messages;\nmsg1.url="http://192.168.1.188:8123/local/image/xiyiji.jpg";\nmsg1.sendtype=4;\nmsg1.prcid=1000004;\n\nreturn msg1;\n","outputs":1,"noerr":0,"x":840,"y":940,"wires":[["76ebd9a.ca6f228"]]},{"id":"37541fbf.c8804","type":"mqtt-broker","z":"","name":"MY_MQTT","broker":"192.168.1.188","port":"1883","clientid":"Node_RED","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"2b887588.e131fa","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]