『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 27107|回复: 32

[流程系列] 利用一个门磁实现洗衣机智能化

[复制链接]

43

主题

412

帖子

3806

积分

元老级技术达人

积分
3806
金钱
3389
HASS币
136
发表于 2021-1-4 22:58:00 | 显示全部楼层 |阅读模式
本帖最后由 hunterfox 于 2021-1-5 10:49 编辑

    家里多了一个小米门磁用不上,不知道往哪粘了。然后想到粘到洗衣机的门上面。


场景描述: 去洗衣服时,把衣服放进去,关门,开启。
                  洗完,打开门,拿出衣服,防止霉菌,一般人门都不关的,直到下一次洗衣服。
                  所以。 我们可以通过门的开闭来判断洗衣机是否处于工作状态。
           通过自己家里的洗衣服的风格,知道多久可以完成。
           通过nr  进行处理门磁的“开,闭” 再配合倒计时。  就可以实现,关门 ,洗衣,倒计时,完成 ,提醒(提醒输出可以:小爱、小米网关,微信。群晖chat都可以。)。
  从而可以实现一个传感器实现洗衣机的: 待机、工作(可以变成倒计时)、完成,发出提醒。这几种状态,实现一个半智能。

2.jpg
1.jpg
flows.zip (3.88 KB, 下载次数: 75)


游客,如果您要查看本帖隐藏内容请回复

[{"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}]


评分

参与人数 1金钱 +5 收起 理由
neoyang + 5

查看全部评分

回复

使用道具 举报

8

主题

263

帖子

2395

积分

金牌会员

Rank: 6Rank: 6

积分
2395
金钱
2132
HASS币
15
发表于 2021-1-4 23:19:20 | 显示全部楼层
本帖最后由 diba.qiu 于 2021-1-4 23:23 编辑

我用Sonoff Pow R2,透過電流判斷洗衣機是否運作中!

洗完衣服就通知我收, 價格跟小米门磁差不多,還能知道每次洗衣服用多少電、花多少錢^^

話說我也多個aqara門磁還不知道用在哪裡,買了沒用還蠻浪費的

评分

参与人数 1金钱 +2 收起 理由
neoyang + 2

查看全部评分

回复

使用道具 举报

77

主题

1391

帖子

2万

积分

元老级技术达人

积分
24293
金钱
22862
HASS币
290
发表于 2021-1-4 23:24:03 | 显示全部楼层
用ha自动化理解就是:
门磁开:待机或关机
门磁关(设定时长之内):工作
门磁关(设定时长之后):完成
变成完成时执行一个通知动作。

差不多是这个意思吧?
回复

使用道具 举报

43

主题

412

帖子

3806

积分

元老级技术达人

积分
3806
金钱
3389
HASS币
136
 楼主| 发表于 2021-1-4 23:31:05 | 显示全部楼层
dscao 发表于 2021-1-4 23:24
用ha自动化理解就是:
门磁开:待机或关机
门磁关(设定时长之内):工作

嗯嗯!~~~~~~~~~
回复

使用道具 举报

43

主题

412

帖子

3806

积分

元老级技术达人

积分
3806
金钱
3389
HASS币
136
 楼主| 发表于 2021-1-4 23:34:34 | 显示全部楼层
diba.qiu 发表于 2021-1-4 23:19
我用Sonoff Pow R2,透過電流判斷洗衣機是否運作中!

洗完衣服就通知我收, 價格跟小米门磁差不多,還能知道 ...

条条大道通罗马。多的门磁可以装在厨房移门上,当抽烟机工作,如果 厨房门没有关上,提醒关一下,不然油烟乱跑
回复

使用道具 举报

8

主题

263

帖子

2395

积分

金牌会员

Rank: 6Rank: 6

积分
2395
金钱
2132
HASS币
15
发表于 2021-1-4 23:44:50 | 显示全部楼层
hunterfox 发表于 2021-1-4 23:34
条条大道通罗马。多的门磁可以装在厨房移门上,当抽烟机工作,如果 厨房门没有关上,提醒关一下,不然油 ...

感謝大佬指導,家裡十幾個門磁想得到的地方都用上了,真該好好想想如何把多的那個也用上別浪費了^^
回复

使用道具 举报

0

主题

3

帖子

26

积分

新手上路

Rank: 1

积分
26
金钱
23
HASS币
0
发表于 2021-1-5 17:58:13 | 显示全部楼层
这个好用,过来学习下
回复

使用道具 举报

1

主题

42

帖子

222

积分

中级会员

Rank: 3Rank: 3

积分
222
金钱
180
HASS币
0
发表于 2021-1-18 16:07:35 | 显示全部楼层
谢谢大佬分享啊
回复

使用道具 举报

1

主题

30

帖子

167

积分

注册会员

Rank: 2

积分
167
金钱
137
HASS币
0
发表于 2021-1-19 21:08:51 | 显示全部楼层
学习一下。。。。。
回复

使用道具 举报

11

主题

331

帖子

1424

积分

金牌会员

Rank: 6Rank: 6

积分
1424
金钱
1093
HASS币
0
发表于 2021-2-8 11:41:28 | 显示全部楼层
diba.qiu 发表于 2021-1-4 23:19
我用Sonoff Pow R2,透過電流判斷洗衣機是否運作中!

洗完衣服就通知我收, 價格跟小米门磁差不多,還能知道 ...

学习了 谢谢。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-22 05:13 , Processed in 0.191670 second(s), 41 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表