Initial commit
This commit is contained in:
48
climate/kallen/old/processing_old.js
Normal file
48
climate/kallen/old/processing_old.js
Normal file
@ -0,0 +1,48 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const vacationMode = states['input_boolean.vacation_mode'].state
|
||||
const overnight = states['input_boolean.kallen_overnight'].state
|
||||
const kallenLoc = states['person.kallen_stork'].state
|
||||
const nightVolume = states['input_number.kallen_bedroom_google_speaker_night_volume'].state
|
||||
const brightness = states['switch.adaptive_lighting_kallen_bedroom'].attributes.brightness_pct
|
||||
const fadeDay = states['input_number.wakeup_lights_fade_day'].state
|
||||
const fadeNight = states['input_number.wakeup_lights_fade_night'].state
|
||||
const hotDay = states['input_boolean.hot_day'].state
|
||||
const heatWarning = states['binary_sensor.heat_warning'].state
|
||||
const fanSeparate = states['binary_sensor.kallen_fan_separate_schedule'].state
|
||||
const topic = msg.topic
|
||||
const toggle = msg.toggle
|
||||
|
||||
let fan = []
|
||||
|
||||
if (hotDay === 'on' || heatWarning === 'on') {
|
||||
fan = 'on'
|
||||
} else {
|
||||
fan = 'off'
|
||||
}
|
||||
|
||||
if (vacationMode === 'off' && overnight === 'off' && kallenLoc === 'home') {
|
||||
if (topic === 'kallen-fan' && fanSeparate === 'on') {
|
||||
node.status({fill:"green",shape:"dot",text:"Fan"});
|
||||
return[null,null,null,msg]
|
||||
} else if (toggle === 'off') {
|
||||
msg.brightness = brightness
|
||||
msg.fade_day = fadeDay * 60
|
||||
msg.fade_night = fadeNight * 60
|
||||
msg.fan = fan
|
||||
node.status({fill:"green",shape:"dot",text:"Wakeup"});
|
||||
return[null,msg,null,null]
|
||||
} else if (toggle === 'on') {
|
||||
msg.volume = nightVolume
|
||||
node.status({fill:"green",shape:"dot",text:"Sleep"});
|
||||
return[null,null,msg,null]
|
||||
}
|
||||
} else {
|
||||
if (topic === 'boolean') {
|
||||
msg.toggle = 'off'
|
||||
node.status({fill:"red",shape:"ring",text:"Blocked"});
|
||||
return [msg,null,null,null]
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Blocked"});
|
||||
return null
|
||||
}
|
||||
}
|
16
climate/kallen/old/schedmode_old.js
Normal file
16
climate/kallen/old/schedmode_old.js
Normal file
@ -0,0 +1,16 @@
|
||||
var states = global.get('homeassistant.homeAssistant.states')
|
||||
var schedMode = states['input_select.scheduled_climate_mode_kallen_fan'].state
|
||||
|
||||
msg.topic = 'common'
|
||||
msg.voice = 'Joanna'
|
||||
|
||||
if (schedMode === 'White Noise') {
|
||||
node.status({fill:"green",shape:"dot",text:"White Noise"});
|
||||
return[msg,null,null]
|
||||
} else if (schedMode === 'Fan') {
|
||||
node.status({fill:"green",shape:"dot",text:"Fan"});
|
||||
return[null,msg,null]
|
||||
} else {
|
||||
node.status({fill:"blue",shape:"dot",text:"N/A"});
|
||||
return[null,null,msg]
|
||||
}
|
10
climate/kallen/prefilter.js
Normal file
10
climate/kallen/prefilter.js
Normal file
@ -0,0 +1,10 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const vacationMode = states['input_boolean.vacation_mode'].state
|
||||
const overnight = states['input_boolean.kallen_overnight'].state
|
||||
const kallenLoc = states['person.kallen_stork'].state
|
||||
|
||||
if (vacationMode === 'off' && overnight === 'off' && kallenLoc === 'home') {
|
||||
node.status({fill:"green",shape:"dot",text:"Proceed"})
|
||||
node.log("Kallen climate flow allowed to proceed")
|
||||
node.send(msg)
|
||||
}
|
134
climate/kallen/processing.js
Normal file
134
climate/kallen/processing.js
Normal file
@ -0,0 +1,134 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const vacationMode = states['input_boolean.vacation_mode'].state
|
||||
const overnight = states['input_boolean.kallen_overnight'].state
|
||||
const kallenLoc = states['person.kallen_stork'].state
|
||||
const dayVolume = states['input_number.kallen_bedroom_google_speaker_day_volume'].state
|
||||
const nightVolume = states['input_number.kallen_bedroom_google_speaker_night_volume'].state
|
||||
const brightness = states['switch.adaptive_lighting_kallen_bedroom'].attributes.brightness_pct
|
||||
const fadeNight = states['input_number.wakeup_lights_fade_night'].state
|
||||
const hotDay = states['input_boolean.hot_day'].state
|
||||
const heatWarning = states['binary_sensor.heat_warning'].state
|
||||
const fanSeparate = states['binary_sensor.kallen_fan_separate_schedule'].state
|
||||
const schedMode = states['input_select.scheduled_climate_mode_kallen_fan'].state
|
||||
const topic = msg.topic
|
||||
const toggle = msg.toggle
|
||||
node.log("Kallen Bedroom: Constants Set")
|
||||
|
||||
let setFan = []
|
||||
let setWhiteNoise = []
|
||||
let setVolume = []
|
||||
let setLights = []
|
||||
node.log("Kallen Bedroom: Variables Defined")
|
||||
|
||||
if (toggle === 'off' && (hotDay === 'on' || heatWarning === 'on')) {
|
||||
setFan = 'turn_on'
|
||||
} else if ((toggle === 'on' || topic === 'kallen-fan') && schedMode === 'Fan') {
|
||||
setFan = 'turn_on'
|
||||
} else {
|
||||
setFan = 'turn_off'
|
||||
}
|
||||
|
||||
if (schedMode === 'White Noise' && toggle === 'on') {
|
||||
setWhiteNoise = 'turn_on'
|
||||
} else {
|
||||
setWhiteNoise = 'turn_off'
|
||||
}
|
||||
|
||||
if (toggle === 'on') {
|
||||
setVolume = parseFloat(nightVolume)
|
||||
setLights = 'turn_on'
|
||||
} else {
|
||||
setVolume = parseFloat(dayVolume)
|
||||
}
|
||||
|
||||
let fadeMult = fadeNight * 60
|
||||
let fadeFinal = Math.round(fadeMult)
|
||||
|
||||
let brtFinal = Math.round(brightness)
|
||||
|
||||
node.log("Kallen Bedroom: Decision Logic Complete")
|
||||
|
||||
let sendFan = {
|
||||
"payload": {
|
||||
"domain": "fan",
|
||||
"service": setFan,
|
||||
"target": {
|
||||
"entity_id": ["fan.kallen_bedroom_fan"]
|
||||
},
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
|
||||
let sendWhiteNoise = {
|
||||
"payload": {
|
||||
"domain": "input_boolean",
|
||||
"service": setWhiteNoise,
|
||||
"target": {
|
||||
"entity_id": ["input_boolean.white_noise_kallen_bedroom"]
|
||||
},
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
|
||||
let sendVolume = {
|
||||
"payload": {
|
||||
"domain": "media_player",
|
||||
"service": "set_volume",
|
||||
"target": {
|
||||
"entity_id": ["media_player.kallen_bedroom_google_speaker"]
|
||||
},
|
||||
"data": {
|
||||
"volume": setVolume
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sendLights = {
|
||||
"payload": {
|
||||
"domain": "light",
|
||||
"service": setLights,
|
||||
"target": {
|
||||
"entity_id": ["light.kallen_bedroom_lights"]
|
||||
},
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
|
||||
let wakeMsg = {
|
||||
"brightness": brtFinal,
|
||||
"fade": fadeFinal
|
||||
}
|
||||
|
||||
let sleepMsg = {
|
||||
"payload": "sleep"
|
||||
}
|
||||
|
||||
node.log("Kallen Bedroom: Message Payloads Defined")
|
||||
|
||||
node.log("----- Kallen Bedroom: Set Parameters -----")
|
||||
node.log("setFan: " + setFan)
|
||||
node.log("setWhiteNoise: " + setWhiteNoise)
|
||||
node.log("setVolume: " + setVolume)
|
||||
node.log("setLights: " + setLights)
|
||||
node.log("----- Kallen Bedroom: End Parameters -----")
|
||||
|
||||
if (vacationMode === 'off' && overnight === 'off' && kallenLoc === 'home') {
|
||||
if (topic === 'kallen-fan' && fanSeparate === 'on') {
|
||||
node.status({fill:"green",shape:"dot",text:"Fan"})
|
||||
node.log("Kallen Bedroom: Early Fan")
|
||||
node.send([null,[sendFan,sendWhiteNoise],null])
|
||||
} else if (toggle === 'off') {
|
||||
node.status({fill:"green",shape:"dot",text:"Wakeup"})
|
||||
node.log("Kallen Bedroom: Wake")
|
||||
node.send([wakeMsg,[sendFan,sendWhiteNoise,sendVolume],null])
|
||||
} else if (toggle === 'on') {
|
||||
node.status({fill:"green",shape:"dot",text:"Sleep"})
|
||||
node.log("Kallen Bedroom: Sleep")
|
||||
node.send([null,[sendFan,sendWhiteNoise,sendVolume,sendLights],sleepMsg])
|
||||
}
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Blocked"})
|
||||
node.log("Kallen Bedroom: Flow Blocked")
|
||||
}
|
||||
|
||||
node.log("Kallen Bedroom: Processing Complete")
|
16
climate/kallen/schedmode.js
Normal file
16
climate/kallen/schedmode.js
Normal file
@ -0,0 +1,16 @@
|
||||
var states = global.get('homeassistant.homeAssistant.states')
|
||||
var schedMode = states['input_select.scheduled_climate_mode_kallen_fan'].state
|
||||
|
||||
msg.topic = 'common'
|
||||
msg.voice = 'Joanna'
|
||||
|
||||
if (schedMode === 'White Noise') {
|
||||
node.status({fill:"green",shape:"dot",text:"White Noise"});
|
||||
return[msg,null,null]
|
||||
} else if (schedMode === 'Fan') {
|
||||
node.status({fill:"green",shape:"dot",text:"Fan"});
|
||||
return[null,msg,null]
|
||||
} else {
|
||||
node.status({fill:"blue",shape:"dot",text:"N/A"});
|
||||
return[null,null,msg]
|
||||
}
|
Reference in New Issue
Block a user