Initial commit

This commit is contained in:
2023-09-28 12:28:27 -04:00
commit 25780c8c5d
30 changed files with 1777 additions and 0 deletions

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

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

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

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

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

View File

@ -0,0 +1,89 @@
const states = global.get('homeassistant.homeAssistant.states')
const toggle = msg.payload
const ac = global.get('mb_aircon_installed', "diskCon")
const lastMode = flow.get("lastMode", "diskCon")
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
let setTemp = bedTemp
let setEco = 'none'
let setHvac = 'cool'
let setAcFan = 'High'
let setFan = 'turn_off'
let sendFan = {
"payload": {
"domain": "fan",
"service": setFan,
"target": {
"entity_id": ["fan.master_bedroom_fan"]
},
"data": {}
}
}
let sendHvac = {
"payload": {
"domain": "climate",
"service": "set_hvac_mode",
"target": {
"entity_id": ["climate.master_bedroom_aircon"]
},
"data": {
"hvac_mode": setHvac
}
}
}
let sendTemp = {
"payload": {
"domain": "climate",
"service": "set_temperature",
"target": {
"entity_id": ["climate.master_bedroom_aircon"]
},
"data": {
"temperature": setTemp
}
}
}
let sendEco = {
"payload": {
"domain": "climate",
"service": "set_preset_mode",
"target": {
"entity_id": ["climate.master_bedroom_aircon"]
},
"data": {
"preset_mode": setEco
}
}
}
let sendAcFan = {
"payload": {
"domain": "climate",
"service": "set_fan_mode",
"target": {
"entity_id": ["climate.master_bedroom_aircon"]
},
"data": {
"fan_mode": setAcFan
}
}
}
let reset = {
"topic": "Reset"
}
if (toggle === 'on') {
node.status({fill:"red",shape:"dot",text:"DANGER MODE ACTIVE"})
node.send([null,sendFan,null])
if (ac === 'on') {
node.send([[sendHvac,sendTemp,sendEco,sendTemp],null,null])
}
} else {
node.status({fill:"green",shape:"dot",text:"Danger Mode Off"})
node.send([null,null,reset])
}

View File

@ -0,0 +1,33 @@
const topic = msg.topic
const nightTemp = msg.nighttemp
const acMode = msg.acmode
const fanMode = msg.fanmode
let coolMsg = {
"payload": 'Master bedroom AC temp has been set to ' + nightTemp + '°F as scheduled',
"topic": 'AC Mode: Cooling'
}
let fanOnlyMsg = {
"payload": 'Too cold outside, AC running fan only.',
"topic": "AC Mode: Fan Only"
}
let fanSchedMsg = {
"payload": 'Master bedroom fan has been activated as scheduled.',
"topic": 'Fan Schedule Activated'
}
if (topic === 'mrbedroom-cooling') {
if (acMode === 'AC') {
node.status({fill:"green",shape:"dot",text:"AC Cooling"})
return coolMsg
} else if (acMode === 'Fan') {
node.status({fill:"green",shape:"dot",text:"AC Fan Only"})
return fanOnlyMsg
}
} else if (topic === 'mrbedroom-fan' && fanMode === 'Fan') {
node.status({fill:"green",shape:"dot",text:"Fan Schedule"})
return fanSchedMsg
} else {
node.status({fill:"red",shape:"ring",text:"Notification not sent"})
return null
}

View File

@ -0,0 +1,405 @@
node.log("Master Bedroom Climate: Processing Started")
// pull in the necessary information
const states = global.get('homeassistant.homeAssistant.states')
const allowed = states['input_boolean.master_bedroom_climate_protocol'].state
const ac = global.get('mb_aircon_installed', "diskCon")
const temp = global.get("tempStr")
const payload = msg.payload
const vacation = states['input_boolean.vacation_mode'].state
const highTemp = states['sensor.today_corrected_high_temp'].state
const dayTemp = states['input_number.master_bedroom_daytime_temp'].state
const nightTemp = states['input_number.master_bedroom_night_temp'].state
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
const showerMode = states['input_boolean.shower_mode'].state
const nightVolume = states['input_number.master_bedroom_echo_dot_night_volume'].state
const fanMode = states['input_select.scheduled_climate_mode_master_bedroom_fan'].state
const acMode = states['input_select.scheduled_climate_mode_master_bedroom_aircon'].state
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
const hotDay = states['input_boolean.hot_day'].state
const heatWarning = states["binary_sensor.heat_warning"].state
const showerCooldown = states["timer.shower_mode_cooldown"].state
const earlyNight = states["binary_sensor.early_night_mode"].state
const danger = states['binary_sensor.heat_warning'].attributes.danger
const meltdown = states['input_boolean.meltdown_protocol'].state
const coolingActive = states['input_boolean.master_bedroom_cooling_on'].state
const echoDotDND = 'switch.basement_echo_dot_do_not_disturb_switch'
node.log("Master Bedroom Climate: Constants Set")
// init variables
let setTemp = []
let setEco = []
let setHvac = []
let setFan = []
let setCool = []
let setSleep = []
let setDisplay = []
let time = []
let type = msg.type
let topic = msg.topic
let echoDotService = []
node.log("Master Bedroom Climate: Variables Defined")
// Sleep Switch Handling
if (type === 'sleep' && payload === 'off') {
setDisplay = 'turn_on'
echoDotService = 'turn_off'
if (coolingActive === 'on') {
time = 'night'
} else {
time = 'day'
}
} else if (type === 'sleep' && payload === 'on') {
setDisplay = 'turn_off'
echoDotService = 'turn_on'
time = 'bedtime'
} else {
time = msg.time
}
if (topic === 'mrbedroom-wakeup') {
setSleep = 'turn_off'
}
// Day Time
if (time === 'day') {
if (type === 'auto') {
setCool = 'turn_off'
}
if (earlyNight === 'off') {
setFan = "turn_off"
if (ac === 'on') {
if (danger === 'Extreme') {
setTemp = nightTemp
setEco = "eco"
setHvac = "cool"
} else if (hotDay === 'on' || heatWarning === 'on') {
setTemp = dayTemp
setEco = "eco"
setHvac = "cool"
} else {
setTemp = nightTemp
setEco = "eco"
setHvac = "off"
}
}
} else if (earlyNight === 'on') {
if (ac === 'on') {
if (danger === 'Extreme') {
setTemp === bedTemp
} else {
setTemp = nightTemp
}
if (fanMode === 'Fan') {
setFan = 'turn_on'
} else {
setFan = 'turn_off'
}
if (acMode === 'AC') {
setHvac = 'cool'
} else if (acMode === 'fan') {
setHvac = 'fan_only'
} else {
setHvac = 'off'
}
if (hotDay === 'on') {
setEco = 'off'
} else {
setEco = 'on'
}
}
}
// Night Time
} else if (time === 'night') {
if (type === 'auto') {
setCool = 'turn_on'
}
if (danger === 'Extreme') {
setTemp = bedTemp
} else {
setTemp = nightTemp
}
if (hotDay === 'on' || sleeping === 'on') {
setEco = 'none'
} else {
setEco = 'eco'
}
if (acMode === 'AC') {
setHvac = 'cool'
} else if (acMode === 'Fan') {
setHvac = 'fan_only'
} else {
setHvac = 'off'
}
if (type === 'sleep' && payload === 'off') {
setFan = 'turn_off'
} else if (fanMode === 'Fan') {
setFan = 'turn_on'
}
// Bed Time
} else if (time === 'bedtime') {
if (ac === 'on') {
setTemp = bedTemp
setEco = 'none'
if (acMode === 'AC') {
setHvac = 'cool'
} else if (acMode === 'Fan') {
setHvac = "fan_only"
}
}
if (fanMode === 'Fan') {
setFan = 'turn_on'
}
}
node.log("Master Bedroom Climate: Decision Logic Complete")
// Define message payloads
let sendFan = {
"payload": {
"domain": "fan",
"service": setFan,
"target": {
"entity_id": ["fan.master_bedroom_fan"]
},
"data": {}
}
}
let sendCool = {
"payload": {
"domain": "input_boolean",
"service": setCool,
"target": {
"entity_id": ["input_boolean.master_bedroom_cooling_on"]
},
"data": {}
}
}
let sendSleep = {
"payload": {
"domain": "input_boolean",
"service": setSleep,
"target": {
"entity_id": ["input_boolean.master_bedroom_sleeping"]
},
"data": {}
}
}
let sendDisplay = {
"payload": {
"domain": "switch",
"service": setDisplay,
"target": {
"entity_id": ["switch.master_bedroom_aircon_display"]
},
"data": {}
}
}
let notify = {
"topic": topic,
"nighttemp": nightTemp,
"acmode": acMode,
"fanmode": fanMode
}
let sendHvac = {
"payload": {
"domain": "climate",
"service": "set_hvac_mode",
"target": {
"entity_id": ["climate.master_bedroom_aircon"]
},
"data": {
"hvac_mode": setHvac
}
}
}
let sendTemp = {
"payload": {
"domain": "climate",
"service": "set_temperature",
"target": {
"entity_id": ["climate.master_bedroom_aircon"]
},
"data": {
"temperature": setTemp
}
}
}
let sendEco = {
"payload": {
"domain": "climate",
"service": "set_preset_mode",
"target": {
"entity_id": ["climate.master_bedroom_aircon"]
},
"data": {
"preset_mode": setEco
}
}
}
let sendAcFan = {
"payload": {
"domain": "climate",
"service": "set_fan_mode",
"target": {
"entity_id": ["climate.master_bedroom_aircon"]
},
"data": {
"fan_mode": "Auto"
}
}
}
let sendEchoDotDND = {
"payload": {
"domain": "switch",
"service": echoDotService,
"target": {
"entity_id": ["switch.basement_echo_dot_do_not_disturb_switch"]
},
"data": {}
}
}
node.log("Master Bedroom Climate: Message Payloads Defined")
// Log the parameters that were chosen, for debugging purposes
node.log("----- Master Bedroom Climate: Set Parameters -----")
node.log("setTemp: " + setTemp)
node.log("setEco: " + setEco)
node.log("setHvac: " + setHvac)
node.log("setFan: " + setFan)
node.log("setCool: " + setCool)
node.log("setSleep: " + setSleep)
node.log("setDisplay " + setDisplay)
node.log("time: " + time)
node.log("type: " + type)
node.log("topic: " + topic)
node.log("----- Master Bedroom Climate: End Parameters -----")
// If this was an automated trigger, set the cooling context for the bedroom accordingly.
if (type === 'auto' && time != 'bedtime') {
node.send([null, null, sendCool, null])
node.log("Master Bedroom Climate: Cooling Context Set")
}
// Automated responses
if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'off') {
node.log("Master Bedroom Climate: Auto")
if (sleeping === 'on' && topic != 'mrbedroom-wakeup') {
node.status({ fill: "red", shape: "ring", text: "Blocked (sleep mode)" })
node.log("Master Bedroom Climate: Blocked (sleep mode)")
} else {
if (topic === 'mrbedroom-cooling' && ac === 'on') {
node.status({ fill: "green", shape: "dot", text: "Cooling Schedule" })
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null])
node.log("Master Bedroom Climate: Auto/Cooling")
} else if (topic === 'mrbedroom-bedtime') {
node.status({ fill: "green", shape: "dot", text: "Bedtime" })
node.log("Master Bedroom Climate: Auto/Bedtime")
if (ac === 'on') {
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Auto/Bedtime/AC")
}
if (fanMode === 'fan') {
node.send([null, sendFan, null, null])
node.log("Master Bedroom Climate: Auto/Bedtime/Fan")
}
} else if (topic === 'mrbedroom-fan' && fanMode === 'Fan') {
node.status({ fill: "green", shape: "dot", text: "Fan Schedule" })
node.send([null, sendFan, null, null])
node.log("Master Bedroom Climate: Auto/Fan")
} else if (topic === 'mrbedroom-wakeup') {
node.status({ fill: "green", shape: "dot", text: "Wakeup Schedule" })
node.log("Master Bedroom Climate: Auto/Wakeup")
if (sleeping === 'off') {
node.send([null, sendFan, null, null])
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep Off")
if (ac === 'on') {
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Auto/Wakeup/AC On")
}
} else if (sleeping === 'on') {
node.send([null, null, sendSleep, null])
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep On")
}
}
}
// Manual Responses
} else if (type === 'manual') {
node.log("Master Bedroom Climate: Manual")
if (time === 'night') {
node.status({ fill: "blue", shape: "dot", text: "Manual Night" })
node.send([null, sendFan, null, null])
node.log("Master Bedroom Climate: Manual/Night")
if (ac === 'on') {
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Manual/Night/AC")
}
} else if (time === 'day') {
node.status({ fill: "blue", shape: "dot", text: "Manual Day" })
node.send([null, sendFan, null, null])
node.log("Master Bedroom Climate: Manual/Day")
if (ac === 'on') {
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Manual/Day/AC")
}
} else if (time === 'bedtime') {
node.status({ fill: "blue", shape: "dot", text: "Manual Bedtime" })
node.send([null, sendFan, null, null])
node.log("Master Bedroom Climate: Manual/Bedtime")
if (ac === 'on') {
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Manual/Bedtime/AC")
}
}
} else if (type === 'sleep') {
node.log("Master Bedroom Climate: Sleep")
if (time === 'night') {
node.status({ fill: "blue", shape: "dot", text: "Wakeup (Hot Day)" })
node.send([null, sendFan, sendEchoDotDND, null])
node.log("Master Bedroom Climate: Sleep/Night")
if (ac === 'on') {
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Sleep/Night/AC")
}
} else if (time === 'day') {
node.status({ fill: "blue", shape: "dot", text: "Wakeup" })
node.send([null, sendFan, sendEchoDotDND, null])
node.log("Master Bedroom Climate: Sleep/Day")
if (ac === 'on') {
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Sleep/Day/AC")
}
} else if (time === 'bedtime') {
node.status({ fill: "blue", shape: "dot", text: "Sleep" })
node.send([null, sendFan, sendEchoDotDND, null])
node.log("Master Bedroom Climate: Sleep/Bedtime")
if (ac === 'on') {
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Sleep/Bedtime/AC")
}
}
} else if (meltdown === 'on') {
node.status({ fill: "red", shape: "ring", text: "Blocked (Meltdown Protocol)" })
node.log("Master Bedroom Climate: Blocked (Meltdown Protocol)")
} else if (vacation === 'on') {
node.status({ fill: "red", shape: "ring", text: "Blocked (Vacation Mode)" })
node.log("Master Bedroom Climate: Blocked (Vacation Mode)")
} else {
node.status({ fill: "red", shape: "ring", text: "Blocked (Automation Disabled)" })
node.log("Master Bedroom Climate: Blocked (Automation Disabled)")
}
node.log("Master Bedroom Climate: Processing Complete")

View File

@ -0,0 +1,30 @@
const lastMode = flow.get('lastMode', "diskCon")
const linkSource = msg._linkSource
let setTime = []
let setType = []
let setTopic = []
if (lastMode === 'day') {
setTime = 'day'
setType = 'manual'
setTopic = 'manual-day'
} else if (lastMode === 'night') {
setTime = 'night'
setType = 'manual'
setTopic = 'manual-night'
} else if (lastMode === 'bedtime') {
setTime = 'bedtime'
setType = 'manual'
setTopic = 'manual-bedtime'
}
let reset = {
"type": setType,
"time": setTime,
"topic": setTopic,
"_linkSource": linkSource
}
node.send(reset)
node.status({ fill: "green", shape: "dot", text: "Mode reset to " + setTopic})

View File

@ -0,0 +1,20 @@
const states = global.get("homeassistant.homeAssistant.states")
const sleeping = states["input_boolean.master_bedroom_sleeping"].state
const earlyNight = 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 coolingActive = states['input_boolean.master_bedroom_cooling_on'].state
let lastMode = []
if (sleeping === 'on' || nightMode === 'on' || goodnight === 'on') {
lastMode = 'bedtime'
} else if (earlyNight === 'on' || giveMeDarkness === 'on' || coolingActive === 'on') {
lastMode = 'night'
} else {
lastMode = 'day'
}
flow.set("lastMode", lastMode, "diskCon")
node.status({ fill: "green", shape: "dot", text: "Last Mode Set: " + lastMode})