Rework upstairs bathroom motion lighting when timer finishes
tm24fan8/Home-Assistant-Configs#176
This commit is contained in:
33
second-floor-lighting/upstairs-bathroom/timer-finished.js
Normal file
33
second-floor-lighting/upstairs-bathroom/timer-finished.js
Normal file
@ -0,0 +1,33 @@
|
||||
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 = {}
|
||||
let late = {}
|
||||
|
||||
if (nightMode === 'on' || (earlyNightMode === 'on' && masterBedroomSleep === 'on')) {
|
||||
late = true
|
||||
scene = 'Single Nightlight'
|
||||
} else {
|
||||
late = false
|
||||
scene = 'Nightlight'
|
||||
}
|
||||
|
||||
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'})
|
||||
}
|
Reference in New Issue
Block a user