From e23c78c971c76a924906f8b78e803efd4fd5a80f Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Sun, 23 Feb 2025 01:07:31 -0500 Subject: [PATCH] Improve motion lighting in some rooms Motion lighting should no longer reset lights to adaptive when scene or brightness has been changed manually --- .../downstairs-bathroom/downstairs-bathroom.js | 10 +++++++--- first-floor-lighting/mud-room/mud-room.js | 11 ++++++++--- second-floor-lighting/emma-bedroom/emma-bedroom.js | 10 +++++++--- .../kallen-bedroom/kallen-bedroom.js | 10 +++++++--- .../master-bedroom/master-bedroom.js | 10 +++++++--- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/first-floor-lighting/downstairs-bathroom/downstairs-bathroom.js b/first-floor-lighting/downstairs-bathroom/downstairs-bathroom.js index cddce53..77ffa3d 100644 --- a/first-floor-lighting/downstairs-bathroom/downstairs-bathroom.js +++ b/first-floor-lighting/downstairs-bathroom/downstairs-bathroom.js @@ -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') { diff --git a/first-floor-lighting/mud-room/mud-room.js b/first-floor-lighting/mud-room/mud-room.js index d0da4f6..c649246 100644 --- a/first-floor-lighting/mud-room/mud-room.js +++ b/first-floor-lighting/mud-room/mud-room.js @@ -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') { diff --git a/second-floor-lighting/emma-bedroom/emma-bedroom.js b/second-floor-lighting/emma-bedroom/emma-bedroom.js index c5453e8..51092e1 100644 --- a/second-floor-lighting/emma-bedroom/emma-bedroom.js +++ b/second-floor-lighting/emma-bedroom/emma-bedroom.js @@ -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') { diff --git a/second-floor-lighting/kallen-bedroom/kallen-bedroom.js b/second-floor-lighting/kallen-bedroom/kallen-bedroom.js index e8e4149..aa220c1 100644 --- a/second-floor-lighting/kallen-bedroom/kallen-bedroom.js +++ b/second-floor-lighting/kallen-bedroom/kallen-bedroom.js @@ -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') { diff --git a/second-floor-lighting/master-bedroom/master-bedroom.js b/second-floor-lighting/master-bedroom/master-bedroom.js index 4b0b5ac..e85b372 100644 --- a/second-floor-lighting/master-bedroom/master-bedroom.js +++ b/second-floor-lighting/master-bedroom/master-bedroom.js @@ -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') {