新人下载app,立即提现现金 您的好友 送你现金 去提现

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

无敌冲锋 04-26 19:43 关注

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

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

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

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

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

实现功能:

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

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

所需设备

所需要用到的设备如下:

1.易微联网关

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

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

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

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

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

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

4.易微联的灯座

5.433开关


折腾过程

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系列 篇三:我的智能家居之路——如何利用homeassistant实现厕所自动开关灯

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

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

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

homeassistant系列 篇三:我的智能家居之路——如何利用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}]

总结

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




展开阅读全文

打开App,享最佳阅读体验

一站式解决

智能家居选购问题

全部评论 (39)
值友1953390209
1
04-28 10:08

tb或者pdd 个红外感应开关 只有人在感应范围内 灯就不灭 离开后 10-30秒熄灯 价格不过8-9块钱 用得着这么费事么

无敌冲锋
0
57分钟前
x_W_x: 有个东西叫,存在感应器,可以和米家联动的 1
yilin101: 你好 哪个 为什么我没找到 2

说实话存在感应器贵,而且无法加入homeassisant

无敌冲锋
0
59分钟前
未来不会是梦: 不是有那种20块钱的人体感应灯泡吗?有人就一直亮着 1

对的,问题是全家的灯都可以换成这种吗?何为智能家居呢?小米为何搞智能家居系统呢?我的全部灯光都换成了智能开关灯,我可以让小度音箱关灯,也可以手机关灯,躺床上喊一声就行了

未来不会是梦
0
1小时前

不是有那种20块钱的人体感应灯泡吗?有人就一直亮着

无敌木头儿
0
05-05 01:21
x_W_x: 有个东西叫,存在感应器,可以和米家联动的 1

搜索到485协议的,要自己接入Ha吗

无敌冲锋
0
05-01 14:40
x_W_x: 有个东西叫,存在感应器,可以和米家联动的 1
yilin101: 你好 哪个 为什么我没找到 2

哪个没找到

yilin101
0
05-01 10:46
x_W_x: 有个东西叫,存在感应器,可以和米家联动的 1

你好 哪个 为什么我没找到

无敌冲锋
0
04-30 16:15
u_29: 可以使用静止人体存在传感器感,实现人在灯一直亮,人走灯灭的效果 1
无敌冲锋: 学习到了,淘宝有吗 2
展开隐藏评论
u_29: 搜 静止人体存在传感器感应开关RS485会议室卫生间酒店母婴室X327 3

兄弟,我看了一下,这玩意贵啊,而且属于只能直接连灯,连了这个东西,我原来的开关就没用了,而我的目的是我机械开关也可以用,同时可以兼顾智能感应。还有就是这个无法加入到智能家居中联动啊

u_29
0
04-30 12:39
u_29: 可以使用静止人体存在传感器感,实现人在灯一直亮,人走灯灭的效果 1
无敌冲锋: 学习到了,淘宝有吗 2

搜 静止人体存在传感器感应开关RS485会议室卫生间酒店母婴室X327

u_29
0
04-30 12:37
u_29: 可以使用静止人体存在传感器感,实现人在灯一直亮,人走灯灭的效果 1
姬蕊: 有这样的传感器吗? 2

静止人体存在传感器感应开关RS485会议室卫生间酒店母婴室X327

打开App,查看更多好文和评论
文中商品
最新智能家居优惠
有券的上:MI 小米 LYWSD03MMC 蓝牙温湿度计2 智能传感器 白色
有券的上:MI 小米 LYWSD03MMC 蓝牙温湿度计2 智能传感器 白色

智能设备热度Top7 超长续航

9元(需用券)
京东 16:04
13 33%
MI 小米 空调伴侣2 智能网关插座
MI 小米 空调伴侣2 智能网关插座

可远程控制 支持小爱同学

61.5元包邮
拼多多 05-05
0 86%
MI 小米  小米 1.5寸 米家蓝牙温湿度计 白色
MI 小米 小米 1.5寸 米家蓝牙温湿度计 白色

近30日已发布新低 9.9的他来了

16.5元
京东 05-05
49 18%
猜你喜欢
查看更多
相关好价
相关商品
查看更多热门商品
社区主页 文章详情
10
78
39
你已经点过赞了
新浪微博 QQ空间 微信好友 豆瓣
当前为触屏版
热门搜索