Rename floor-based folders

This commit is contained in:
2025-03-24 03:09:52 -04:00
parent 6b29b8622f
commit 456ec217f2
14 changed files with 0 additions and 0 deletions

View 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
}

View 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 -----")

View 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 -----")

View 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 -----")