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

 找回密码
 立即注册
查看: 7289|回复: 13

[流程系列] 【已解决】做了一个永远关不掉的感应灯

[复制链接]

21

主题

162

帖子

2118

积分

论坛DIY达人

积分
2118
金钱
1951
HASS币
30
发表于 2021-1-11 20:17:35 | 显示全部楼层 |阅读模式
本帖最后由 innx 于 2021-1-12 18:38 编辑

故事是这样的。。。

卫生间的灯已经通过mqtt接入nodered,然后又在开关边上加了一个红外人体传感器

只想到人走过去自动开灯,没想到关灯时因为人也在感应边上,在关灯后人一动就触发人体感应模块灯又开了

然后就是关灯。。。人动。。。感应到,灯又开了。。。再关灯。。。人又动。。。灯又感应开。。。

瞬间被自己蠢哭。。。

有个想法是获取到灯的状态从on到off的时候禁用人体传感器xx秒,学艺不精搜遍了百度函数写不出来各种报错,求大佬给点思路,感谢。


==================================================
请看楼下大佬的示例,解决了感应开灯,手动关灯后x秒人体传感器不触发的效果。
回复

使用道具 举报

43

主题

407

帖子

3619

积分

元老级技术达人

积分
3619
金钱
3207
HASS币
136
发表于 2021-1-12 09:31:57 | 显示全部楼层
[{"id":"32e60761.dc2758","type":"trigger","z":"86e04a84.9d1278","op1":"0","op2":"1","op1type":"str","op2type":"str","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","name":"封闭时间","x":500,"y":1840,"wires":[["eebd9692.01d9f8","2ee4b04d.e9872"]]},{"id":"94a3893c.4732a8","type":"server-state-changed","z":"86e04a84.9d1278","name":"按键开关","server":"b9c9a101.8b6bc","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.wei_sheng_jian_deng","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":200,"y":1840,"wires":[["e6d51739.af9628"],[]]},{"id":"eebd9692.01d9f8","type":"change","z":"86e04a84.9d1278","name":"","rules":[{"t":"set","p":"closetime","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":1840,"wires":[["a1de4a5a.ad02d8"]]},{"id":"e6d51739.af9628","type":"switch","z":"86e04a84.9d1278","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":1840,"wires":[["32e60761.dc2758"]]},{"id":"2ee4b04d.e9872","type":"debug","z":"86e04a84.9d1278","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":1900,"wires":[]},{"id":"a21dccd4.b6019","type":"inject","z":"86e04a84.9d1278","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":1900,"wires":[["e6d51739.af9628"]]},{"id":"a1de4a5a.ad02d8","type":"debug","z":"86e04a84.9d1278","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":930,"y":1900,"wires":[]},{"id":"63a2e0c1.5f2c2","type":"api-call-service","z":"86e04a84.9d1278","name":"卫生间灯开","server":"b9c9a101.8b6bc","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.wei_sheng_jian_deng","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":950,"y":1760,"wires":[["7fa2a1a7.2a1c7"]]},{"id":"4db3b06d.96d24","type":"mqtt in","z":"86e04a84.9d1278","name":"","topic":"cmnd/tasmota_EF82BE/POWER3","qos":"2","datatype":"auto","broker":"3ba861ee.9e20be","x":340,"y":1700,"wires":[["c42d2d24.3702d","f1e15eff.3fea8"]]},{"id":"c42d2d24.3702d","type":"debug","z":"86e04a84.9d1278","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":1680,"wires":[]},{"id":"d36e8ab6.0d3778","type":"inject","z":"86e04a84.9d1278","name":"","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":410,"y":1760,"wires":[["f1e15eff.3fea8"]]},{"id":"f1e15eff.3fea8","type":"switch","z":"86e04a84.9d1278","name":"","property":"closetime","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":790,"y":1760,"wires":[["63a2e0c1.5f2c2"],[]]},{"id":"7fa2a1a7.2a1c7","type":"debug","z":"86e04a84.9d1278","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":970,"y":1700,"wires":[]},{"id":"b9c9a101.8b6bc","type":"server","z":"","name":".7.7-Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"3ba861ee.9e20be","type":"mqtt-broker","z":"","name":"","broker":"192.168.7.7","port":"1883","clientid":"Node-red","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"2","birthPayload":"","closeTopic":"","closeQos":"2","closePayload":"","willTopic":"","willQos":"2","willPayload":""}]
你流当中有几个错误。    我改好了。测试正常了。  你先要对 closetime进行赋值。也就是先进行按键操作。操作完了closetime就有状态了。 switch 里面取closetime 这个值才有意义

评分

参与人数 1金钱 +5 收起 理由
innx + 5 厉害了word楼主!

查看全部评分

回复

使用道具 举报

43

主题

407

帖子

3619

积分

元老级技术达人

积分
3619
金钱
3207
HASS币
136
发表于 2021-1-11 20:19:53 | 显示全部楼层
用stoptimer 组件,有很多延时组件,你用用人体感应触发开,不要用人体感应触发管,
回复

使用道具 举报

21

主题

162

帖子

2118

积分

论坛DIY达人

积分
2118
金钱
1951
HASS币
30
 楼主| 发表于 2021-1-11 20:41:32 | 显示全部楼层
hunterfox 发表于 2021-1-11 20:19
用stoptimer 组件,有很多延时组件,你用用人体感应触发开,不要用人体感应触发管, ...

忘了说了,灯开是根据人体感应开,关是手动按开关关闭,如果不去按开关就是一直开的,stoptimer我看了好像做不到吧?请教一下感谢
回复

使用道具 举报

43

主题

407

帖子

3619

积分

元老级技术达人

积分
3619
金钱
3207
HASS币
136
发表于 2021-1-11 21:05:07 | 显示全部楼层
本帖最后由 hunterfox 于 2021-1-11 21:06 编辑
<div class="blockcode"><blockquote>[{"id":"4bc7ab2f.002b24","type":"stoptimer2","z":"9e9c2d22.11217","duration":"1","durationType":"num","units":"Minute","payloadtype":"str","payloadval":"关灯成功","name":"","x":440,"y":1460,"wires":[["4b0818f1.587078"],[]]},{"id":"4b0818f1.587078","type":"switch","z":"9e9c2d22.11217","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":630,"y":1460,"wires":[["46c9bc16.a44884"],["621b8707.426dd8"]]},{"id":"89b1d98.8e82028","type":"time-range-switch","z":"9e9c2d22.11217","name":"","lat":"","lon":"","startTime":"6:00","endTime":"21:30","startOffset":0,"endOffset":0,"x":290,"y":1400,"wires":[[],["4bc7ab2f.002b24","46c9bc16.a44884"]]},{"id":"46c9bc16.a44884","type":"api-call-service","z":"9e9c2d22.11217","name":"开小米灯","server":"2b887588.e131fa","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.gateway_light_04cf8ca9cb57","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":780,"y":1400,"wires":[[]]},{"id":"621b8707.426dd8","type":"api-call-service","z":"9e9c2d22.11217","name":"关小米灯","server":"2b887588.e131fa","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.gateway_light_04cf8ca9cb57","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":780,"y":1460,"wires":[[]]},{"id":"cb715417.989048","type":"server-state-changed","z":"9e9c2d22.11217","name":"客厅有人","server":"2b887588.e131fa","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.b03_12","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":140,"y":1420,"wires":[["89b1d98.8e82028"]]},{"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 收起 理由
innx + 5 厉害了word楼主!

查看全部评分

回复

使用道具 举报

21

主题

162

帖子

2118

积分

论坛DIY达人

积分
2118
金钱
1951
HASS币
30
 楼主| 发表于 2021-1-11 22:05:03 | 显示全部楼层

感谢回复,导入进去了我理解大佬做的是不是这样,麻烦看看我有没有理解错。

当客厅有人,时间在时间段外,就开灯。同时计时1分钟后关灯。

这样还是自动关灯,我的目的是让人体感应模块在接收到开关从on切换到off的时候,禁用掉人体感应这个流xx秒来避免关掉又感应到又开灯的情况。
-------------
我想是为了避免有人在卫生间里面灯灭了所以想自动开灯,手动关灯的想法。
我现在是用的tasmota固件,接了一个开关到86面板上,这样可以手动关灯了。
尴尬就是在感应模块就在86面板开关边上所以关掉又感应到又开灯。。。
回复

使用道具 举报

43

主题

407

帖子

3619

积分

元老级技术达人

积分
3619
金钱
3207
HASS币
136
发表于 2021-1-11 22:10:00 | 显示全部楼层
就是 开关关-  感应失效是吧

那就是 在 感应触发开   和灯开之间,插入一个间隔 开关状态的节点就可以了。当节点是关闭状态,则流不输出

人体感应开-----开关状态判断 -------开灯
回复

使用道具 举报

43

主题

407

帖子

3619

积分

元老级技术达人

积分
3619
金钱
3207
HASS币
136
发表于 2021-1-11 22:23:38 | 显示全部楼层

加一个变量判断一下变量状态就可以了,刚理解你的意思

本帖最后由 hunterfox 于 2021-1-11 22:25 编辑
[{"id":"cb715417.989048","type":"server-state-changed","z":"9e9c2d22.11217","name":"客厅有人","server":"2b887588.e131fa","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.b03_12","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":140,"y":1420,"wires":[["89b1d98.8e82028"]]},{"id":"4bc7ab2f.002b24","type":"stoptimer2","z":"9e9c2d22.11217","duration":"1","durationType":"num","units":"Minute","payloadtype":"str","payloadval":"关灯成功","name":"","x":360,"y":1500,"wires":[["4b0818f1.587078"],[]]},{"id":"4b0818f1.587078","type":"switch","z":"9e9c2d22.11217","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":510,"y":1500,"wires":[["126467c8.172578"],["621b8707.426dd8"]]},{"id":"46c9bc16.a44884","type":"api-call-service","z":"9e9c2d22.11217","name":"开小米灯","server":"2b887588.e131fa","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.gateway_light_04cf8ca9cb57","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":880,"y":1420,"wires":[[]]},{"id":"621b8707.426dd8","type":"api-call-service","z":"9e9c2d22.11217","name":"关小米灯","server":"2b887588.e131fa","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.gateway_light_04cf8ca9cb57","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":740,"y":1540,"wires":[[]]},{"id":"89b1d98.8e82028","type":"time-range-switch","z":"9e9c2d22.11217","name":"","lat":"","lon":"","startTime":"6:00","endTime":"21:30","startOffset":0,"endOffset":0,"x":290,"y":1400,"wires":[[],["4bc7ab2f.002b24","126467c8.172578"]]},{"id":"c09c1da8.cdf9d","type":"trigger","z":"9e9c2d22.11217","op1":"0","op2":"1","op1type":"str","op2type":"str","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","name":"封闭时间","x":280,"y":1560,"wires":[["c607f25b.2a00d"]]},{"id":"131e1e56.5a6f22","type":"server-state-changed","z":"9e9c2d22.11217","name":"按键开关","server":"2b887588.e131fa","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.espapi02_key2gpio2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":100,"y":1560,"wires":[["c09c1da8.cdf9d"]]},{"id":"c607f25b.2a00d","type":"change","z":"9e9c2d22.11217","name":"","rules":[{"t":"set","p":"closetime","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":1580,"wires":[[]]},{"id":"126467c8.172578","type":"switch","z":"9e9c2d22.11217","name":"","property":"closetime","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":710,"y":1440,"wires":[["46c9bc16.a44884"],[]]},{"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 收起 理由
innx + 5 厉害了word楼主!

查看全部评分

回复

使用道具 举报

21

主题

162

帖子

2118

积分

论坛DIY达人

积分
2118
金钱
1951
HASS币
30
 楼主| 发表于 2021-1-11 22:28:30 | 显示全部楼层
hunterfox 发表于 2021-1-11 22:10
就是 开关关-  感应失效是吧

那就是 在 感应触发开   和灯开之间,插入一个间隔 开关状态的节点就可以了。 ...

感谢。这个方向对了,但是还是没有状态从on到off后xx秒失效的效果
回复

使用道具 举报

21

主题

162

帖子

2118

积分

论坛DIY达人

积分
2118
金钱
1951
HASS币
30
 楼主| 发表于 2021-1-11 22:34:20 | 显示全部楼层

感谢回了2个帖子,请教下第二个流程的closetime是怎么应用的?我导入了nodered看2个流程是没有关联?
回复

使用道具 举报

43

主题

407

帖子

3619

积分

元老级技术达人

积分
3619
金钱
3207
HASS币
136
发表于 2021-1-11 22:36:31 | 显示全部楼层
innx 发表于 2021-1-11 22:34
感谢回了2个帖子,请教下第二个流程的closetime是怎么应用的?我导入了nodered看2个流程是没有关联? ...

closetime 是我设定的一个变量,当你关开关时, 就会对closetime 进行赋值,XX秒后再赋另一个值。  在人体感应时, 加一个switch 检测 closetime这个变量当前值,在封闭期内,不进行开灯操作

评分

参与人数 1金钱 +5 收起 理由
innx + 5 厉害了word楼主!

查看全部评分

回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-23 23:01 , Processed in 0.057755 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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