Compare commits
3 Commits
mb_climate
...
2025.11.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
5440325aaf
|
|||
|
4aa305c9d2
|
|||
|
f63baaef48
|
14
climate/emma-bedroom/outdoor-threshold.js
Normal file
14
climate/emma-bedroom/outdoor-threshold.js
Normal 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
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const earlyNight = states['binary_sensor.early_night_mode'].state
|
||||
const payload = msg.payload
|
||||
|
||||
if (payload === 'off') {
|
||||
if (earlyNight === 'on') {
|
||||
msg.mode = 'Night Mode'
|
||||
} else {
|
||||
msg.mode = 'Day Mode'
|
||||
}
|
||||
} else if (payload === 'on') {
|
||||
msg.mode = 'Bedtime Mode'
|
||||
}
|
||||
|
||||
return msg
|
||||
14
climate/master-bedroom/outdoor-threshold.js
Normal file
14
climate/master-bedroom/outdoor-threshold.js
Normal file
@@ -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
|
||||
}
|
||||
@@ -11,6 +11,7 @@ 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
|
||||
@@ -20,8 +21,8 @@ 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'
|
||||
const currentMode = states['input_select.current_climate_mode_master_bedroom'].state
|
||||
node.log("Master Bedroom Climate: Constants Set")
|
||||
|
||||
// Define some entity IDs
|
||||
@@ -46,13 +47,14 @@ let setAcFan = 'auto'
|
||||
let setEco = 'auto'
|
||||
let setHvac = 'cool'
|
||||
let setFan = []
|
||||
let setMode = []
|
||||
let validNight = ['Night Mode','Bedtime Mode']
|
||||
let setCool = []
|
||||
let setSleep = []
|
||||
let setPeople = []
|
||||
let setDisplay = 'turn_on'
|
||||
let time = []
|
||||
let echoDotService = []
|
||||
let setBriefing = []
|
||||
let setBriefingDelay = []
|
||||
let type = msg.type
|
||||
let topic = msg.topic
|
||||
let isWakeup = context.get("isWakeup")
|
||||
@@ -63,18 +65,15 @@ if (type === 'sleep' && payload === 'off') {
|
||||
setDisplay = 'turn_on'
|
||||
echoDotService = 'turn_off'
|
||||
setPeople = 'turn_on'
|
||||
if (validNight.includes(currentMode)) {
|
||||
if (coolingActive === 'on') {
|
||||
time = 'night'
|
||||
setMode = 'Night Mode'
|
||||
} else {
|
||||
time = 'day'
|
||||
setMode = 'Day Mode'
|
||||
}
|
||||
} else if (type === 'sleep' && payload === 'on') {
|
||||
setDisplay = 'turn_off'
|
||||
echoDotService = 'turn_on'
|
||||
time = 'bedtime'
|
||||
setMode = 'Bedtime Mode'
|
||||
} else {
|
||||
time = msg.time
|
||||
}
|
||||
@@ -83,9 +82,20 @@ if (topic === 'mrbedroom-wakeup') {
|
||||
setSleep = 'turn_off'
|
||||
}
|
||||
|
||||
// Setup TTS briefing
|
||||
if (topic === 'mrbedroom-wakeup') {
|
||||
setBriefing = "master_bedroom_wakeup_briefing"
|
||||
setBriefingDelay = 60000
|
||||
} else if (type === 'sleep' && payload === 'off') {
|
||||
setBriefing = "master_bedroom_wakeup_briefing"
|
||||
setBriefingDelay = 15000
|
||||
}
|
||||
|
||||
// Day Time
|
||||
if (time === 'day') {
|
||||
setMode = 'Day Mode'
|
||||
if (type === 'auto') {
|
||||
setCool = 'turn_off'
|
||||
}
|
||||
if (earlyNight === 'off') {
|
||||
setFan = "turn_off"
|
||||
if (ac === 'on') {
|
||||
@@ -131,7 +141,10 @@ if (time === 'day') {
|
||||
}
|
||||
// Night Time
|
||||
} else if (time === 'night') {
|
||||
setMode = 'Night Mode'
|
||||
// If this is being run at scheduled time, turn on input_boolean.master_bedroom_cooling_on
|
||||
if (type === 'auto') {
|
||||
setCool = 'turn_on'
|
||||
}
|
||||
// Decide temperature
|
||||
if (type === 'sleep' && payload === 'off') {
|
||||
setTemp = dayTemp
|
||||
@@ -162,7 +175,6 @@ if (time === 'day') {
|
||||
}
|
||||
// Bed Time
|
||||
} else if (time === 'bedtime') {
|
||||
setMode = 'Bedtime Mode'
|
||||
setPeople = 'turn_off'
|
||||
if (ac === 'on') {
|
||||
setTemp = bedTemp
|
||||
@@ -197,15 +209,13 @@ let sendFan = {
|
||||
}
|
||||
}
|
||||
|
||||
let sendMode = {
|
||||
let sendCool = {
|
||||
"payload": {
|
||||
"action": "input_select.select_option",
|
||||
"action": `input_boolean.${setCool}`,
|
||||
"target": {
|
||||
"entity_id": ["input_select.current_climate_mode_master_bedroom"]
|
||||
"entity_id": ["input_boolean.master_bedroom_cooling_on"]
|
||||
},
|
||||
"data": {
|
||||
"option": setMode
|
||||
}
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,6 +256,13 @@ let notify = {
|
||||
"fanmode": fanMode
|
||||
}
|
||||
|
||||
let sendBriefing = {
|
||||
"payload": {
|
||||
"action": `script.${setBriefing}`,
|
||||
},
|
||||
"delay": setBriefingDelay
|
||||
}
|
||||
|
||||
let sendHvac = {
|
||||
"payload": {
|
||||
"action": "climate.set_hvac_mode",
|
||||
@@ -312,10 +329,12 @@ node.log(`setAcFan: ${setAcFan}`)
|
||||
node.log(`setEco: ${setEco}`)
|
||||
node.log(`setHvac: ${setHvac}`)
|
||||
node.log(`setFan: ${setFan}`)
|
||||
node.log(`setMode: ${setMode}`)
|
||||
node.log(`setCool: ${setCool}`)
|
||||
node.log(`setSleep: ${setSleep}`)
|
||||
node.log(`setPeople: ${setPeople}`)
|
||||
node.log(`setDisplay: ${setDisplay}`)
|
||||
node.log(`setBriefing: ${setBriefing}`)
|
||||
node.log(`setBriefingDelay: ${setBriefingDelay}`)
|
||||
node.log(`time: ${time}`)
|
||||
node.log(`type: ${type}`)
|
||||
node.log(`topic: ${topic}`)
|
||||
@@ -323,13 +342,13 @@ node.log("----- Master Bedroom Climate: End Parameters -----")
|
||||
|
||||
// If this was an automated trigger, set the cooling context for the bedroom accordingly.
|
||||
|
||||
if (type === 'auto') {
|
||||
node.send([null, null, sendMode, null])
|
||||
node.log("Master Bedroom Climate: Cooling Mode Context Set")
|
||||
if (type === 'auto' && time != 'bedtime') {
|
||||
node.send([null, null, sendCool, null, null])
|
||||
node.log("Master Bedroom Climate: Cooling Context Set")
|
||||
}
|
||||
|
||||
// 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)" })
|
||||
@@ -340,35 +359,36 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||
node.log("Master Bedroom Climate: Auto/Cooling")
|
||||
} else if (topic === 'mrbedroom-bedtime') {
|
||||
node.send([null, null, sendPeople, null])
|
||||
node.send([null, null, sendPeople, null, null])
|
||||
node.status({ fill: "green", shape: "dot", text: "Bedtime" })
|
||||
node.log("Master Bedroom Climate: Auto/Bedtime")
|
||||
if (ac === 'on') {
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null, null])
|
||||
node.log("Master Bedroom Climate: Auto/Bedtime/AC")
|
||||
}
|
||||
if (fanMode === 'fan') {
|
||||
node.send([null, sendFan, null, null])
|
||||
node.send([null, sendFan, null, 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.send([null, sendFan, null, null, null])
|
||||
node.log("Master Bedroom Climate: Auto/Fan")
|
||||
} else if (topic === 'mrbedroom-wakeup') {
|
||||
node.send([null, null, null, null, sendBriefing])
|
||||
node.status({ fill: "green", shape: "dot", text: "Wakeup Schedule" })
|
||||
node.log("Master Bedroom Climate: Auto/Wakeup")
|
||||
if (sleeping === 'off') {
|
||||
context.set("isWakeup", false)
|
||||
node.send([null, sendFan, null, null])
|
||||
node.send([null, sendFan, null, null, null])
|
||||
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep Off")
|
||||
if (ac === 'on') {
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null, null])
|
||||
node.log("Master Bedroom Climate: Auto/Wakeup/AC On")
|
||||
}
|
||||
} else if (sleeping === 'on') {
|
||||
context.set("isWakeup", true)
|
||||
node.send([null, null, sendSleep, null])
|
||||
node.send([null, null, sendSleep, null, null])
|
||||
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep On")
|
||||
}
|
||||
}
|
||||
@@ -378,26 +398,26 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
||||
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.send([null, sendFan, null, null, null])
|
||||
node.log("Master Bedroom Climate: Manual/Night")
|
||||
if (ac === 'on') {
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, 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.send([null, sendFan, null, null, null])
|
||||
node.log("Master Bedroom Climate: Manual/Day")
|
||||
if (ac === 'on') {
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, 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.send([null, sendFan, null, null, null])
|
||||
node.log("Master Bedroom Climate: Manual/Bedtime")
|
||||
if (ac === 'on') {
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null, null])
|
||||
node.log("Master Bedroom Climate: Manual/Bedtime/AC")
|
||||
}
|
||||
}
|
||||
@@ -405,25 +425,28 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
||||
// Sleep Switch Responses
|
||||
} else if (type === 'sleep') {
|
||||
if (payload === 'off') {
|
||||
node.send([null, null, sendPeople, null])
|
||||
node.send([null, null, sendPeople, null, null])
|
||||
}
|
||||
node.log("Master Bedroom Climate: Sleep")
|
||||
if (time === 'bedtime') {
|
||||
node.status({ fill: "blue", shape: "dot", text: "Sleep" })
|
||||
node.send([null, sendFan, [sendEchoDotDND,sendPeople], null])
|
||||
node.send([null, sendFan, [sendEchoDotDND,sendPeople], null, null])
|
||||
node.log("Master Bedroom Climate: Sleep/Bedtime")
|
||||
if (ac === 'on') {
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null, null])
|
||||
node.log("Master Bedroom Climate: Sleep/Bedtime/AC")
|
||||
}
|
||||
} else {
|
||||
node.status({ fill: "blue", shape: "dot", text: "Wakeup" })
|
||||
node.send([null, sendFan, sendEchoDotDND, null])
|
||||
node.send([null, sendFan, sendEchoDotDND, null, null])
|
||||
node.log("Master Bedroom Climate: Sleep/Day")
|
||||
if (ac === 'on') {
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null, null])
|
||||
node.log(`Master Bedroom Climate: Sleep/${convertToTitleCase(time)}/AC`)
|
||||
}
|
||||
if (time === 'day' && isWakeup === false) {
|
||||
node.send([null, null, null, null, sendBriefing])
|
||||
}
|
||||
}
|
||||
context.set("isWakeup", false)
|
||||
} else if (meltdown === 'on') {
|
||||
|
||||
@@ -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 -----")
|
||||
Reference in New Issue
Block a user