Fix timer not being canceled when motion is detected again
This commit is contained in:
@ -9,10 +9,11 @@ const newDuration = duration * 60
|
|||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold && lights === 'off') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
} else {
|
} else {
|
||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
@ -21,7 +22,7 @@ if (payload === 'on') {
|
|||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,11 @@ const newDuration = duration * 60
|
|||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold && (lights === 'off' || selScene === 'Nightlight')) {
|
if (lux <= threshold && (lights === 'off' || selScene === 'Nightlight')) {
|
||||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
} else {
|
} else {
|
||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
@ -22,7 +23,7 @@ if (payload === 'on') {
|
|||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,11 @@ if (sleeping === 'off') {
|
|||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold && lights === 'off') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
} else {
|
} else {
|
||||||
if (lights === 'off') {
|
if (lights === 'on') {
|
||||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
@ -23,7 +24,7 @@ if (sleeping === 'off') {
|
|||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,11 @@ if (sleeping === 'off') {
|
|||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold && lights === 'off') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
} else {
|
} else {
|
||||||
if (lights === 'off') {
|
if (lights === 'on') {
|
||||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
@ -23,7 +24,7 @@ if (sleeping === 'off') {
|
|||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,11 @@ if (peopleSleeping === false && nightMode === 'off') {
|
|||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold && lights === 'off') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
node.send([msg,null])
|
node.send([msg,msg,null])
|
||||||
} else {
|
} else {
|
||||||
if (lights === 'off') {
|
if (lights === 'on') {
|
||||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||||
|
node.send([null,msg,null])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||||
}
|
}
|
||||||
@ -26,7 +27,7 @@ if (peopleSleeping === false && nightMode === 'off') {
|
|||||||
if (lights === 'on') {
|
if (lights === 'on') {
|
||||||
msg.duration = newDuration
|
msg.duration = newDuration
|
||||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||||
node.send([null,msg])
|
node.send([null,null,msg])
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user