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:
2025-02-23 01:07:31 -05:00
parent 87ed0e89c0
commit e23c78c971
5 changed files with 36 additions and 15 deletions

View File

@ -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') {

View File

@ -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') {

View File

@ -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') {

View File

@ -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') {

View File

@ -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') {