Compare commits

..

8 Commits

12 changed files with 139 additions and 49 deletions
+10 -2
View File
@@ -3,13 +3,21 @@ const toggle = msg.payload
const ac = global.get('emmaBedroom.aircon.installed', "diskCon")
const lastMode = flow.get("emmaBedroom.lastMode", "diskCon")
const bedTemp = states['input_number.emma_bedroom_bedtime_temp'].state
const ecoHold = states['switch.emma_bedroom_aircon_eco_hold'].state
const fanMode = states['input_select.emma_bedroom_aircon_fan_mode'].state
const airconEntity = ["climate.emma_bedroom_aircon"]
let setTemp = bedTemp
let setEco = 'turn_off'
let setEco = 'turn_on'
let setHvac = 'cool'
let setAcFan = 'High'
let setAcFan = fanMode
if (ecoHold === 'on') {
setEco = 'turn_on'
} else {
setEco = 'turn_off'
}
let sendHvac = {
"payload": {
+1 -1
View File
@@ -11,7 +11,7 @@ let fanOnlyMsg = {
"topic": "Emma AC Mode: Fan Only"
}
if (topic === 'emmabedroom-cooling') {
if (topic === 'emmabedroom-climate') {
if (acMode === 'AC') {
node.status({fill:"green",shape:"dot",text:"AC Cooling"})
return coolMsg
+14
View File
@@ -0,0 +1,14 @@
const outdoor = global.get("outdoorTemp.tempInt")
const thresholdEntity = global.get("homeassistant.homeAssistant.states['input_number.emma_bedroom_aircon_mode_threshold'].state")
const threshold = parseInt(thresholdEntity)
msg.outdoor = outdoor
msg.modeThreshold = threshold
if (outdoor >= threshold) {
node.status({fill:"green",shape:"dot",text:`${outdoor} >= ${threshold}`})
return msg
} else {
node.status({fill:"red",shape:"ring",text:`${outdoor} < ${threshold}`})
return null
}
+17 -11
View File
@@ -18,6 +18,8 @@ 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.emma_bedroom_cooling_on'].state
const ecoHold = states['input_boolean.emma_bedroom_aircon_eco_hold'].state
const fanModeAircon = states['input_select.emma_bedroom_aircon_fan_mode'].state
node.log("Emma Bedroom Climate: Constants Set")
// Define reusable constants
@@ -39,7 +41,7 @@ function convertToTitleCase(str) {
// init variables
let setTemp = dayTemp
let setAcFan = 'auto'
let setAcFan = fanModeAircon
let setEco = 'turn_on'
let setHvac = 'cool'
let setCool = []
@@ -97,7 +99,7 @@ if (time === 'day') {
} else if (earlyNight === 'on') {
if (ac === 'on') {
if (danger === 'Extreme') {
setTemp === bedTemp
setTemp = bedTemp
} else {
setTemp = nightTemp
}
@@ -108,11 +110,7 @@ if (time === 'day') {
} else {
setHvac = 'off'
}
if (hotDay === 'on') {
setEco = 'turn_off'
} else {
setEco = 'turn_on'
}
setEco = 'turn_on'
}
}
// Night Time
@@ -131,7 +129,11 @@ if (time === 'day') {
}
// Decide eco mode
if (sleeping === 'on') {
setEco = 'turn_off'
if (ecoHold === 'on') {
setEco = 'turn_on'
} else {
setEco = 'turn_off'
}
} else {
setEco = 'turn_on'
}
@@ -148,7 +150,11 @@ if (time === 'day') {
setPeople = 'turn_off'
if (ac === 'on') {
setTemp = bedTemp
setEco = 'turn_off'
if (ecoHold === 'on') {
setEco = 'turn_on'
} else {
setEco = 'turn_off'
}
if (schedMode === 'AC') {
setHvac = 'cool'
setDisplay = 'turn_off'
@@ -291,7 +297,7 @@ if (setDisplay.length > 0) {
flow.set('emmaBedroom.airconDisplay',setDisplay,'diskCon')
}
flow.set('emmaBedroom.airconFanMode',setAcFan,'diskCon')
flow.set('emmaBedroom.airconfanModeAircon',setAcFan,'diskCon')
// Log the parameters that were chosen, for debugging purposes
@@ -322,7 +328,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
node.status({ fill: "red", shape: "ring", text: "Blocked (sleep mode)" })
node.log("Emma Bedroom Climate: Blocked (sleep mode)")
} else {
if (topic === 'emmabedroom-cooling' && ac === 'on') {
if (topic === 'emmabedroom-climate' && ac === 'on') {
node.status({ fill: "green", shape: "dot", text: "Cooling Schedule" })
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
node.log("Emma Bedroom Climate: Auto/Cooling")
+19 -4
View File
@@ -1,15 +1,30 @@
const states = global.get('homeassistant.homeAssistant.states')
const sleeping = states['input_boolean.emma_sleeping'].state
if (sleeping !== 'on') {
// Check if all settings support aircon usage
const ac = global.get('emmaBedroom.aircon.installed', "diskCon")
const allowed = states['input_boolean.emma_bedroom_climate_protocol'].state
const schedMode = states['input_select.scheduled_climate_mode_emma_bedroom'].state
const coolingActive = states["input_boolean.emma_bedroom_cooling_on"].state
const sleeping = states["input_boolean.emma_sleeping"].state
let proceed = false
if (ac === 'on' && allowed === 'on' && schedMode === 'AC' && coolingActive === 'on') {
proceed = true
}
if (sleeping != 'on') {
node.status({fill:'red',shape:'ring',text:'Emma not sleeping, watchdog disabled'})
return null
} else if (proceed === false) {
node.status({fill:'red',shape:'ring',text:'Aircon not in use, watchdog disabled'})
return null
}
const airconEntity = ['climate.emma_bedroom_aircon']
// Gather relevant attributes from the aircon entity
const airconEntity = ['climate.emma_bedroom_aircon']
const airconState = msg.payload.state
const airconAttributes = msg.payload.attributes
const airconEco = airconAttributes['eco_mode']
+10 -2
View File
@@ -3,16 +3,24 @@ const toggle = msg.payload
const ac = global.get('masterBedroom.aircon.installed', "diskCon")
const lastMode = flow.get("masterBedroom.lastMode", "diskCon")
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
const ecoHold = states['switch.master_bedroom_aircon_eco_hold'].state
const fanMode = states['input_select.master_bedroom_aircon_fan_mode'].state
const airconEntity = ["climate.master_bedroom_aircon"]
const fanEntity = ["fan.master_bedroom_fan"]
let setTemp = bedTemp
let setEco = 'turn_off'
let setEco = 'turn_on'
let setHvac = 'cool'
let setAcFan = 'High'
let setAcFan = fanMode
let setFan = 'turn_off'
if (ecoHold === 'on') {
setEco = 'turn_on'
} else {
setEco = 'turn_off'
}
let sendFan = {
"payload": {
"action": `fan.${setFan}`,
@@ -0,0 +1,14 @@
const outdoor = global.get("outdoorTemp.tempInt")
const thresholdEntity = global.get("homeassistant.homeAssistant.states['input_number.master_bedroom_aircon_mode_threshold'].state")
const threshold = parseInt(thresholdEntity)
msg.outdoor = outdoor
msg.modeThreshold = threshold
if (outdoor >= threshold) {
node.status({fill:"green",shape:"dot",text:`${outdoor} >= ${threshold}`})
return msg
} else {
node.status({fill:"red",shape:"ring",text:`${outdoor} < ${threshold}`})
return null
}
+7 -5
View File
@@ -4,12 +4,14 @@ const states = global.get('homeassistant.homeAssistant.states')
const dayTemp = parseInt(states['input_number.master_bedroom_daytime_temp'].state)
const nightTemp = parseInt(states['input_number.master_bedroom_night_temp'].state)
const bedTemp = parseInt(states['input_number.master_bedroom_bedtime_temp'].state)
const ecoHold = states['switch.master_bedroom_aircon_eco_hold'].state
const fanModeAircon = states['input_select.master_bedroom_aircon_fan_mode'].state
let dayMode = {
"power": "turn_on",
"temp": dayTemp,
"hvac": "cool",
"fan": "auto",
"fan": fanModeAircon,
"eco": "turn_on"
}
@@ -17,16 +19,16 @@ let nightMode = {
"power": "turn_on",
"temp": nightTemp,
"hvac": "cool",
"fan": "auto",
"eco": "turn_on"
"fan": fanModeAircon,
"eco": ecoHold === "on" ? "turn_on" : "turn_off"
}
let bedMode = {
"power": "turn_on",
"temp": bedTemp,
"hvac": "cool",
"fan": "auto",
"eco": "turn_off"
"fan": fanModeAircon,
"eco": ecoHold === "on" ? "turn_on" : "turn_off"
}
let showerMode = {
+17 -11
View File
@@ -23,6 +23,8 @@ 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'
const ecoHold = states['switch.master_bedroom_aircon_eco_hold'].state
const fanModeAircon = states['input_select.master_bedroom_aircon_fan_mode'].state
node.log("Master Bedroom Climate: Constants Set")
// Define some entity IDs
@@ -43,8 +45,8 @@ function convertToTitleCase(str) {
// init variables
let setTemp = dayTemp
let setAcFan = 'auto'
let setEco = 'auto'
let setAcFan = fanModeAircon
let setEco = 'turn_on'
let setHvac = 'cool'
let setFan = []
let setCool = []
@@ -116,7 +118,7 @@ if (time === 'day') {
} else if (earlyNight === 'on') {
if (ac === 'on') {
if (danger === 'Extreme') {
setTemp === bedTemp
setTemp = bedTemp
} else {
setTemp = nightTemp
}
@@ -132,11 +134,7 @@ if (time === 'day') {
} else {
setHvac = 'off'
}
if (hotDay === 'on') {
setEco = 'turn_off'
} else {
setEco = 'turn_on'
}
setEco = 'turn_on'
}
}
// Night Time
@@ -155,7 +153,11 @@ if (time === 'day') {
}
// Decide eco mode
if (sleeping === 'on') {
setEco = 'turn_off'
if (ecoHold === 'on') {
setEco = 'turn_on'
} else {
setEco = 'turn_off'
}
} else {
setEco = 'turn_on'
}
@@ -178,7 +180,11 @@ if (time === 'day') {
setPeople = 'turn_off'
if (ac === 'on') {
setTemp = bedTemp
setEco = 'turn_off'
if (ecoHold === 'on') {
setEco = 'turn_on'
} else {
setEco = 'turn_off'
}
if (acMode === 'AC') {
setHvac = 'cool'
setDisplay = 'turn_off'
@@ -348,7 +354,7 @@ if (type === 'auto' && time != 'bedtime') {
}
// Automated responses
if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'off') {
if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'off') { //! allowed === 'off' currently because of upstairs heat issues. Need to figure out a way to still allow wakeup flow to run.
node.log("Master Bedroom Climate: Auto")
if (sleeping === 'on' && topic != 'mrbedroom-wakeup') {
node.status({ fill: "red", shape: "ring", text: "Blocked (sleep mode)" })
+14 -4
View File
@@ -9,12 +9,14 @@ const currentSetTemp = states['climate.master_bedroom_aircon'].attributes.temper
const coolingTime = states['input_boolean.master_bedroom_cooling_on'].state
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
const hotDay = states['input_boolean.hot_day'].state
const ecoHold = states['switch.master_bedroom_aircon_eco_hold'].state
const fanModeAircon = states['input_select.master_bedroom_aircon_fan_mode'].state
const topic = msg.topic
const airconEntity = ["climate.master_bedroom_aircon"]
let setTemp = {}
let setEco = {}
let setEco = 'turn_on'
let duration = {}
let end = {}
let setHvac = {}
@@ -22,7 +24,11 @@ let setHvac = {}
if (topic === 'toggle') {
if (hotDay === 'on' || sleeping === 'on') {
setTemp = bedTemp
setEco = 'turn_off'
if (ecoHold === 'on') {
setEco = 'turn_on'
} else {
setEco = 'turn_off'
}
} else {
setTemp = nightTemp
setEco = 'turn_on'
@@ -31,7 +37,11 @@ if (topic === 'toggle') {
if (currentSetTemp == bedTemp) {
setTemp = nightTemp
if (hotDay === 'on') {
setEco = 'turn_off'
if (ecoHold === 'on') {
setEco = 'turn_on'
} else {
setEco = 'turn_off'
}
} else {
setEco = 'turn_on'
}
@@ -109,7 +119,7 @@ let sendAcFan = {
"entity_id": airconEntity
},
"data": {
"fan_mode": "auto"
"fan_mode": fanModeAircon
}
}
}
@@ -5,7 +5,8 @@ const lux = parseInt(states['sensor.master_bedroom_illuminance'].state)
const threshold = parseInt(states['input_number.master_bedroom_lux_threshold'].state)
const masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state
const kallenBedroomSleep = states['input_boolean.kallen_sleeping'].state
const peopleSleeping = (masterBedroomSleep === 'on' || kallenBedroomSleep === 'on')
const emmaBedroomSleep = states['input_boolean.emma_sleeping'].state
const peopleSleeping = (masterBedroomSleep === 'on' || kallenBedroomSleep === 'on' || emmaBedroomSleep === 'on')
const nightMode = states['input_boolean.night_mode'].state
const payload = msg.payload
const newDuration = duration * 60
@@ -2,11 +2,17 @@ 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 emmaBedroomSleep = states['input_boolean.emma_sleeping'].state
const payload = msg.payload
const newDuration = duration * 60
let threshold = parseInt(states['input_number.upstairs_bathroom_lux_threshold'].state)
if (emmaBedroomSleep === 'on') {
threshold = 10
}
let timerCancel = {
"payload": "stop"
}
@@ -32,11 +38,11 @@ if (showerMode === '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 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 -----")