Added a PIR and DHT22 to a light switch for the bathroom for automated lights using some Tasmota rules to keep things self contained and easy to maintain.
Just realized, with these rules, if there’s constant motion for 31+ seconds then the light will still turn off if you set something like this:
rule2 on switch2#state=1 do backlog power1 on; ruletimer1 30 endon on rules#timer=1 do power1 off endon
Do you think we need to find a better way?
Such that the light remains on until motion detected, once motion stops, light turns off after 30 seconds.
Are you able to get the PIR to hold triggered constantly for 30 seconds?
Yes. So I had it on 30s, went inside the bathroom, motion was on, came out and was about to wait 30s but it literally closed after I came out. Then I figured it probably didn’t reset in b/w. Then did another try with waving continuously for 30s in front of the sensor and voila it turned off lights will I was still waving.
Although slightly unrealistic but happened the first time so figured, there could be a better way?
But Other than this has been working pretty amazing. Just trying to make it even better.
Thanks for your amazing videos!
I’m definitely going to try to keep mine triggered. See if this would work. When triggered it turns on, when no motion then it starts the 30 second count down. But thinking this out in my head we might still get the light cut off if motion stops then triggers again.
rule2 on switch2#state=1 do backlog power1; ruletimer1 600 on endon on switch2#state=0 do ruletimer1 30 endon on rules#timer=1 do power1 off endon
rule2 on switch2#state=1 do backlog power1; ruletimer1 0 on endon on switch2#state=0 do ruletimer1 30 endon on rules#timer=1 do power1 off endon
A couple other ideas (not tested!), in case there is a timer set, we would need to clear the timer on state=1(motion). Would a ruletimer1 0 do that but then would it kick the rules#timer1 thing off though. Give it a shot and let me know. Always learning rules myself. Thanks for the comments!
I want to enable a PIR switch only in the example above plus night, but it doesn’t work.
rule1 on switch1#state=1 do backlog event checksunrise=%time%;
event checksunset=%time% endon
on event#checksunrise<%sunrise% do power1 1 endon
on event#checksunset>%sunset% do power1 1 endon;
ruletimer1 0 on endon on switch1#state=0 do ruletimer1 30 endon on rules#timer=1 do power1 off endon
Which code is wrong?