Improve motion lighting in some rooms
Motion lighting should no longer reset lights to adaptive when scene or brightness has been changed manually
This commit is contained in:
@ -7,11 +7,15 @@ const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold || lights === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
||||
if (lux <= threshold && lights === 'off') {
|
||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||
node.send([msg,null])
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
if (lights === 'on') {
|
||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
}
|
||||
}
|
||||
} else if (payload === 'off') {
|
||||
if (lights === 'on') {
|
||||
|
@ -1,5 +1,6 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const lights = states['light.mud_room_overhead'].state
|
||||
const selScene = states['input_text.mud_room_selected_scene'].state
|
||||
const duration = states['input_number.mud_room_lights_off_delay'].state
|
||||
const lux = parseInt(states['sensor.mud_room_illuminance'].state)
|
||||
const threshold = parseInt(states['input_number.mud_room_lux_threshold'].state)
|
||||
@ -7,11 +8,15 @@ const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold || lights === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
||||
if (lux <= threshold && (lights === 'off' || selScene === 'Nightlight')) {
|
||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||
node.send([msg,null])
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
if (lights === 'on') {
|
||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
}
|
||||
}
|
||||
} else if (payload === 'off') {
|
||||
if (lights === 'on') {
|
||||
|
@ -9,11 +9,15 @@ const newDuration = duration * 60
|
||||
|
||||
if (sleeping === 'off') {
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold || lights === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
||||
if (lux <= threshold && lights === 'off') {
|
||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||
node.send([msg,null])
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
if (lights === 'off') {
|
||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
}
|
||||
}
|
||||
} else if (payload === 'off') {
|
||||
if (lights === 'on') {
|
||||
|
@ -9,11 +9,15 @@ const newDuration = duration * 60
|
||||
|
||||
if (sleeping === 'off') {
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold || lights === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
||||
if (lux <= threshold && lights === 'off') {
|
||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||
node.send([msg,null])
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
if (lights === 'off') {
|
||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
}
|
||||
}
|
||||
} else if (payload === 'off') {
|
||||
if (lights === 'on') {
|
||||
|
@ -12,11 +12,15 @@ const newDuration = duration * 60
|
||||
|
||||
if (peopleSleeping === false && nightMode === 'off') {
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold || lights === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
||||
if (lux <= threshold && lights === 'off') {
|
||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||
node.send([msg,null])
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
if (lights === 'off') {
|
||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
}
|
||||
}
|
||||
} else if (payload === 'off') {
|
||||
if (lights === 'on') {
|
||||
|
Reference in New Issue
Block a user