homeassistant系列 篇三:我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

2021-04-26 19:43:13 13点赞 120收藏 42评论

创作立场声明:本文所有使用设备均为本人自费购入

追加修改(2021-04-28 21:47:55):
题目修改为:homeassistant系列(三):我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

重点:每秒检测,最低可以调成延迟2秒左右重点:每秒检测,最低可以调成延迟2秒左右

看到这个题目有人肯定会说这不很简单吗?买一个声控或者感应灯泡人过开灯或者喊一声开灯不就行了,但是如果你蹲在厕所里不动,是不是需要过一会喊一声嘿哈呢。

现在智能家居越来越深入人心,当然米家的接受度更高,因为设置简单。但是个人使用过程中觉得小米家不是很好,主要存在一下几个问题:1.感应间隔时间太长,小米人体感应器是1分钟感应一次,这就让人很无语了,1分钟后有可能检测不到你的存在直接给你把灯关了,而且你挥手半天它都不感应再次开灯。2.你的家里不可能全是小米的,所以如果有其他的设备存在,加入不到米家,无法联动。

实现功能:

有人自动开灯,没有人活动自动关灯,如果开灯后厕所门关闭,则灯永不会关闭。只有在门打开,并且厕所中无人活动感应,灯才会关闭。避免了人在蹲厕所,直接关灯的尴尬。

家里万一有老人习惯用开关,开关与这个感应不冲突。

所需设备

所需要用到的设备如下:

1.易微联网关

我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

淘宝网-淘!我喜欢s.taobao.com去看看

2.易微联人体感应器(感应间隔可调,最短可以调成2S左右)

我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

淘宝网-淘!我喜欢s.taobao.com去看看

3.小米的门窗感应器,因为小米的比易微联的感应宽度更大,需要搭配小米的网关使用。当然为了省钱也可以选择易微联的wifi门窗感应器。

小米米家智能家庭套装无线开关人体温湿度门窗传感器2需搭配网关48元天猫精选去购买

斜着放感应范围更大点,不需要完全对牢。

我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

SONOFF嵩诺433射频门磁感应器易微联智能开关防盗门窗传感器家用39.9元天猫精选去购买

4.易微联的灯座

。WiFi智能灯头天猫精灵小爱小度语音控制易微联灯具无线遥控定时18.2元天猫精选去购买

5.433开关

易微联wifi智能墙壁开关遥控控制单火开关小爱同学天猫精灵智能26元天猫精选去购买


折腾过程

1.安装homeassisant,本文章不做赘述,玩智能家居的都懂,因为我本身家里有软路由24h运行,所以我选择在虚拟机中添加了homeassisant。当然也可以NAS docker中安装,网上教程较多。

2.在/config/configuration.yaml中加入如下:

sonoff: #易微联

username: +8613xxxxxxxxxx(注意:后有一个空格,username前有2个空格)

password: 你的易微联账号密码(注意:后有一个空格, password前有2个空格)

reload: always (注意:后有一个空格, reload前有2个空格)

3.完成第二步后重启homeassistant,然后可以在开发者工具中的实体中查看到每个设备的ID及状态情况。

我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

4.我选择安装的为hassio套装,所以在supervisor中安装了Node-red

我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

5.将下面的流程复制,在Node-red导入节点,将会得到下面的流程,延迟20s自己可以调短,总的思路就是当易微联的人体感应器感应到关闭后,感应小米门窗感应器的闭合状态,如果是打开的则延迟20s后再次查看易微联人体感应器的状态,如果依然为关闭状态则执行下一步,最后关闭灯。如果是打开状态则返回前面再次检测小米门窗感应器的状态,形成一个只要是人在就无限循环20s不关闭灯。后面我加入了一个易微联插座作为这个自动化的开关按钮,如果这个插座是关闭的,则这个自动化关闭,此步(即方框内)可选择不加入。

我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

[{"id":"243d5c6a.1ee6c4","type":"api-call-service","z":"c7f06fcb.6204a","name":"打开厕所灯","server":"542f76fd.960708","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.sonoff_100111159e","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":810,"y":80,"wires":[["5149747b.27721c"]]},{"id":"5149747b.27721c","type":"debug","z":"c7f06fcb.6204a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":80,"wires":[]},{"id":"2fd2dcb6.1dc934","type":"server-state-changed","z":"c7f06fcb.6204a","name":"厕所易微联人體感應器","server":"3a7ec2db.61d00e","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.sonoff_a40000899c","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":220,"y":80,"wires":[["b0113d9d.6542e"]]},{"id":"b0113d9d.6542e","type":"switch","z":"c7f06fcb.6204a","name":"on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":80,"wires":[["243d5c6a.1ee6c4"],[]]},{"id":"8bb09429.5ac4f8","type":"api-call-service","z":"c7f06fcb.6204a","name":"关闭厕所灯","server":"542f76fd.960708","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.sonoff_100111159e","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1090,"y":240,"wires":[["ced0e7eb.13d668"]]},{"id":"ced0e7eb.13d668","type":"debug","z":"c7f06fcb.6204a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1270,"y":240,"wires":[]},{"id":"182e34bb.849dbb","type":"server-state-changed","z":"c7f06fcb.6204a","name":"厕所易微联人體感應器","server":"3a7ec2db.61d00e","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.sonoff_a40000899c","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":220,"y":140,"wires":[["e615c0f3.c85c9"]]},{"id":"87ec82a2.9c889","type":"delay","z":"c7f06fcb.6204a","name":"","pauseType":"delay","timeout":"20","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1000,"y":160,"wires":[["5432e42e.eadfac"]]},{"id":"e615c0f3.c85c9","type":"switch","z":"c7f06fcb.6204a","name":"on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":430,"y":140,"wires":[[],["62116c08.6e2bb4"]]},{"id":"62116c08.6e2bb4","type":"api-current-state","z":"c7f06fcb.6204a","name":"厕所横门感应状态","server":"542f76fd.960708","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.e4aaec36eee6_contact","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":650,"y":160,"wires":[["3ee89f76.99fa9"]]},{"id":"3ee89f76.99fa9","type":"switch","z":"c7f06fcb.6204a","name":"on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":160,"wires":[["87ec82a2.9c889"],[]]},{"id":"5432e42e.eadfac","type":"api-current-state","z":"c7f06fcb.6204a","name":"再次厕所感应器状态","server":"542f76fd.960708","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.sonoff_a40000899c","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":580,"y":240,"wires":[["7055d792.3728f8"],["62116c08.6e2bb4"]]},{"id":"b891ce90.b5a53","type":"comment","z":"c7f06fcb.6204a","name":"厕所感应开关灯","info":"","x":200,"y":40,"wires":[]},{"id":"7055d792.3728f8","type":"api-current-state","z":"c7f06fcb.6204a","name":"开关厕所关灯自动化","server":"542f76fd.960708","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.sonoff_1000b37519","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840,"y":240,"wires":[["8bb09429.5ac4f8"],[]]},{"id":"542f76fd.960708","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"3a7ec2db.61d00e","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true}]

总结

我家是老房子,老旧线路的局限也阻拦不了我变懒的决心,智能家居的使用让生活更加方便。第一次发文,如有不足评论指出。




展开 收起

淘宝网-淘!我喜欢

淘宝网-淘!我喜欢

暂无报价 去购买

淘宝网-淘!我喜欢

淘宝网-淘!我喜欢

暂无报价 去购买

小米米家智能家庭套装无线开关人体温湿度门窗传感器2需搭配网关

小米米家智能家庭套装无线开关人体温湿度门窗传感器2需搭配网关

暂无报价 去购买

SONOFF嵩诺433射频门磁感应器易微联智能开关防盗门窗传感器家用

SONOFF嵩诺433射频门磁感应器易微联智能开关防盗门窗传感器家用

暂无报价 去购买

。WiFi智能灯头天猫精灵小爱小度语音控制易微联灯具无线遥控定时

。WiFi智能灯头天猫精灵小爱小度语音控制易微联灯具无线遥控定时

暂无报价 去购买

易微联wifi智能墙壁开关遥控控制单火开关小爱同学天猫精灵智能

易微联wifi智能墙壁开关遥控控制单火开关小爱同学天猫精灵智能

暂无报价 去购买

Xiaomi 小米 米家智能插座3

Xiaomi 小米 米家智能插座3

49元起

Xiaomi 小米 DMWG03LM 智能多模网关2 白色

Xiaomi 小米 DMWG03LM 智能多模网关2 白色

181.8元起

Xiaomi 小米 ZSWG01CM 智能中枢网关 黑色

Xiaomi 小米 ZSWG01CM 智能中枢网关 黑色

191.79元起

Xiaomi 小米 无线开关 蓝牙版

Xiaomi 小米 无线开关 蓝牙版

32.9元起

Xiaomi 小米 MCCG02HL 小米门窗传感器 2 米家

Xiaomi 小米 MCCG02HL 小米门窗传感器 2 米家

37.8元起

Xiaomi 小米 SJWS01LM 水浸卫士 白色

Xiaomi 小米 SJWS01LM 水浸卫士 白色

54.89元起

Xiaomi 小米 米家夜灯2 红外人体感应夜灯

Xiaomi 小米 米家夜灯2 红外人体感应夜灯

43元起

Xiaomi 小米 智能开关 零火版

Xiaomi 小米 智能开关 零火版

109元起

Xiaomi 小米 LYWSD03MMC 智能传感器

Xiaomi 小米 LYWSD03MMC 智能传感器

20.89元起

Xiaomi 小米 JT-BF-03MI/AW 智能天然气卫士

Xiaomi 小米 JT-BF-03MI/AW 智能天然气卫士

161.28元起

Xiaomi 小米 XMWXKG01YL 智能开关 双键版 白色

Xiaomi 小米 XMWXKG01YL 智能开关 双键版 白色

49元起

Xiaomi 小米 XMZNCXB01QM 5位插孔插排

Xiaomi 小米 XMZNCXB01QM 5位插孔插排

59元起

Xiaomi 小米 米家智能宠物喂食器2 自动喂食5L大粮仓防潮锁鲜顺畅出粮 智能场景联动 白色

Xiaomi 小米 米家智能宠物喂食器2 自动喂食5L大粮仓防潮锁鲜顺畅出粮 智能场景联动 白色

343元起

Xiaomi 小米 智能语音控制开关 白色

Xiaomi 小米 智能语音控制开关 白色

39元起

Xiaomi 小米 异味除pm2.5 低噪设计 米家APP智控 米家空气净化器4 Lite

Xiaomi 小米 异味除pm2.5 低噪设计 米家APP智控 米家空气净化器4 Lite

599元起

Xiaomi 小米 智能家庭面板

Xiaomi 小米 智能家庭面板

318元起
42评论

  • 精彩
  • 最新
提示信息

取消
确认
评论举报

相关好价推荐
查看更多好价

相关文章推荐

更多精彩文章
更多精彩文章
最新文章 热门文章
120
扫一下,分享更方便,购买更轻松