@sdetweil said in PIR sensor to turn on LED strip:
use my updated fork…
https://github.com/sdetweil/MMM-PiLights
it responds to the PIR modules USER_PRESENCE notification (true = turn on, false = turn off)
if lights are off and on is sent, it will restore the previous sequence set with the normal
SEQUENCE notification
Thanks @sdetweil
Let’s see if I understand:
- By default the LEDs will be off, until the “MMM-GPIO-Notifications” module detects something.
- If the PIR detects the movement the “MMM-GPIO-Notifications” module will send the notification USER_PRESENCE = true and the LEDs will turn on
- After some time without movement the “MMM-GPIO-Notifications” module will send the notification USER_PRESENCE = false and the LEDs will turn off
Correct?
I’m not a developer, but I’m still trying to understand your change in the code:
else if (notification === ' USER_PRESENCE'){
if(payload == false){
this.leds.allOFF();
} else {
// user present, restore the last active sequence
Promise.resolve(this.runSequence(this.lastSequence.sequence, thi,lastSequence.iterations,this.lastSequence.delay)
.catch((err) => {
this.log('user present Sequence error: ' + err.message);
}));
why can’t I see this notification in the code?
(notification === ' USER_PRESENCE'){
if(payload == true){
this.leds.allON();
}
Thanks again!