Fix timer not being canceled when motion is detected again

This commit is contained in:
2025-02-23 22:54:49 -05:00
parent e23c78c971
commit 0f6b6a8275
5 changed files with 18 additions and 13 deletions

View File

@ -9,10 +9,11 @@ const newDuration = duration * 60
if (payload === 'on') {
if (lux <= threshold && lights === 'off') {
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
node.send([msg,null])
node.send([msg,msg,null])
} else {
if (lights === 'on') {
node.status({fill:'red',shape:'ring',text:'Lights already on'})
node.send([null,msg,null])
} else {
node.status({fill:'red',shape:'ring',text:'Too bright'})
}
@ -21,7 +22,7 @@ if (payload === 'on') {
if (lights === 'on') {
msg.duration = newDuration
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
node.send([null,msg])
node.send([null,null,msg])
} else {
node.status({fill:"red",shape:"ring",text:"Lights already off"})
}

View File

@ -10,10 +10,11 @@ const newDuration = duration * 60
if (payload === 'on') {
if (lux <= threshold && (lights === 'off' || selScene === 'Nightlight')) {
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
node.send([msg,null])
node.send([msg,msg,null])
} else {
if (lights === 'on') {
node.status({fill:'red',shape:'ring',text:'Lights already on'})
node.send([null,msg,null])
} else {
node.status({fill:'red',shape:'ring',text:'Too bright'})
}
@ -22,7 +23,7 @@ if (payload === 'on') {
if (lights === 'on') {
msg.duration = newDuration
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
node.send([null,msg])
node.send([null,null,msg])
} else {
node.status({fill:"red",shape:"ring",text:"Lights already off"})
}

View File

@ -11,10 +11,11 @@ if (sleeping === 'off') {
if (payload === 'on') {
if (lux <= threshold && lights === 'off') {
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
node.send([msg,null])
node.send([msg,msg,null])
} else {
if (lights === 'off') {
if (lights === 'on') {
node.status({fill:'red',shape:'ring',text:'Lights already on'})
node.send([null,msg,null])
} else {
node.status({fill:'red',shape:'ring',text:'Too bright'})
}
@ -23,7 +24,7 @@ if (sleeping === 'off') {
if (lights === 'on') {
msg.duration = newDuration
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
node.send([null,msg])
node.send([null,null,msg])
} else {
node.status({fill:"red",shape:"ring",text:"Lights already off"})
}

View File

@ -11,10 +11,11 @@ if (sleeping === 'off') {
if (payload === 'on') {
if (lux <= threshold && lights === 'off') {
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
node.send([msg,null])
node.send([msg,msg,null])
} else {
if (lights === 'off') {
if (lights === 'on') {
node.status({fill:'red',shape:'ring',text:'Lights already on'})
node.send([null,msg,null])
} else {
node.status({fill:'red',shape:'ring',text:'Too bright'})
}
@ -23,7 +24,7 @@ if (sleeping === 'off') {
if (lights === 'on') {
msg.duration = newDuration
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
node.send([null,msg])
node.send([null,null,msg])
} else {
node.status({fill:"red",shape:"ring",text:"Lights already off"})
}

View File

@ -14,10 +14,11 @@ if (peopleSleeping === false && nightMode === 'off') {
if (payload === 'on') {
if (lux <= threshold && lights === 'off') {
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
node.send([msg,null])
node.send([msg,msg,null])
} else {
if (lights === 'off') {
if (lights === 'on') {
node.status({fill:'red',shape:'ring',text:'Lights already on'})
node.send([null,msg,null])
} else {
node.status({fill:'red',shape:'ring',text:'Too bright'})
}
@ -26,7 +27,7 @@ if (peopleSleeping === false && nightMode === 'off') {
if (lights === 'on') {
msg.duration = newDuration
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
node.send([null,msg])
node.send([null,null,msg])
} else {
node.status({fill:"red",shape:"ring",text:"Lights already off"})
}