diff --git a/first-floor-lighting/mud-room/mud-room.js b/first-floor-lighting/mud-room/mud-room.js new file mode 100644 index 0000000..d0da4f6 --- /dev/null +++ b/first-floor-lighting/mud-room/mud-room.js @@ -0,0 +1,24 @@ +const states = global.get('homeassistant.homeAssistant.states') +const lights = states['light.mud_room_overhead'].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) +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'}) + node.send([msg,null]) + } else { + node.status({fill:'red',shape:'ring',text:'Too bright'}) + } +} else if (payload === 'off') { + if (lights === 'on') { + msg.duration = newDuration + node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'}) + node.send([null,msg]) + } else { + node.status({fill:"red",shape:"ring",text:"Lights already off"}) + } +} \ No newline at end of file diff --git a/second-floor-lighting/kallen-bedroom/kallen-bedroom.js b/second-floor-lighting/kallen-bedroom/kallen-bedroom.js new file mode 100644 index 0000000..e8e4149 --- /dev/null +++ b/second-floor-lighting/kallen-bedroom/kallen-bedroom.js @@ -0,0 +1,29 @@ +const states = global.get('homeassistant.homeAssistant.states') +const lights = states['light.kallen_bedroom_lights'].state +const duration = states['input_number.kallen_bedroom_lights_off_delay'].state +const lux = parseInt(states['sensor.kallen_bedroom_illuminance'].state) +const threshold = parseInt(states['input_number.kallen_bedroom_lux_threshold'].state) +const sleeping = states['input_boolean.kallen_sleeping'].state +const payload = msg.payload +const newDuration = duration * 60 + +if (sleeping === 'off') { + if (payload === 'on') { + if (lux <= threshold || lights === 'on') { + node.status({fill:'green',shape:'dot',text:'Lights On'}) + node.send([msg,null]) + } else { + node.status({fill:'red',shape:'ring',text:'Too bright'}) + } + } else if (payload === 'off') { + if (lights === 'on') { + msg.duration = newDuration + node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'}) + node.send([null,msg]) + } else { + node.status({fill:"red",shape:"ring",text:"Lights already off"}) + } + } +} else { + node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'}) +} \ No newline at end of file diff --git a/second-floor-lighting/master-bedroom/master-bedroom.js b/second-floor-lighting/master-bedroom/master-bedroom.js new file mode 100644 index 0000000..f2687ec --- /dev/null +++ b/second-floor-lighting/master-bedroom/master-bedroom.js @@ -0,0 +1,30 @@ +const states = global.get('homeassistant.homeAssistant.states') +const lights = states['light.master_bedroom_lights'].state +const duration = states['input_number.master_bedroom_lights_off_delay'].state +const lux = parseInt(states['sensor.master_bedroom_illuminance'].state) +const threshold = parseInt(states['input_number.master_bedroom_lux_threshold'].state) +const sleeping = states['input_boolean.master_bedroom_sleeping'].state +const nightMode = states['input_boolean.night_mode'].state +const payload = msg.payload +const newDuration = duration * 60 + +if (sleeping === 'off' && nightMode === 'off') { + if (payload === 'on') { + if (lux <= threshold || lights === 'on') { + node.status({fill:'green',shape:'dot',text:'Lights On'}) + node.send([msg,null]) + } else { + node.status({fill:'red',shape:'ring',text:'Too bright'}) + } + } else if (payload === 'off') { + if (lights === 'on') { + msg.duration = newDuration + node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'}) + node.send([null,msg]) + } else { + node.status({fill:"red",shape:"ring",text:"Lights already off"}) + } + } +} else { + node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'}) +} \ No newline at end of file diff --git a/second-floor-lighting/stairwell/on-off.js b/second-floor-lighting/stairwell/on-off.js index 08484bd..c3f570f 100644 --- a/second-floor-lighting/stairwell/on-off.js +++ b/second-floor-lighting/stairwell/on-off.js @@ -21,7 +21,7 @@ if (payload === 'on') { hallwayAction = 'off' } else if (nightMode === 'on' || peopleSleeping === true) { hallwayAction = 'on' - hallwayScene = 'Dimmed' + hallwayScene = 'Nightlight' } else if (earlyNightMode === 'on') { hallwayAction = 'on' hallwayScene = 'Adaptive' diff --git a/second-floor-lighting/stairwell/timer-finished.js b/second-floor-lighting/stairwell/timer-finished.js index 9260728..32310b0 100644 --- a/second-floor-lighting/stairwell/timer-finished.js +++ b/second-floor-lighting/stairwell/timer-finished.js @@ -3,11 +3,13 @@ const earlyNightMode = states['binary_sensor.early_night_mode'].state const nightMode = states['input_boolean.night_mode'].state const goodnight = states['input_boolean.goodnight'].state const masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state +const kallenBedroomSleep = states['input_boolean.kallen_sleeping'].state +const peopleSleeping = (masterBedroomSleep === 'on' || kallenBedroomSleep === 'on') let hallwayScene = {} let hallwayAction = {} -if (goodnight === 'on' || masterBedroomSleep === 'on') { +if (goodnight === 'on' || peopleSleeping === true) { hallwayAction = 'off' } else if (earlyNightMode === 'on' || nightMode === 'on') { hallwayAction = 'on'