Rename floor-based folders
This commit is contained in:
37
first-floor/dining-room/processing.js
Normal file
37
first-floor/dining-room/processing.js
Normal file
@ -0,0 +1,37 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const peoplePresent = states['binary_sensor.people_present'].state
|
||||
const vacationMode = states['input_boolean.vacation_mode'].state
|
||||
const nightMode = states['input_boolean.night_mode'].state
|
||||
const kallenSleeping = states['input_boolean.kallen_sleeping'].state
|
||||
const kallenOvernight = states['input_boolean.kallen_overnight'].state
|
||||
const duration = states['input_number.dining_room_lights_off_delay'].state
|
||||
const guestMode = states['input_boolean.guest_mode'].state
|
||||
const newDuration = duration * 60
|
||||
const topic = msg.topic
|
||||
const payload = msg.payload
|
||||
|
||||
let block = {}
|
||||
|
||||
if ((peoplePresent === 'on' && vacationMode === 'off' && nightMode === 'on' && guestMode === 'off') && (kallenSleeping === 'on' || kallenOvernight === 'on')) {
|
||||
block = false
|
||||
} else {
|
||||
block = true
|
||||
}
|
||||
|
||||
if (topic === 'motion' && block === false) {
|
||||
if (payload === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Motion On'})
|
||||
node.send([msg,null,null])
|
||||
} else if (payload === 'off') {
|
||||
msg.duration = newDuration
|
||||
node.status({fill:'red',shape:'ring',text:parseInt(duration) + ' minutes'})
|
||||
node.send([null,msg,null])
|
||||
}
|
||||
} else if (topic === 'timer') {
|
||||
if (payload === 'finished') {
|
||||
node.status({fill:'green',shape:'dot',text:'Timer Finished'})
|
||||
node.send([null,null,msg])
|
||||
}
|
||||
} else if (block === true) {
|
||||
node.status({fill:'red',shape:'ring',text:'Blocked'})
|
||||
}
|
29
first-floor/downstairs-bathroom/downstairs-bathroom.js
Normal file
29
first-floor/downstairs-bathroom/downstairs-bathroom.js
Normal file
@ -0,0 +1,29 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const lights = states['light.downstairs_bathroom_lights'].state
|
||||
const duration = states['input_number.downstairs_bathroom_lights_off_delay'].state
|
||||
const lux = parseInt(states['sensor.downstairs_bathroom_illuminance'].state)
|
||||
const threshold = parseInt(states['input_number.downstairs_bathroom_lux_threshold'].state)
|
||||
const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
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"})
|
||||
}
|
||||
}
|
37
first-floor/living-room/processing.js
Normal file
37
first-floor/living-room/processing.js
Normal file
@ -0,0 +1,37 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const peoplePresent = states['binary_sensor.people_present'].state
|
||||
const vacationMode = states['input_boolean.vacation_mode'].state
|
||||
const nightMode = states['input_boolean.night_mode'].state
|
||||
const kallenSleeping = states['input_boolean.kallen_sleeping'].state
|
||||
const kallenOvernight = states['input_boolean.kallen_overnight'].state
|
||||
const duration = states['input_number.living_room_lights_off_delay'].state
|
||||
const guestMode = states['input_boolean.guest_mode'].state
|
||||
const newDuration = duration * 60
|
||||
const topic = msg.topic
|
||||
const payload = msg.payload
|
||||
|
||||
let block = {}
|
||||
|
||||
if ((peoplePresent === 'on' && vacationMode === 'off' && nightMode === 'on' && guestMode === 'off') && (kallenSleeping === 'on' || kallenOvernight === 'on')) {
|
||||
block = false
|
||||
} else {
|
||||
block = true
|
||||
}
|
||||
|
||||
if (topic === 'motion' && block === false) {
|
||||
if (payload === 'on') {
|
||||
node.status({fill:'green',shape:'dot',text:'Motion On'})
|
||||
node.send([msg,null,null])
|
||||
} else if (payload === 'off') {
|
||||
msg.duration = newDuration
|
||||
node.status({fill:'red',shape:'ring',text:parseInt(duration) + ' minutes'})
|
||||
node.send([null,msg,null])
|
||||
}
|
||||
} else if (topic === 'timer') {
|
||||
if (payload === 'finished') {
|
||||
node.status({fill:'green',shape:'dot',text:'Timer Finished'})
|
||||
node.send([null,null,msg])
|
||||
}
|
||||
} else if (block === true) {
|
||||
node.status({fill:'red',shape:'ring',text:'Blocked'})
|
||||
}
|
30
first-floor/mud-room/mud-room.js
Normal file
30
first-floor/mud-room/mud-room.js
Normal file
@ -0,0 +1,30 @@
|
||||
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)
|
||||
const payload = msg.payload
|
||||
const newDuration = duration * 60
|
||||
|
||||
if (payload === 'on') {
|
||||
if (lux <= threshold && (lights === 'off' || selScene === 'Nightlight')) {
|
||||
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"})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user