Rename floor-based folders
This commit is contained in:
34
second-floor/emma-bedroom/emma-bedroom.js
Normal file
34
second-floor/emma-bedroom/emma-bedroom.js
Normal file
@ -0,0 +1,34 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const lights = states['light.emma_bedroom_light'].state
|
||||
const duration = states['input_number.emma_bedroom_lights_off_delay'].state
|
||||
const lux = parseInt(states['sensor.emma_bedroom_illuminance'].state)
|
||||
const threshold = parseInt(states['input_number.emma_bedroom_lux_threshold'].state)
|
||||
const sleeping = states['input_boolean.emma_sleeping'].state
|
||||
const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
if (sleeping === 'off') {
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold && lights === 'off') {
|
||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||
node.send([msg,msg,null])
|
||||
} else {
|
||||
if (lights === 'on') {
|
||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||
node.send([null,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,null,msg])
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})
|
||||
}
|
34
second-floor/kallen-bedroom/kallen-bedroom.js
Normal file
34
second-floor/kallen-bedroom/kallen-bedroom.js
Normal file
@ -0,0 +1,34 @@
|
||||
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 === 'off') {
|
||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||
node.send([msg,msg,null])
|
||||
} else {
|
||||
if (lights === 'on') {
|
||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||
node.send([null,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,null,msg])
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})
|
||||
}
|
37
second-floor/master-bedroom/master-bedroom.js
Normal file
37
second-floor/master-bedroom/master-bedroom.js
Normal file
@ -0,0 +1,37 @@
|
||||
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 masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state
|
||||
const kallenBedroomSleep = states['input_boolean.kallen_sleeping'].state
|
||||
const peopleSleeping = (masterBedroomSleep === 'on' || kallenBedroomSleep === 'on')
|
||||
const nightMode = states['input_boolean.night_mode'].state
|
||||
const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
if (peopleSleeping === false && nightMode === 'off') {
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold && lights === 'off') {
|
||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||
node.send([msg,msg,null])
|
||||
} else {
|
||||
if (lights === 'on') {
|
||||
node.status({fill:'red',shape:'ring',text:'Lights already on'})
|
||||
node.send([null,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,null,msg])
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})
|
||||
}
|
43
second-floor/stairwell/adjust.js
Normal file
43
second-floor/stairwell/adjust.js
Normal file
@ -0,0 +1,43 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const earlyNightMode = states['binary_sensor.early_night_mode'].state
|
||||
const giveMeDarkness = states['input_boolean.give_me_darkness'].state
|
||||
const nightMode = states['input_boolean.night_mode'].state
|
||||
const goodnight = states['input_boolean.goodnight'].state
|
||||
const payload = msg.payload
|
||||
|
||||
let brt1 = 50
|
||||
let brt2 = 100
|
||||
let brt3 = 150
|
||||
let brtmax = 255
|
||||
let colortemp = {}
|
||||
let brt = {}
|
||||
|
||||
if (earlyNightMode === 'off' && giveMeDarkness === 'off' && nightMode === 'off' && goodnight === 'off') {
|
||||
colortemp = 4000
|
||||
} else {
|
||||
colortemp = 2000
|
||||
}
|
||||
|
||||
if (goodnight === 'on') {
|
||||
brt = brt1
|
||||
} else if (nightMode === 'on') {
|
||||
brt = brt3
|
||||
} else if (giveMeDarkness === 'on') {
|
||||
brt === brt2
|
||||
} else if (earlyNightMode === 'on') {
|
||||
brt = brt3
|
||||
} else {
|
||||
brt = brtmax
|
||||
}
|
||||
|
||||
let msgAdjust = {
|
||||
"brightness": brt,
|
||||
"colortemp": colortemp
|
||||
}
|
||||
|
||||
if (payload === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Adjustments Sent'})
|
||||
node.send(msgAdjust)
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Light Off'})
|
||||
}
|
56
second-floor/stairwell/on-off.js
Normal file
56
second-floor/stairwell/on-off.js
Normal file
@ -0,0 +1,56 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const stairwellLights = states['light.stairwell_led_strip'].state
|
||||
const hallwayLights = states['light.hallway_overhead'].state
|
||||
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')
|
||||
const duration = states['input_number.stairwell_lights_off_delay'].state
|
||||
const lux = parseInt(states['sensor.stairwell_bottom_illuminance'].state)
|
||||
const threshold = parseInt(states['input_number.stairwell_lux_threshold'].state)
|
||||
const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
let hallwayScene = {}
|
||||
let hallwayAction = {}
|
||||
|
||||
if (payload === 'on') {
|
||||
if (goodnight === 'on') {
|
||||
hallwayAction = 'off'
|
||||
} else if (nightMode === 'on' || (peopleSleeping === true && earlyNightMode === 'on')) {
|
||||
hallwayAction = 'on'
|
||||
hallwayScene = 'Nightlight'
|
||||
} else if (earlyNightMode === 'on') {
|
||||
hallwayAction = 'on'
|
||||
hallwayScene = 'Adaptive'
|
||||
} else {
|
||||
hallwayAction = 'off'
|
||||
}
|
||||
}
|
||||
|
||||
msg.hallway = hallwayAction
|
||||
msg.scene = hallwayScene
|
||||
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold || stairwellLights === 'on' || hallwayLights === 'on') {
|
||||
if (hallwayScene === 'Adaptive') {
|
||||
node.send([null,null,msg,msg])
|
||||
} else if (hallwayAction === 'on') {
|
||||
node.send([null,null,msg,null])
|
||||
}
|
||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
||||
node.send([msg,null,null,null])
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Too bright'})
|
||||
}
|
||||
} else if (payload === 'off') {
|
||||
if (stairwellLights === 'on' || hallwayLights === 'on') {
|
||||
msg.duration = newDuration
|
||||
node.status({fill:"green",shape:"dot",text:parseInt(duration) + ' minutes'})
|
||||
node.send([null,msg,null,null])
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||
}
|
||||
}
|
34
second-floor/stairwell/timer-finished.js
Normal file
34
second-floor/stairwell/timer-finished.js
Normal file
@ -0,0 +1,34 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
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' || peopleSleeping === true) {
|
||||
hallwayAction = 'off'
|
||||
} else if (earlyNightMode === 'on' || nightMode === 'on') {
|
||||
hallwayAction = 'on'
|
||||
hallwayScene = 'Nightlight'
|
||||
} else {
|
||||
hallwayAction = 'off'
|
||||
}
|
||||
|
||||
msg.hallway = hallwayAction
|
||||
|
||||
// Turn off Stairwell LED Strip
|
||||
node.send([null,null,msg])
|
||||
|
||||
// Hallway actions
|
||||
if (hallwayAction === 'on') {
|
||||
msg.scene = hallwayScene
|
||||
node.status({fill:'green',shape:'dot',text:'Hallway ' + hallwayScene})
|
||||
node.send([msg,null,null])
|
||||
} else if (hallwayAction === 'off') {
|
||||
node.status({fill:'green',shape:'dot',text:'Hallway Off'})
|
||||
node.send([null,msg,null])
|
||||
}
|
25
second-floor/upstairs-bathroom/auto-shower-mode.js
Normal file
25
second-floor/upstairs-bathroom/auto-shower-mode.js
Normal file
@ -0,0 +1,25 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const showerMode = states['input_boolean.shower_mode'].state
|
||||
const tempChange = parseFloat(msg.payload)
|
||||
|
||||
let action = {}
|
||||
|
||||
if (tempChange < 0) {
|
||||
action = 'off'
|
||||
} else if (tempChange >= 5.0) {
|
||||
action = 'on'
|
||||
} else {
|
||||
action = 'none'
|
||||
}
|
||||
|
||||
let actionMsg = {
|
||||
'action': 'turn_' + action
|
||||
}
|
||||
|
||||
if ((action === 'on' && showerMode === 'off') || (action === 'off' && showerMode === 'on')) {
|
||||
node.status({fill:'green',shape:'dot',text:'Shower Mode ' + action})
|
||||
node.send(actionMsg)
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'No action taken'})
|
||||
return null
|
||||
}
|
42
second-floor/upstairs-bathroom/motion-detected.js
Normal file
42
second-floor/upstairs-bathroom/motion-detected.js
Normal file
@ -0,0 +1,42 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const lights = states['light.upstairs_bathroom_lights'].state
|
||||
const duration = states['input_number.upstairs_bathroom_motion_off_delay'].state
|
||||
const lux = parseInt(states['sensor.upstairs_bathroom_illuminance'].state)
|
||||
const threshold = parseInt(states['input_number.upstairs_bathroom_lux_threshold'].state)
|
||||
const showerMode = states['input_boolean.shower_mode'].state
|
||||
const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
let timerCancel = {
|
||||
"payload": "stop"
|
||||
}
|
||||
|
||||
if (showerMode === 'off') {
|
||||
if (payload === 'on') {
|
||||
node.send([null,null,timerCancel])
|
||||
if (lux <= threshold || lights === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights On'})
|
||||
node.send([msg,null,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,null])
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Lights already off"})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node.log("----- Upstairs Bathroom Motion Parameters Start -----")
|
||||
node.log("Upstairs Bathroom payload: " + payload)
|
||||
node.log("Upstairs Bathroom lights: " + lights)
|
||||
node.log("Upstairs Bathroom duration: " + duration)
|
||||
node.log("Upstairs Bathroom newDuration: " + newDuration)
|
||||
node.log("Upstairs Bathroom lux: " + lux)
|
||||
node.log("Upstairs Bathroom threshold: " + threshold)
|
||||
node.log("Upstairs Bathroom showerMode: " + showerMode)
|
||||
node.log("----- Upstairs Bathroom Motion Parameters End -----")
|
59
second-floor/upstairs-bathroom/shower-mode.js
Normal file
59
second-floor/upstairs-bathroom/shower-mode.js
Normal file
@ -0,0 +1,59 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const occupied = states['binary_sensor.upstairs_bathroom_occupied'].state
|
||||
const earlyNightMode = states['binary_sensor.early_night_mode'].state
|
||||
const nightMode = states['input_boolean.night_mode'].state
|
||||
const kallenOvernight = states['input_boolean.kallen_overnight'].state
|
||||
const motion = states['binary_sensor.upstairs_bathroom_motion'].state
|
||||
const payload = msg.payload
|
||||
|
||||
let timerCancel = {
|
||||
"payload": "stop"
|
||||
}
|
||||
|
||||
let scene = {}
|
||||
if (payload === 'on') {
|
||||
scene = 'Bright'
|
||||
} else {
|
||||
if (motion === 'on') {
|
||||
scene = 'Adaptive'
|
||||
} else {
|
||||
scene = 'Single Nightlight'
|
||||
}
|
||||
}
|
||||
|
||||
if (payload === 'on') {
|
||||
msg.scene = scene
|
||||
node.status({fill:'green',shape:'dot',text:'Shower Mode On'})
|
||||
node.send([timerCancel,msg,null])
|
||||
} else if (payload === 'off') {
|
||||
node.send([timerCancel,null,null])
|
||||
if (motion === 'on') {
|
||||
msg.scene = scene
|
||||
node.status({fill:'green',shape:'dot',text:'Lights Adaptive'})
|
||||
node.send([null,msg,null])
|
||||
} else if (earlyNightMode === 'on') {
|
||||
if (kallenOvernight === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights Off'})
|
||||
node.send([null,null,msg])
|
||||
} else {
|
||||
msg.scene = scene
|
||||
node.status({fill:'green',shape:'dot',text:'Scene Set'})
|
||||
node.send([null,msg,null])
|
||||
}
|
||||
} else {
|
||||
node.status({fill:'green',shape:'dot',text:'Lights Off'})
|
||||
node.send([null,null,msg])
|
||||
}
|
||||
}
|
||||
|
||||
node.log("----- Upstairs Bathroom Shower Mode Parameters Start -----")
|
||||
node.log("Upstairs Bathroom payload: " + payload)
|
||||
node.log("Upstairs Bathroom scene: " + scene)
|
||||
if (payload === 'off') {
|
||||
node.log("Upstairs Bathroom occupied: " + occupied)
|
||||
node.log("Upstairs Bathroom earlyNightMode: " + earlyNightMode)
|
||||
node.log("Upstairs Bathroom nightMode: " + nightMode)
|
||||
node.log("Upstairs Bathroom kallenOvernight: " + kallenOvernight)
|
||||
node.log("Upstairs Bathroom motion: " + motion)
|
||||
}
|
||||
node.log("----- Upstairs Bathroom Shower Mode Parameters End -----")
|
41
second-floor/upstairs-bathroom/timer-finished.js
Normal file
41
second-floor/upstairs-bathroom/timer-finished.js
Normal file
@ -0,0 +1,41 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const showerMode = states['input_boolean.shower_mode'].state
|
||||
const earlyNightMode = states['binary_sensor.early_night_mode'].state
|
||||
const kallenOvernight = states['input_boolean.kallen_overnight'].state
|
||||
const nightMode = states['input_boolean.night_mode'].state
|
||||
const masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state
|
||||
|
||||
let scene = 'Single Nightlight'
|
||||
let late = {}
|
||||
|
||||
if (nightMode === 'on' || (earlyNightMode === 'on' && masterBedroomSleep === 'on')) {
|
||||
late = true
|
||||
} else {
|
||||
late = false
|
||||
}
|
||||
|
||||
if (showerMode === 'off') {
|
||||
if (earlyNightMode === 'off') {
|
||||
node.send([null,null,msg])
|
||||
node.status({fill:'green',shape:'dot',text:'Lights Off'})
|
||||
} else {
|
||||
msg.option = scene
|
||||
node.send([null,msg,null])
|
||||
if (late === true && kallenOvernight === 'on') {
|
||||
node.send([msg,null,null])
|
||||
}
|
||||
node.status({fill:'green',shape:'dot',text:'Scene set to ' + scene})
|
||||
}
|
||||
} else {
|
||||
node.status({fill:'red',shape:'ring',text:'Blocked'})
|
||||
}
|
||||
|
||||
node.log("----- Upstairs Bathroom Timer Parameters Start -----")
|
||||
node.log("Upstairs Bathroom showerMode: " + showerMode)
|
||||
node.log("Upstairs Bathroom earlyNightMode: " + showerMode)
|
||||
node.log("Upstairs Bathroom kallenOvernight: " + kallenOvernight)
|
||||
node.log("Upstairs Bathroom nightMode: " + nightMode)
|
||||
node.log("Upstairs Bathroom masterBedroomSleep: " + masterBedroomSleep)
|
||||
node.log("Upstairs Bathroom scene: " + scene)
|
||||
node.log("Upstairs Bathroom late: " + late)
|
||||
node.log("----- Upstairs Bathroom Timer Parameters End -----")
|
Reference in New Issue
Block a user