Compare commits
28 Commits
2025.4.1
...
mb_climate
Author | SHA1 | Date | |
---|---|---|---|
b69aed0029
|
|||
cdf20900c9
|
|||
abc0004623
|
|||
305d145e59
|
|||
19206710fa
|
|||
ba7af1addf
|
|||
054b498f51
|
|||
c99f125289
|
|||
9f415eb232
|
|||
3a97da1b6d
|
|||
d764f99977
|
|||
0980c3b1ec
|
|||
86730c48ef
|
|||
4029a7992f
|
|||
d4bf2e3f23
|
|||
5d8f69e4f4
|
|||
0b64c61cd1
|
|||
b6c0ac0713
|
|||
bff29b48e9
|
|||
bc1ed66b56
|
|||
fefc52bd01
|
|||
b626b5b5e8
|
|||
408b85bf6a
|
|||
ba56bd08f4
|
|||
b0870578ef
|
|||
da63c34b3d
|
|||
ae17ad6969
|
|||
7a957572c8
|
@ -4,8 +4,10 @@ const ac = global.get('emmaBedroom.aircon.installed', "diskCon")
|
|||||||
const lastMode = flow.get("emmaBedroom.lastMode", "diskCon")
|
const lastMode = flow.get("emmaBedroom.lastMode", "diskCon")
|
||||||
const bedTemp = states['input_number.emma_bedroom_bedtime_temp'].state
|
const bedTemp = states['input_number.emma_bedroom_bedtime_temp'].state
|
||||||
|
|
||||||
|
const airconEntity = ["climate.emma_bedroom_aircon"]
|
||||||
|
|
||||||
let setTemp = bedTemp
|
let setTemp = bedTemp
|
||||||
let setEco = 'none'
|
let setEco = 'turn_off'
|
||||||
let setHvac = 'cool'
|
let setHvac = 'cool'
|
||||||
let setAcFan = 'High'
|
let setAcFan = 'High'
|
||||||
|
|
||||||
@ -13,7 +15,7 @@ let sendHvac = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_hvac_mode",
|
"action": "climate.set_hvac_mode",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["climate.emma_bedroom_aircon"]
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"hvac_mode": setHvac
|
"hvac_mode": setHvac
|
||||||
@ -25,7 +27,7 @@ let sendTemp = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_temperature",
|
"action": "climate.set_temperature",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["climate.emma_bedroom_aircon"]
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"temperature": setTemp
|
"temperature": setTemp
|
||||||
@ -35,13 +37,11 @@ let sendTemp = {
|
|||||||
|
|
||||||
let sendEco = {
|
let sendEco = {
|
||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_preset_mode",
|
"action": `switch.${setEco}`,
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["climate.emma_bedroom_aircon"]
|
"entity_id": ["switch.emma_bedroom_aircon_eco_mode"]
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {}
|
||||||
"preset_mode": setEco
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ let sendAcFan = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_fan_mode",
|
"action": "climate.set_fan_mode",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["climate.emma_bedroom_aircon"]
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"fan_mode": setAcFan
|
"fan_mode": setAcFan
|
||||||
@ -64,7 +64,7 @@ let reset = {
|
|||||||
if (toggle === 'on') {
|
if (toggle === 'on') {
|
||||||
node.status({fill:"red",shape:"dot",text:"DANGER MODE ACTIVE"})
|
node.status({fill:"red",shape:"dot",text:"DANGER MODE ACTIVE"})
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac,sendTemp,sendEco,sendTemp],null])
|
node.send([[sendHvac,sendTemp,sendAcFan,sendEco],null])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"green",shape:"dot",text:"Danger Mode Off"})
|
node.status({fill:"green",shape:"dot",text:"Danger Mode Off"})
|
||||||
|
@ -22,9 +22,10 @@ node.log("Emma Bedroom Climate: Constants Set")
|
|||||||
|
|
||||||
// Define reusable constants
|
// Define reusable constants
|
||||||
|
|
||||||
const emmaBedroomAircon = "climate.emma_bedroom_aircon"
|
const airconEntity = ["climate.emma_bedroom_aircon"]
|
||||||
const emmaBedroomWhiteNoise = "input_boolean.white_noise_emma_bedroom"
|
const whiteNoiseEntity = ["input_boolean.white_noise_emma_bedroom"]
|
||||||
const validSchedModesAC = ['AC', 'Fan']
|
const validSchedModesAC = ['AC', 'Fan']
|
||||||
|
const peopleIDs = ["input_boolean.emma_awake"]
|
||||||
|
|
||||||
// Helper function to convert a string to title case
|
// Helper function to convert a string to title case
|
||||||
|
|
||||||
@ -37,13 +38,14 @@ function convertToTitleCase(str) {
|
|||||||
|
|
||||||
// init variables
|
// init variables
|
||||||
|
|
||||||
let setTemp = []
|
let setTemp = dayTemp
|
||||||
let setEco = []
|
let setAcFan = 'auto'
|
||||||
let setHvac = []
|
let setEco = 'turn_on'
|
||||||
|
let setHvac = 'cool'
|
||||||
let setCool = []
|
let setCool = []
|
||||||
let setSleep = []
|
let setSleep = []
|
||||||
let setPeople = []
|
let setPeople = []
|
||||||
let setDisplay = []
|
let setDisplay = 'turn_on'
|
||||||
let setWhiteNoise = "turn_off"
|
let setWhiteNoise = "turn_off"
|
||||||
let time = []
|
let time = []
|
||||||
let type = msg.type
|
let type = msg.type
|
||||||
@ -80,15 +82,15 @@ if (time === 'day') {
|
|||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
if (danger === 'Extreme') {
|
if (danger === 'Extreme') {
|
||||||
setTemp = nightTemp
|
setTemp = nightTemp
|
||||||
setEco = "eco"
|
setEco = "turn_on"
|
||||||
setHvac = "cool"
|
setHvac = "cool"
|
||||||
} else if (hotDay === 'on' || heatWarning === 'on') {
|
} else if (hotDay === 'on' || heatWarning === 'on') {
|
||||||
setTemp = dayTemp
|
setTemp = dayTemp
|
||||||
setEco = "eco"
|
setEco = "turn_on"
|
||||||
setHvac = "cool"
|
setHvac = "cool"
|
||||||
} else {
|
} else {
|
||||||
setTemp = nightTemp
|
setTemp = nightTemp
|
||||||
setEco = "eco"
|
setEco = "turn_on"
|
||||||
setHvac = "off"
|
setHvac = "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,9 +109,9 @@ if (time === 'day') {
|
|||||||
setHvac = 'off'
|
setHvac = 'off'
|
||||||
}
|
}
|
||||||
if (hotDay === 'on') {
|
if (hotDay === 'on') {
|
||||||
setEco = 'none'
|
setEco = 'turn_off'
|
||||||
} else {
|
} else {
|
||||||
setEco = 'eco'
|
setEco = 'turn_on'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,9 +131,9 @@ if (time === 'day') {
|
|||||||
}
|
}
|
||||||
// Decide eco mode
|
// Decide eco mode
|
||||||
if (sleeping === 'on') {
|
if (sleeping === 'on') {
|
||||||
setEco = 'none'
|
setEco = 'turn_off'
|
||||||
} else {
|
} else {
|
||||||
setEco = 'eco'
|
setEco = 'turn_on'
|
||||||
}
|
}
|
||||||
// Decide HVAC mode
|
// Decide HVAC mode
|
||||||
if (schedMode === 'AC') {
|
if (schedMode === 'AC') {
|
||||||
@ -146,11 +148,13 @@ if (time === 'day') {
|
|||||||
setPeople = 'turn_off'
|
setPeople = 'turn_off'
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
setTemp = bedTemp
|
setTemp = bedTemp
|
||||||
setEco = 'none'
|
setEco = 'turn_off'
|
||||||
if (schedMode === 'AC') {
|
if (schedMode === 'AC') {
|
||||||
setHvac = 'cool'
|
setHvac = 'cool'
|
||||||
|
setDisplay = 'turn_off'
|
||||||
} else if (schedMode === 'Fan') {
|
} else if (schedMode === 'Fan') {
|
||||||
setHvac = "fan_only"
|
setHvac = "fan_only"
|
||||||
|
setDisplay = 'turn_off'
|
||||||
} else if (schedMode === 'White Noise') {
|
} else if (schedMode === 'White Noise') {
|
||||||
setWhiteNoise = 'turn_on'
|
setWhiteNoise = 'turn_on'
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
@ -189,7 +193,7 @@ let sendPeople = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": `input_boolean.${setPeople}`,
|
"action": `input_boolean.${setPeople}`,
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["input_boolean.emma_awake"]
|
"entity_id": peopleIDs
|
||||||
},
|
},
|
||||||
"data": {}
|
"data": {}
|
||||||
}
|
}
|
||||||
@ -209,7 +213,7 @@ let sendWhiteNoise = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": `input_boolean.${setWhiteNoise}`,
|
"action": `input_boolean.${setWhiteNoise}`,
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": emmaBedroomWhiteNoise
|
"entity_id": whiteNoiseEntity
|
||||||
},
|
},
|
||||||
"data": {}
|
"data": {}
|
||||||
}
|
}
|
||||||
@ -225,7 +229,7 @@ let sendHvac = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_hvac_mode",
|
"action": "climate.set_hvac_mode",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": emmaBedroomAircon
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"hvac_mode": setHvac
|
"hvac_mode": setHvac
|
||||||
@ -237,7 +241,7 @@ let sendTemp = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_temperature",
|
"action": "climate.set_temperature",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": emmaBedroomAircon
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"temperature": setTemp
|
"temperature": setTemp
|
||||||
@ -247,13 +251,11 @@ let sendTemp = {
|
|||||||
|
|
||||||
let sendEco = {
|
let sendEco = {
|
||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_preset_mode",
|
"action": `switch.${setEco}`,
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": emmaBedroomAircon
|
"entity_id": ["switch.emma_bedroom_aircon_eco_mode"]
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {}
|
||||||
"preset_mode": setEco
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,20 +263,41 @@ let sendAcFan = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_fan_mode",
|
"action": "climate.set_fan_mode",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": emmaBedroomAircon
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"fan_mode": "auto"
|
"fan_mode": setAcFan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node.log("Emma Bedroom Climate: Message Payloads Defined")
|
node.log("Emma Bedroom Climate: Message Payloads Defined")
|
||||||
|
|
||||||
|
// Send some parameters to flow context for use in other nodes
|
||||||
|
|
||||||
|
if (setHvac.length > 0) {
|
||||||
|
flow.set('emmaBedroom.airconHvacMode',setHvac,'diskCon')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setEco.length > 0) {
|
||||||
|
flow.set('emmaBedroom.airconEco',setEco,'diskCon')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setTemp.length > 0) {
|
||||||
|
flow.set('emmaBedroom.airconTargetTemp',setTemp,'diskCon')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setDisplay.length > 0) {
|
||||||
|
flow.set('emmaBedroom.airconDisplay',setDisplay,'diskCon')
|
||||||
|
}
|
||||||
|
|
||||||
|
flow.set('emmaBedroom.airconFanMode',setAcFan,'diskCon')
|
||||||
|
|
||||||
// Log the parameters that were chosen, for debugging purposes
|
// Log the parameters that were chosen, for debugging purposes
|
||||||
|
|
||||||
node.log("----- Emma Bedroom Climate: Set Parameters -----")
|
node.log("----- Emma Bedroom Climate: Set Parameters -----")
|
||||||
node.log(`setTemp: ${setTemp}`)
|
node.log(`setTemp: ${setTemp}`)
|
||||||
|
node.log(`setAcFan: ${setAcFan}`)
|
||||||
node.log(`setEco: ${setEco}`)
|
node.log(`setEco: ${setEco}`)
|
||||||
node.log(`setHvac: ${setHvac}`)
|
node.log(`setHvac: ${setHvac}`)
|
||||||
node.log(`setCool: ${setCool}`)
|
node.log(`setCool: ${setCool}`)
|
||||||
@ -301,14 +324,14 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
} else {
|
} else {
|
||||||
if (topic === 'emmabedroom-cooling' && ac === 'on') {
|
if (topic === 'emmabedroom-cooling' && ac === 'on') {
|
||||||
node.status({ fill: "green", shape: "dot", text: "Cooling Schedule" })
|
node.status({ fill: "green", shape: "dot", text: "Cooling Schedule" })
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
|
||||||
node.log("Emma Bedroom Climate: Auto/Cooling")
|
node.log("Emma Bedroom Climate: Auto/Cooling")
|
||||||
} else if (topic === 'emmabedroom-bedtime') {
|
} else if (topic === 'emmabedroom-bedtime') {
|
||||||
node.send([null, sendPeople, null])
|
node.send([null, sendPeople, null])
|
||||||
node.status({ fill: "green", shape: "dot", text: "Bedtime" })
|
node.status({ fill: "green", shape: "dot", text: "Bedtime" })
|
||||||
node.log("Emma Bedroom Climate: Auto/Bedtime")
|
node.log("Emma Bedroom Climate: Auto/Bedtime")
|
||||||
if (validSchedModesAC.includes(schedMode) && ac === 'on') {
|
if (validSchedModesAC.includes(schedMode) && ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
|
||||||
node.log("Emma Bedroom Climate: Auto/Bedtime/AC")
|
node.log("Emma Bedroom Climate: Auto/Bedtime/AC")
|
||||||
} else if (schedMode === 'White Noise') {
|
} else if (schedMode === 'White Noise') {
|
||||||
node.send([null, sendWhiteNoise, null])
|
node.send([null, sendWhiteNoise, null])
|
||||||
@ -322,7 +345,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
node.send([null, sendWhiteNoise, null])
|
node.send([null, sendWhiteNoise, null])
|
||||||
node.log("Emma Bedroom Climate: Auto/Wakeup/Sleep Off")
|
node.log("Emma Bedroom Climate: Auto/Wakeup/Sleep Off")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
|
||||||
node.log("Emma Bedroom Climate: Auto/Wakeup/AC On")
|
node.log("Emma Bedroom Climate: Auto/Wakeup/AC On")
|
||||||
}
|
}
|
||||||
} else if (sleeping === 'on') {
|
} else if (sleeping === 'on') {
|
||||||
@ -339,7 +362,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
node.status({ fill: "blue", shape: "dot", text: "Manual Night" })
|
node.status({ fill: "blue", shape: "dot", text: "Manual Night" })
|
||||||
node.log("Emma Bedroom Climate: Manual/Night")
|
node.log("Emma Bedroom Climate: Manual/Night")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
|
||||||
node.log("Emma Bedroom Climate: Manual/Night/AC")
|
node.log("Emma Bedroom Climate: Manual/Night/AC")
|
||||||
}
|
}
|
||||||
} else if (time === 'day') {
|
} else if (time === 'day') {
|
||||||
@ -347,14 +370,14 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
node.send([null, sendWhiteNoise, null])
|
node.send([null, sendWhiteNoise, null])
|
||||||
node.log("Emma Bedroom Climate: Manual/Day")
|
node.log("Emma Bedroom Climate: Manual/Day")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
|
||||||
node.log("Emma Bedroom Climate: Manual/Day/AC")
|
node.log("Emma Bedroom Climate: Manual/Day/AC")
|
||||||
}
|
}
|
||||||
} else if (time === 'bedtime') {
|
} else if (time === 'bedtime') {
|
||||||
node.status({ fill: "blue", shape: "dot", text: "Manual Bedtime" })
|
node.status({ fill: "blue", shape: "dot", text: "Manual Bedtime" })
|
||||||
node.log("Emma Bedroom Climate: Manual/Bedtime")
|
node.log("Emma Bedroom Climate: Manual/Bedtime")
|
||||||
if (validSchedModesAC.includes(schedMode) && ac === 'on') {
|
if (validSchedModesAC.includes(schedMode) && ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
|
||||||
node.log("Emma Bedroom Climate: Manual/Bedtime/AC")
|
node.log("Emma Bedroom Climate: Manual/Bedtime/AC")
|
||||||
} else if (schedMode === 'White Noise') {
|
} else if (schedMode === 'White Noise') {
|
||||||
node.send([null, sendWhiteNoise, null])
|
node.send([null, sendWhiteNoise, null])
|
||||||
@ -373,7 +396,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
node.send([null, [sendPeople, sendWhiteNoise], null])
|
node.send([null, [sendPeople, sendWhiteNoise], null])
|
||||||
node.log("Emma Bedroom Climate: Sleep/Bedtime")
|
node.log("Emma Bedroom Climate: Sleep/Bedtime")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
|
||||||
node.log("Emma Bedroom Climate: Sleep/Bedtime/AC")
|
node.log("Emma Bedroom Climate: Sleep/Bedtime/AC")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -381,7 +404,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
node.send([null, sendWhiteNoise, null])
|
node.send([null, sendWhiteNoise, null])
|
||||||
node.log("Emma Bedroom Climate: Sleep/Day")
|
node.log("Emma Bedroom Climate: Sleep/Day")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null])
|
||||||
node.log(`Emma Bedroom Climate: Sleep/${convertToTitleCase(time)}/AC`)
|
node.log(`Emma Bedroom Climate: Sleep/${convertToTitleCase(time)}/AC`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
climate/emma-bedroom/set-temp-vars.js
Normal file
21
climate/emma-bedroom/set-temp-vars.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
const topic = msg.topic
|
||||||
|
const payload = msg.payload
|
||||||
|
const lastMode = flow.get('emmaBedroom.lastMode', 'diskCon')
|
||||||
|
|
||||||
|
if (topic === 'daytemp') {
|
||||||
|
flow.set('emmaBedroom.dayTemp', payload, 'diskCon')
|
||||||
|
} else if (topic === 'nighttemp') {
|
||||||
|
flow.set("emmaBedroom.nightTemp", payload, "diskCon")
|
||||||
|
} else if (topic === 'bedtemp') {
|
||||||
|
flow.set("emmaBedroom.bedTemp", payload, "diskCon")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastMode === 'day') {
|
||||||
|
flow.set('emmaBedroom.airconTargetTemp', flow.get('emmaBedroom.dayTemp', 'diskCon'), 'diskCon')
|
||||||
|
} else if (lastMode === 'night') {
|
||||||
|
flow.set('emmaBedroom.airconTargetTemp', flow.get('emmaBedroom.nightTemp', 'diskCon'), 'diskCon')
|
||||||
|
} else if (lastMode === 'bedtime') {
|
||||||
|
flow.set('emmaBedroom.airconTargetTemp', flow.get('emmaBedroom.bedTemp', 'diskCon'), 'diskCon')
|
||||||
|
}
|
||||||
|
|
||||||
|
node.status({fill:'green',shape:'dot',text:`Set ${topic} to ${payload}`})
|
151
climate/emma-bedroom/watchdog.js
Normal file
151
climate/emma-bedroom/watchdog.js
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
const states = global.get('homeassistant.homeAssistant.states')
|
||||||
|
const sleeping = states['input_boolean.emma_sleeping'].state
|
||||||
|
|
||||||
|
if (sleeping !== 'on') {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Emma not sleeping, watchdog disabled'})
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const airconEntity = ['climate.emma_bedroom_aircon']
|
||||||
|
|
||||||
|
// Gather relevant attributes from the aircon entity
|
||||||
|
|
||||||
|
const airconState = msg.payload.state
|
||||||
|
const airconAttributes = msg.payload.attributes
|
||||||
|
const airconEco = airconAttributes['eco_mode']
|
||||||
|
const airconTargetTemp = airconAttributes['temperature']
|
||||||
|
const airconFanMode = airconAttributes['fan_mode']
|
||||||
|
const airconDisplay = airconAttributes['screen_display']
|
||||||
|
|
||||||
|
// Gather the last explicitly sent configuration from the context
|
||||||
|
|
||||||
|
const airconHvacCfg = flow.get('emmaBedroom.airconHvacMode', 'diskCon')
|
||||||
|
const airconEcoCfg = flow.get('emmaBedroom.airconEco', 'diskCon')
|
||||||
|
const airconTargetTempCfg = parseFloat(flow.get('emmaBedroom.airconTargetTemp', 'diskCon'))
|
||||||
|
const airconFanModeCfg = flow.get('emmaBedroom.airconFanMode', 'diskCon')
|
||||||
|
const airconDisplayCfg = flow.get('emmaBedroom.airconDisplay', 'diskCon')
|
||||||
|
|
||||||
|
// Compare the current state with the last sent configuration
|
||||||
|
|
||||||
|
let ecoMatch = {}
|
||||||
|
let displayMatch = {}
|
||||||
|
let counter = 0
|
||||||
|
|
||||||
|
let sendDisplay = {
|
||||||
|
"payload": {
|
||||||
|
"action": `switch.${airconDisplayCfg}`,
|
||||||
|
"target": {
|
||||||
|
"entity_id": ["switch.emma_bedroom_aircon_display"]
|
||||||
|
},
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendHvac = {
|
||||||
|
"payload": {
|
||||||
|
"action": "climate.set_hvac_mode",
|
||||||
|
"target": {
|
||||||
|
"entity_id": airconEntity
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"hvac_mode": airconHvacCfg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendTemp = {
|
||||||
|
"payload": {
|
||||||
|
"action": "climate.set_temperature",
|
||||||
|
"target": {
|
||||||
|
"entity_id": airconEntity
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"temperature": airconTargetTempCfg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendEco = {
|
||||||
|
"payload": {
|
||||||
|
"action": `switch.${airconEcoCfg}`,
|
||||||
|
"target": {
|
||||||
|
"entity_id": ["switch.emma_bedroom_aircon_eco_mode"]
|
||||||
|
},
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendAcFan = {
|
||||||
|
"payload": {
|
||||||
|
"action": "climate.set_fan_mode",
|
||||||
|
"target": {
|
||||||
|
"entity_id": airconEntity
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"fan_mode": airconFanModeCfg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix hvac mode if mismatch
|
||||||
|
|
||||||
|
if (airconState != airconHvacCfg) {
|
||||||
|
node.log(`Emma Bedroom Aircon HVAC mode mismatch: ${airconState} vs ${airconHvacCfg}`)
|
||||||
|
node.send(sendHvac)
|
||||||
|
counter += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix eco mode if mismatch
|
||||||
|
|
||||||
|
if (airconEco === false && airconEcoCfg === 'turn_off') {
|
||||||
|
ecoMatch = true
|
||||||
|
} else if (airconEco === true && airconEcoCfg === 'turn_on') {
|
||||||
|
ecoMatch = true
|
||||||
|
} else {
|
||||||
|
ecoMatch = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ecoMatch === false) {
|
||||||
|
node.log(`Emma Bedroom Aircon Eco mode mismatch: ${airconEco} vs ${airconEcoCfg}`)
|
||||||
|
node.send(sendEco)
|
||||||
|
counter += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix target temperature if mismatch
|
||||||
|
|
||||||
|
if (airconTargetTemp != airconTargetTempCfg) {
|
||||||
|
node.log(`Target temperature mismatch: ${airconTargetTemp} vs ${airconTargetTempCfg}`)
|
||||||
|
node.send(sendTemp)
|
||||||
|
counter += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix fan mode if mismatch
|
||||||
|
|
||||||
|
if (airconFanMode != airconFanModeCfg) {
|
||||||
|
node.log(`Fan mode mismatch: ${airconFanMode} vs ${airconFanModeCfg}`)
|
||||||
|
node.send(sendAcFan)
|
||||||
|
counter += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix display mode if mismatch
|
||||||
|
|
||||||
|
if (airconDisplay === false && airconDisplayCfg === 'turn_off') {
|
||||||
|
displayMatch = true
|
||||||
|
} else if (airconDisplay === true && airconDisplayCfg === 'turn_on') {
|
||||||
|
displayMatch = true
|
||||||
|
} else {
|
||||||
|
displayMatch = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (displayMatch === false) {
|
||||||
|
node.log(`Emma Bedroom Aircon Display mode mismatch: ${airconDisplay} vs ${airconDisplayCfg}`)
|
||||||
|
node.send(sendDisplay)
|
||||||
|
counter += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (counter > 0) {
|
||||||
|
node.log(`Emma Bedroom Aircon: ${counter} configuration(s) fixed`)
|
||||||
|
node.status({fill:'yellow',shape:'dot',text:`${counter} config(s) fixed`})
|
||||||
|
} else {
|
||||||
|
node.status({fill:'green',shape:'dot',text:`No config changes`})
|
||||||
|
}
|
15
climate/master-bedroom/day-night.js
Normal file
15
climate/master-bedroom/day-night.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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
|
@ -4,8 +4,11 @@ const ac = global.get('masterBedroom.aircon.installed', "diskCon")
|
|||||||
const lastMode = flow.get("masterBedroom.lastMode", "diskCon")
|
const lastMode = flow.get("masterBedroom.lastMode", "diskCon")
|
||||||
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
|
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
|
||||||
|
|
||||||
|
const airconEntity = ["climate.master_bedroom_aircon"]
|
||||||
|
const fanEntity = ["fan.master_bedroom_fan"]
|
||||||
|
|
||||||
let setTemp = bedTemp
|
let setTemp = bedTemp
|
||||||
let setEco = 'none'
|
let setEco = 'turn_off'
|
||||||
let setHvac = 'cool'
|
let setHvac = 'cool'
|
||||||
let setAcFan = 'High'
|
let setAcFan = 'High'
|
||||||
let setFan = 'turn_off'
|
let setFan = 'turn_off'
|
||||||
@ -14,7 +17,7 @@ let sendFan = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": `fan.${setFan}`,
|
"action": `fan.${setFan}`,
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["fan.master_bedroom_fan"]
|
"entity_id": fanEntity
|
||||||
},
|
},
|
||||||
"data": {}
|
"data": {}
|
||||||
}
|
}
|
||||||
@ -24,7 +27,7 @@ let sendHvac = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_hvac_mode",
|
"action": "climate.set_hvac_mode",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["climate.master_bedroom_aircon"]
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"hvac_mode": setHvac
|
"hvac_mode": setHvac
|
||||||
@ -36,7 +39,7 @@ let sendTemp = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_temperature",
|
"action": "climate.set_temperature",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["climate.master_bedroom_aircon"]
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"temperature": setTemp
|
"temperature": setTemp
|
||||||
@ -46,13 +49,11 @@ let sendTemp = {
|
|||||||
|
|
||||||
let sendEco = {
|
let sendEco = {
|
||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_preset_mode",
|
"action": `switch.${setEco}`,
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["climate.master_bedroom_aircon"]
|
"entity_id": ["switch.master_bedroom_aircon_eco_mode"]
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {}
|
||||||
"preset_mode": setEco
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ let sendAcFan = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_fan_mode",
|
"action": "climate.set_fan_mode",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["climate.master_bedroom_aircon"]
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"fan_mode": setAcFan
|
"fan_mode": setAcFan
|
||||||
@ -76,7 +77,7 @@ if (toggle === 'on') {
|
|||||||
node.status({fill:"red",shape:"dot",text:"DANGER MODE ACTIVE"})
|
node.status({fill:"red",shape:"dot",text:"DANGER MODE ACTIVE"})
|
||||||
node.send([null,sendFan,null])
|
node.send([null,sendFan,null])
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac,sendTemp,sendEco,sendTemp],null,null])
|
node.send([[sendHvac,sendTemp,sendAcFan,sendEco],null,null])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"green",shape:"dot",text:"Danger Mode Off"})
|
node.status({fill:"green",shape:"dot",text:"Danger Mode Off"})
|
||||||
|
43
climate/master-bedroom/processing-start.js
Normal file
43
climate/master-bedroom/processing-start.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
context.set("isWakeup", false)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
let dayMode = {
|
||||||
|
"power": "turn_on",
|
||||||
|
"temp": dayTemp,
|
||||||
|
"hvac": "cool",
|
||||||
|
"fan": "auto",
|
||||||
|
"eco": "turn_on"
|
||||||
|
}
|
||||||
|
|
||||||
|
let nightMode = {
|
||||||
|
"power": "turn_on",
|
||||||
|
"temp": nightTemp,
|
||||||
|
"hvac": "cool",
|
||||||
|
"fan": "auto",
|
||||||
|
"eco": "turn_on"
|
||||||
|
}
|
||||||
|
|
||||||
|
let bedMode = {
|
||||||
|
"power": "turn_on",
|
||||||
|
"temp": bedTemp,
|
||||||
|
"hvac": "cool",
|
||||||
|
"fan": "auto",
|
||||||
|
"eco": "turn_off"
|
||||||
|
}
|
||||||
|
|
||||||
|
let showerMode = {
|
||||||
|
"power": "turn_on",
|
||||||
|
"temp": 70,
|
||||||
|
"hvac": "dry",
|
||||||
|
"fan": "auto",
|
||||||
|
"eco": "turn_off"
|
||||||
|
}
|
||||||
|
|
||||||
|
flow.set('masterBedroom.modes.daymode', dayMode, 'diskCon')
|
||||||
|
flow.set('masterBedroom.modes.nightmode', nightMode, 'diskCon')
|
||||||
|
flow.set('masterBedroom.modes.bedmode', bedMode, 'diskCon')
|
||||||
|
flow.set('masterBedroom.modes.showermode', showerMode, 'diskCon')
|
@ -11,7 +11,6 @@ const dayTemp = states['input_number.master_bedroom_daytime_temp'].state
|
|||||||
const nightTemp = states['input_number.master_bedroom_night_temp'].state
|
const nightTemp = states['input_number.master_bedroom_night_temp'].state
|
||||||
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
|
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
|
||||||
const showerMode = states['input_boolean.shower_mode'].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 fanMode = states['input_select.scheduled_climate_mode_master_bedroom_fan'].state
|
||||||
const acMode = states['input_select.scheduled_climate_mode_master_bedroom_aircon'].state
|
const acMode = states['input_select.scheduled_climate_mode_master_bedroom_aircon'].state
|
||||||
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
|
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
|
||||||
@ -21,14 +20,14 @@ const showerCooldown = states["timer.shower_mode_cooldown"].state
|
|||||||
const earlyNight = states["binary_sensor.early_night_mode"].state
|
const earlyNight = states["binary_sensor.early_night_mode"].state
|
||||||
const danger = states['binary_sensor.heat_warning'].attributes.danger
|
const danger = states['binary_sensor.heat_warning'].attributes.danger
|
||||||
const meltdown = states['input_boolean.meltdown_protocol'].state
|
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 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")
|
node.log("Master Bedroom Climate: Constants Set")
|
||||||
|
|
||||||
// Define some entity IDs
|
// Define some entity IDs
|
||||||
|
|
||||||
const masterBedroomAircon = "climate.master_bedroom_aircon"
|
const airconEntity = ["climate.master_bedroom_aircon"]
|
||||||
const masterBedroomFan = "fan.master_bedroom_fan"
|
const fanEntity = ["fan.master_bedroom_fan"]
|
||||||
const peopleIDs = ["input_boolean.tony_awake", "input_boolean.tina_awake"]
|
const peopleIDs = ["input_boolean.tony_awake", "input_boolean.tina_awake"]
|
||||||
|
|
||||||
// Helper function to convert a string to title case
|
// Helper function to convert a string to title case
|
||||||
@ -42,18 +41,18 @@ function convertToTitleCase(str) {
|
|||||||
|
|
||||||
// init variables
|
// init variables
|
||||||
|
|
||||||
let setTemp = []
|
let setTemp = dayTemp
|
||||||
let setEco = []
|
let setAcFan = 'auto'
|
||||||
let setHvac = []
|
let setEco = 'auto'
|
||||||
|
let setHvac = 'cool'
|
||||||
let setFan = []
|
let setFan = []
|
||||||
let setCool = []
|
let setMode = []
|
||||||
|
let validNight = ['Night Mode','Bedtime Mode']
|
||||||
let setSleep = []
|
let setSleep = []
|
||||||
let setPeople = []
|
let setPeople = []
|
||||||
let setDisplay = []
|
let setDisplay = 'turn_on'
|
||||||
let time = []
|
let time = []
|
||||||
let echoDotService = []
|
let echoDotService = []
|
||||||
let setBriefing = []
|
|
||||||
let setBriefingDelay = []
|
|
||||||
let type = msg.type
|
let type = msg.type
|
||||||
let topic = msg.topic
|
let topic = msg.topic
|
||||||
let isWakeup = context.get("isWakeup")
|
let isWakeup = context.get("isWakeup")
|
||||||
@ -64,15 +63,18 @@ if (type === 'sleep' && payload === 'off') {
|
|||||||
setDisplay = 'turn_on'
|
setDisplay = 'turn_on'
|
||||||
echoDotService = 'turn_off'
|
echoDotService = 'turn_off'
|
||||||
setPeople = 'turn_on'
|
setPeople = 'turn_on'
|
||||||
if (coolingActive === 'on') {
|
if (validNight.includes(currentMode)) {
|
||||||
time = 'night'
|
time = 'night'
|
||||||
|
setMode = 'Night Mode'
|
||||||
} else {
|
} else {
|
||||||
time = 'day'
|
time = 'day'
|
||||||
|
setMode = 'Day Mode'
|
||||||
}
|
}
|
||||||
} else if (type === 'sleep' && payload === 'on') {
|
} else if (type === 'sleep' && payload === 'on') {
|
||||||
setDisplay = 'turn_off'
|
setDisplay = 'turn_off'
|
||||||
echoDotService = 'turn_on'
|
echoDotService = 'turn_on'
|
||||||
time = 'bedtime'
|
time = 'bedtime'
|
||||||
|
setMode = 'Bedtime Mode'
|
||||||
} else {
|
} else {
|
||||||
time = msg.time
|
time = msg.time
|
||||||
}
|
}
|
||||||
@ -81,34 +83,23 @@ if (topic === 'mrbedroom-wakeup') {
|
|||||||
setSleep = 'turn_off'
|
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
|
// Day Time
|
||||||
if (time === 'day') {
|
if (time === 'day') {
|
||||||
if (type === 'auto') {
|
setMode = 'Day Mode'
|
||||||
setCool = 'turn_off'
|
|
||||||
}
|
|
||||||
if (earlyNight === 'off') {
|
if (earlyNight === 'off') {
|
||||||
setFan = "turn_off"
|
setFan = "turn_off"
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
if (danger === 'Extreme') {
|
if (danger === 'Extreme') {
|
||||||
setTemp = nightTemp
|
setTemp = nightTemp
|
||||||
setEco = "eco"
|
setEco = "turn_on"
|
||||||
setHvac = "cool"
|
setHvac = "cool"
|
||||||
} else if (hotDay === 'on' || heatWarning === 'on') {
|
} else if (hotDay === 'on' || heatWarning === 'on') {
|
||||||
setTemp = dayTemp
|
setTemp = dayTemp
|
||||||
setEco = "eco"
|
setEco = "turn_on"
|
||||||
setHvac = "cool"
|
setHvac = "cool"
|
||||||
} else {
|
} else {
|
||||||
setTemp = nightTemp
|
setTemp = nightTemp
|
||||||
setEco = "eco"
|
setEco = "turn_on"
|
||||||
setHvac = "off"
|
setHvac = "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,18 +123,15 @@ if (time === 'day') {
|
|||||||
setHvac = 'off'
|
setHvac = 'off'
|
||||||
}
|
}
|
||||||
if (hotDay === 'on') {
|
if (hotDay === 'on') {
|
||||||
setEco = 'none'
|
setEco = 'turn_off'
|
||||||
} else {
|
} else {
|
||||||
setEco = 'eco'
|
setEco = 'turn_on'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Night Time
|
// Night Time
|
||||||
} else if (time === 'night') {
|
} else if (time === 'night') {
|
||||||
// If this is being run at scheduled time, turn on input_boolean.master_bedroom_cooling_on
|
setMode = 'Night Mode'
|
||||||
if (type === 'auto') {
|
|
||||||
setCool = 'turn_on'
|
|
||||||
}
|
|
||||||
// Decide temperature
|
// Decide temperature
|
||||||
if (type === 'sleep' && payload === 'off') {
|
if (type === 'sleep' && payload === 'off') {
|
||||||
setTemp = dayTemp
|
setTemp = dayTemp
|
||||||
@ -154,9 +142,9 @@ if (time === 'day') {
|
|||||||
}
|
}
|
||||||
// Decide eco mode
|
// Decide eco mode
|
||||||
if (sleeping === 'on') {
|
if (sleeping === 'on') {
|
||||||
setEco = 'none'
|
setEco = 'turn_off'
|
||||||
} else {
|
} else {
|
||||||
setEco = 'eco'
|
setEco = 'turn_on'
|
||||||
}
|
}
|
||||||
// Decide HVAC mode
|
// Decide HVAC mode
|
||||||
if (acMode === 'AC') {
|
if (acMode === 'AC') {
|
||||||
@ -174,14 +162,17 @@ if (time === 'day') {
|
|||||||
}
|
}
|
||||||
// Bed Time
|
// Bed Time
|
||||||
} else if (time === 'bedtime') {
|
} else if (time === 'bedtime') {
|
||||||
|
setMode = 'Bedtime Mode'
|
||||||
setPeople = 'turn_off'
|
setPeople = 'turn_off'
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
setTemp = bedTemp
|
setTemp = bedTemp
|
||||||
setEco = 'none'
|
setEco = 'turn_off'
|
||||||
if (acMode === 'AC') {
|
if (acMode === 'AC') {
|
||||||
setHvac = 'cool'
|
setHvac = 'cool'
|
||||||
|
setDisplay = 'turn_off'
|
||||||
} else if (acMode === 'Fan') {
|
} else if (acMode === 'Fan') {
|
||||||
setHvac = "fan_only"
|
setHvac = "fan_only"
|
||||||
|
setDisplay = 'turn_off'
|
||||||
} else {
|
} else {
|
||||||
setHvac = "off"
|
setHvac = "off"
|
||||||
}
|
}
|
||||||
@ -200,19 +191,21 @@ let sendFan = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": `fan.${setFan}`,
|
"action": `fan.${setFan}`,
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": masterBedroomFan
|
"entity_id": fanEntity
|
||||||
},
|
},
|
||||||
"data": {}
|
"data": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sendCool = {
|
let sendMode = {
|
||||||
"payload": {
|
"payload": {
|
||||||
"action": `input_boolean.${setCool}`,
|
"action": "input_select.select_option",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": ["input_boolean.master_bedroom_cooling_on"]
|
"entity_id": ["input_select.current_climate_mode_master_bedroom"]
|
||||||
},
|
},
|
||||||
"data": {}
|
"data": {
|
||||||
|
"option": setMode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,18 +246,11 @@ let notify = {
|
|||||||
"fanmode": fanMode
|
"fanmode": fanMode
|
||||||
}
|
}
|
||||||
|
|
||||||
let sendBriefing = {
|
|
||||||
"payload": {
|
|
||||||
"action": `script.${setBriefing}`,
|
|
||||||
},
|
|
||||||
"delay": setBriefingDelay
|
|
||||||
}
|
|
||||||
|
|
||||||
let sendHvac = {
|
let sendHvac = {
|
||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_hvac_mode",
|
"action": "climate.set_hvac_mode",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": masterBedroomAircon
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"hvac_mode": setHvac
|
"hvac_mode": setHvac
|
||||||
@ -276,7 +262,7 @@ let sendTemp = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_temperature",
|
"action": "climate.set_temperature",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": masterBedroomAircon
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"temperature": setTemp
|
"temperature": setTemp
|
||||||
@ -286,13 +272,11 @@ let sendTemp = {
|
|||||||
|
|
||||||
let sendEco = {
|
let sendEco = {
|
||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_preset_mode",
|
"action": `switch.${setEco}`,
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": masterBedroomAircon
|
"entity_id": ["switch.master_bedroom_aircon_eco_mode"]
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {}
|
||||||
"preset_mode": setEco
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,10 +284,10 @@ let sendAcFan = {
|
|||||||
"payload": {
|
"payload": {
|
||||||
"action": "climate.set_fan_mode",
|
"action": "climate.set_fan_mode",
|
||||||
"target": {
|
"target": {
|
||||||
"entity_id": masterBedroomAircon
|
"entity_id": airconEntity
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"fan_mode": "auto"
|
"fan_mode": setAcFan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,15 +308,14 @@ node.log("Master Bedroom Climate: Message Payloads Defined")
|
|||||||
|
|
||||||
node.log("----- Master Bedroom Climate: Set Parameters -----")
|
node.log("----- Master Bedroom Climate: Set Parameters -----")
|
||||||
node.log(`setTemp: ${setTemp}`)
|
node.log(`setTemp: ${setTemp}`)
|
||||||
|
node.log(`setAcFan: ${setAcFan}`)
|
||||||
node.log(`setEco: ${setEco}`)
|
node.log(`setEco: ${setEco}`)
|
||||||
node.log(`setHvac: ${setHvac}`)
|
node.log(`setHvac: ${setHvac}`)
|
||||||
node.log(`setFan: ${setFan}`)
|
node.log(`setFan: ${setFan}`)
|
||||||
node.log(`setCool: ${setCool}`)
|
node.log(`setMode: ${setMode}`)
|
||||||
node.log(`setSleep: ${setSleep}`)
|
node.log(`setSleep: ${setSleep}`)
|
||||||
node.log(`setPeople: ${setPeople}`)
|
node.log(`setPeople: ${setPeople}`)
|
||||||
node.log(`setDisplay: ${setDisplay}`)
|
node.log(`setDisplay: ${setDisplay}`)
|
||||||
node.log(`setBriefing: ${setBriefing}`)
|
|
||||||
node.log(`setBriefingDelay: ${setBriefingDelay}`)
|
|
||||||
node.log(`time: ${time}`)
|
node.log(`time: ${time}`)
|
||||||
node.log(`type: ${type}`)
|
node.log(`type: ${type}`)
|
||||||
node.log(`topic: ${topic}`)
|
node.log(`topic: ${topic}`)
|
||||||
@ -340,9 +323,9 @@ node.log("----- Master Bedroom Climate: End Parameters -----")
|
|||||||
|
|
||||||
// If this was an automated trigger, set the cooling context for the bedroom accordingly.
|
// If this was an automated trigger, set the cooling context for the bedroom accordingly.
|
||||||
|
|
||||||
if (type === 'auto' && time != 'bedtime') {
|
if (type === 'auto') {
|
||||||
node.send([null, null, sendCool, null, null])
|
node.send([null, null, sendMode, null])
|
||||||
node.log("Master Bedroom Climate: Cooling Context Set")
|
node.log("Master Bedroom Climate: Cooling Mode Context Set")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automated responses
|
// Automated responses
|
||||||
@ -354,39 +337,38 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
} else {
|
} else {
|
||||||
if (topic === 'mrbedroom-cooling' && ac === 'on') {
|
if (topic === 'mrbedroom-cooling' && ac === 'on') {
|
||||||
node.status({ fill: "green", shape: "dot", text: "Cooling Schedule" })
|
node.status({ fill: "green", shape: "dot", text: "Cooling Schedule" })
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||||
node.log("Master Bedroom Climate: Auto/Cooling")
|
node.log("Master Bedroom Climate: Auto/Cooling")
|
||||||
} else if (topic === 'mrbedroom-bedtime') {
|
} else if (topic === 'mrbedroom-bedtime') {
|
||||||
node.send([null, null, sendPeople, null, null])
|
node.send([null, null, sendPeople, null])
|
||||||
node.status({ fill: "green", shape: "dot", text: "Bedtime" })
|
node.status({ fill: "green", shape: "dot", text: "Bedtime" })
|
||||||
node.log("Master Bedroom Climate: Auto/Bedtime")
|
node.log("Master Bedroom Climate: Auto/Bedtime")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||||
node.log("Master Bedroom Climate: Auto/Bedtime/AC")
|
node.log("Master Bedroom Climate: Auto/Bedtime/AC")
|
||||||
}
|
}
|
||||||
if (fanMode === 'fan') {
|
if (fanMode === 'fan') {
|
||||||
node.send([null, sendFan, null, null, null])
|
node.send([null, sendFan, null, null])
|
||||||
node.log("Master Bedroom Climate: Auto/Bedtime/Fan")
|
node.log("Master Bedroom Climate: Auto/Bedtime/Fan")
|
||||||
}
|
}
|
||||||
} else if (topic === 'mrbedroom-fan' && fanMode === 'Fan') {
|
} else if (topic === 'mrbedroom-fan' && fanMode === 'Fan') {
|
||||||
node.status({ fill: "green", shape: "dot", text: "Fan Schedule" })
|
node.status({ fill: "green", shape: "dot", text: "Fan Schedule" })
|
||||||
node.send([null, sendFan, null, null, null])
|
node.send([null, sendFan, null, null])
|
||||||
node.log("Master Bedroom Climate: Auto/Fan")
|
node.log("Master Bedroom Climate: Auto/Fan")
|
||||||
} else if (topic === 'mrbedroom-wakeup') {
|
} else if (topic === 'mrbedroom-wakeup') {
|
||||||
node.send([null, null, null, null, sendBriefing])
|
|
||||||
node.status({ fill: "green", shape: "dot", text: "Wakeup Schedule" })
|
node.status({ fill: "green", shape: "dot", text: "Wakeup Schedule" })
|
||||||
node.log("Master Bedroom Climate: Auto/Wakeup")
|
node.log("Master Bedroom Climate: Auto/Wakeup")
|
||||||
if (sleeping === 'off') {
|
if (sleeping === 'off') {
|
||||||
context.set("isWakeup", false)
|
context.set("isWakeup", false)
|
||||||
node.send([null, sendFan, null, null, null])
|
node.send([null, sendFan, null, null])
|
||||||
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep Off")
|
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep Off")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||||
node.log("Master Bedroom Climate: Auto/Wakeup/AC On")
|
node.log("Master Bedroom Climate: Auto/Wakeup/AC On")
|
||||||
}
|
}
|
||||||
} else if (sleeping === 'on') {
|
} else if (sleeping === 'on') {
|
||||||
context.set("isWakeup", true)
|
context.set("isWakeup", true)
|
||||||
node.send([null, null, sendSleep, null, null])
|
node.send([null, null, sendSleep, null])
|
||||||
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep On")
|
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep On")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,26 +378,26 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
node.log("Master Bedroom Climate: Manual")
|
node.log("Master Bedroom Climate: Manual")
|
||||||
if (time === 'night') {
|
if (time === 'night') {
|
||||||
node.status({ fill: "blue", shape: "dot", text: "Manual Night" })
|
node.status({ fill: "blue", shape: "dot", text: "Manual Night" })
|
||||||
node.send([null, sendFan, null, null, null])
|
node.send([null, sendFan, null, null])
|
||||||
node.log("Master Bedroom Climate: Manual/Night")
|
node.log("Master Bedroom Climate: Manual/Night")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||||
node.log("Master Bedroom Climate: Manual/Night/AC")
|
node.log("Master Bedroom Climate: Manual/Night/AC")
|
||||||
}
|
}
|
||||||
} else if (time === 'day') {
|
} else if (time === 'day') {
|
||||||
node.status({ fill: "blue", shape: "dot", text: "Manual Day" })
|
node.status({ fill: "blue", shape: "dot", text: "Manual Day" })
|
||||||
node.send([null, sendFan, null, null, null])
|
node.send([null, sendFan, null, null])
|
||||||
node.log("Master Bedroom Climate: Manual/Day")
|
node.log("Master Bedroom Climate: Manual/Day")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||||
node.log("Master Bedroom Climate: Manual/Day/AC")
|
node.log("Master Bedroom Climate: Manual/Day/AC")
|
||||||
}
|
}
|
||||||
} else if (time === 'bedtime') {
|
} else if (time === 'bedtime') {
|
||||||
node.status({ fill: "blue", shape: "dot", text: "Manual Bedtime" })
|
node.status({ fill: "blue", shape: "dot", text: "Manual Bedtime" })
|
||||||
node.send([null, sendFan, null, null, null])
|
node.send([null, sendFan, null, null])
|
||||||
node.log("Master Bedroom Climate: Manual/Bedtime")
|
node.log("Master Bedroom Climate: Manual/Bedtime")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||||
node.log("Master Bedroom Climate: Manual/Bedtime/AC")
|
node.log("Master Bedroom Climate: Manual/Bedtime/AC")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -423,28 +405,25 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
|
|||||||
// Sleep Switch Responses
|
// Sleep Switch Responses
|
||||||
} else if (type === 'sleep') {
|
} else if (type === 'sleep') {
|
||||||
if (payload === 'off') {
|
if (payload === 'off') {
|
||||||
node.send([null, null, sendPeople, null, null])
|
node.send([null, null, sendPeople, null])
|
||||||
}
|
}
|
||||||
node.log("Master Bedroom Climate: Sleep")
|
node.log("Master Bedroom Climate: Sleep")
|
||||||
if (time === 'bedtime') {
|
if (time === 'bedtime') {
|
||||||
node.status({ fill: "blue", shape: "dot", text: "Sleep" })
|
node.status({ fill: "blue", shape: "dot", text: "Sleep" })
|
||||||
node.send([null, sendFan, [sendEchoDotDND,sendPeople], null, null])
|
node.send([null, sendFan, [sendEchoDotDND,sendPeople], null])
|
||||||
node.log("Master Bedroom Climate: Sleep/Bedtime")
|
node.log("Master Bedroom Climate: Sleep/Bedtime")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||||
node.log("Master Bedroom Climate: Sleep/Bedtime/AC")
|
node.log("Master Bedroom Climate: Sleep/Bedtime/AC")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
node.status({ fill: "blue", shape: "dot", text: "Wakeup" })
|
node.status({ fill: "blue", shape: "dot", text: "Wakeup" })
|
||||||
node.send([null, sendFan, sendEchoDotDND, null, null])
|
node.send([null, sendFan, sendEchoDotDND, null])
|
||||||
node.log("Master Bedroom Climate: Sleep/Day")
|
node.log("Master Bedroom Climate: Sleep/Day")
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
|
node.send([[sendDisplay, sendHvac, sendTemp, sendAcFan, sendEco], null, null, null])
|
||||||
node.log(`Master Bedroom Climate: Sleep/${convertToTitleCase(time)}/AC`)
|
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)
|
context.set("isWakeup", false)
|
||||||
} else if (meltdown === 'on') {
|
} else if (meltdown === 'on') {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const states = global.get('homeassistant.homeAssistant.states')
|
const states = global.get('homeassistant.homeAssistant.states')
|
||||||
const ac = global.get('masterBedroom.aircon.installed', "diskCon")
|
const ac = global.get('masterBedroom.aircon.installed', "diskCon")
|
||||||
const temp = global.get('outdoorTemptempStr')
|
const temp = global.get('outdoorTemp.tempStr')
|
||||||
const threshold = states['input_number.master_bedroom_aircon_run_threshold'].state
|
const threshold = states['input_number.master_bedroom_aircon_run_threshold'].state
|
||||||
const dayTemp = states['input_number.master_bedroom_daytime_temp'].state
|
const dayTemp = states['input_number.master_bedroom_daytime_temp'].state
|
||||||
const nightTemp = states['input_number.master_bedroom_night_temp'].state
|
const nightTemp = states['input_number.master_bedroom_night_temp'].state
|
||||||
@ -11,31 +11,33 @@ const sleeping = states['input_boolean.master_bedroom_sleeping'].state
|
|||||||
const hotDay = states['input_boolean.hot_day'].state
|
const hotDay = states['input_boolean.hot_day'].state
|
||||||
const topic = msg.topic
|
const topic = msg.topic
|
||||||
|
|
||||||
|
const airconEntity = ["climate.master_bedroom_aircon"]
|
||||||
|
|
||||||
let setTemp = {}
|
let setTemp = {}
|
||||||
let ecoMode = {}
|
let setEco = {}
|
||||||
let duration = {}
|
let duration = {}
|
||||||
let end = {}
|
let end = {}
|
||||||
let hvac = {}
|
let setHvac = {}
|
||||||
|
|
||||||
if (topic === 'toggle') {
|
if (topic === 'toggle') {
|
||||||
if (hotDay === 'on' || sleeping === 'on') {
|
if (hotDay === 'on' || sleeping === 'on') {
|
||||||
setTemp = bedTemp
|
setTemp = bedTemp
|
||||||
ecoMode = 'none'
|
setEco = 'turn_off'
|
||||||
} else {
|
} else {
|
||||||
setTemp = nightTemp
|
setTemp = nightTemp
|
||||||
ecoMode = 'eco'
|
setEco = 'turn_on'
|
||||||
}
|
}
|
||||||
} else if (topic === 'timer') {
|
} else if (topic === 'timer') {
|
||||||
if (currentSetTemp == bedTemp) {
|
if (currentSetTemp == bedTemp) {
|
||||||
setTemp = nightTemp
|
setTemp = nightTemp
|
||||||
if (hotDay === 'on') {
|
if (hotDay === 'on') {
|
||||||
ecoMode = 'none'
|
setEco = 'turn_off'
|
||||||
} else {
|
} else {
|
||||||
ecoMode = 'eco'
|
setEco = 'turn_on'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setTemp = dayTemp
|
setTemp = dayTemp
|
||||||
ecoMode = 'eco'
|
setEco = 'turn_on'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,36 +52,75 @@ if (setTemp == bedTemp) {
|
|||||||
if (setTemp == dayTemp) {
|
if (setTemp == dayTemp) {
|
||||||
end = true
|
end = true
|
||||||
if (hotDay === 'off') {
|
if (hotDay === 'off') {
|
||||||
hvac = 'off'
|
setHvac = 'off'
|
||||||
} else {
|
} else {
|
||||||
hvac = 'cool'
|
setHvac = 'cool'
|
||||||
}
|
}
|
||||||
} else if (setTemp != bedTemp && coolingTime === 'on') {
|
} else if (setTemp != bedTemp && coolingTime === 'on') {
|
||||||
end = true
|
end = true
|
||||||
hvac = 'cool'
|
setHvac = 'cool'
|
||||||
} else {
|
} else {
|
||||||
end = false
|
end = false
|
||||||
hvac = 'cool'
|
setHvac = 'cool'
|
||||||
}
|
|
||||||
|
|
||||||
let setMsg = {
|
|
||||||
"set": setTemp,
|
|
||||||
"eco": ecoMode,
|
|
||||||
"hvac": hvac,
|
|
||||||
"end": end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let timerStart = {
|
let timerStart = {
|
||||||
"duration": duration
|
"duration": duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sendHvac = {
|
||||||
|
"payload": {
|
||||||
|
"action": "climate.set_hvac_mode",
|
||||||
|
"target": {
|
||||||
|
"entity_id": airconEntity
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"hvac_mode": setHvac
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendTemp = {
|
||||||
|
"payload": {
|
||||||
|
"action": "climate.set_temperature",
|
||||||
|
"target": {
|
||||||
|
"entity_id": airconEntity
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"temperature": setTemp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendEco = {
|
||||||
|
"payload": {
|
||||||
|
"action": `switch.${setEco}`,
|
||||||
|
"target": {
|
||||||
|
"entity_id": ["switch.master_bedroom_aircon_eco_mode"]
|
||||||
|
},
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendAcFan = {
|
||||||
|
"payload": {
|
||||||
|
"action": "climate.set_fan_mode",
|
||||||
|
"target": {
|
||||||
|
"entity_id": airconEntity
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"fan_mode": "auto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ac === 'on' && temp >= threshold) {
|
if (ac === 'on' && temp >= threshold) {
|
||||||
if (sleeping === 'on' || coolingTime === 'on' || end === true) {
|
if (sleeping === 'on' || coolingTime === 'on' || end === true) {
|
||||||
node.status({fill:"green",shape:"dot",text:"Finished"})
|
node.status({fill:"green",shape:"dot",text:"Finished"})
|
||||||
return [setMsg, null]
|
return [[sendHvac, sendTemp, sendAcFan, sendEco], null]
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"blue",shape:"dot",text:"Next Cycle"})
|
node.status({fill:"blue",shape:"dot",text:"Next Cycle"})
|
||||||
return [setMsg, timerStart]
|
return [[sendHvac, sendTemp, sendAcFan, sendEco], timerStart]
|
||||||
}
|
}
|
||||||
} else if (ac === 'off') {
|
} else if (ac === 'off') {
|
||||||
node.status({fill:"red",shape:"ring",text:"A/C Not Installed"})
|
node.status({fill:"red",shape:"ring",text:"A/C Not Installed"})
|
||||||
|
@ -6,17 +6,56 @@ const nightTemp = states['input_number.master_bedroom_night_temp'].state
|
|||||||
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
|
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
|
||||||
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
|
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
|
||||||
|
|
||||||
|
const airconEntity = ["climate.master_bedroom_aircon"]
|
||||||
|
|
||||||
|
let setTemp = []
|
||||||
|
let setHvac = "dry"
|
||||||
|
let setEco = "turn_off"
|
||||||
|
|
||||||
|
if (sleeping === 'on') {
|
||||||
|
setTemp = bedTemp
|
||||||
|
} else {
|
||||||
|
setTemp = nightTemp
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendHvac = {
|
||||||
|
"payload": {
|
||||||
|
"action": "climate.set_hvac_mode",
|
||||||
|
"target": {
|
||||||
|
"entity_id": airconEntity
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"hvac_mode": setHvac
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendTemp = {
|
||||||
|
"payload": {
|
||||||
|
"action": "climate.set_temperature",
|
||||||
|
"target": {
|
||||||
|
"entity_id": airconEntity
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"temperature": setTemp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sendEco = {
|
||||||
|
"payload": {
|
||||||
|
"action": `switch.${setEco}`,
|
||||||
|
"target": {
|
||||||
|
"entity_id": ["switch.master_bedroom_aircon_eco_mode"]
|
||||||
|
},
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ac === 'on') {
|
if (ac === 'on') {
|
||||||
if (temp >= threshold) {
|
if (temp >= threshold) {
|
||||||
if (sleeping === 'on') {
|
node.status({fill:"green",shape:"dot",text:`Shower Mode On: ${setTemp}°F`})
|
||||||
msg.set = bedTemp
|
node.send([[sendHvac, sendTemp, sendEco]])
|
||||||
node.status({fill:"green",shape:"dot",text:`Shower Mode On: ${bedTemp}`})
|
|
||||||
return msg
|
|
||||||
} else {
|
|
||||||
msg.set = nightTemp
|
|
||||||
node.status({fill:"green",shape:"dot",text:`Shower Mode On: ${nightTemp}`})
|
|
||||||
return msg
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red",shape:"ring",text:"Too Cold"})
|
node.status({fill:"red",shape:"ring",text:"Too Cold"})
|
||||||
return null
|
return null
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const states = global.get('homeassistant.homeAssistant.states')
|
const states = global.get('homeassistant.homeAssistant.states')
|
||||||
const earlyNightMode = states['binary_sensor.early_night_mode'].state
|
const outdoorLux = parseInt(states['sensor.home_tempest_illuminance'].state)
|
||||||
|
const threshold = parseInt(states['input_number.front_porch_lux_threshold'].state)
|
||||||
const frontPorchToggle = states['input_boolean.front_porch_light_on'].state
|
const frontPorchToggle = states['input_boolean.front_porch_light_on'].state
|
||||||
const holidaymode = states['input_boolean.holiday_mode'].state
|
const holidaymode = states['input_boolean.holiday_mode'].state
|
||||||
const currentholiday = states['input_select.holiday_animation'].state
|
const currentholiday = states['input_select.holiday_animation'].state
|
||||||
@ -9,7 +10,7 @@ let holidayMsg = {
|
|||||||
"holiday": holiday
|
"holiday": holiday
|
||||||
}
|
}
|
||||||
|
|
||||||
if (earlyNightMode === 'on' && frontPorchToggle === 'on') {
|
if ((outdoorLux <= threshold) && frontPorchToggle === 'on') {
|
||||||
if (holidaymode === 'on') {
|
if (holidaymode === 'on') {
|
||||||
node.status({fill:"blue",shape:"dot",text:"Holiday On"})
|
node.status({fill:"blue",shape:"dot",text:"Holiday On"})
|
||||||
node.send([holidayMsg,msg])
|
node.send([holidayMsg,msg])
|
||||||
@ -20,7 +21,7 @@ if (earlyNightMode === 'on' && frontPorchToggle === 'on') {
|
|||||||
} else {
|
} else {
|
||||||
if (frontPorchToggle === 'off') {
|
if (frontPorchToggle === 'off') {
|
||||||
node.status({ fill: "red", shape: "ring", text: "Disabled" })
|
node.status({ fill: "red", shape: "ring", text: "Disabled" })
|
||||||
} else if (earlyNightMode === 'off') {
|
} else if (outdoorLux > threshold) {
|
||||||
node.status({ fill: "red", shape: "ring", text: "Daytime" })
|
node.status({ fill: "red", shape: "ring", text: "Daytime" })
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,11 +3,13 @@ const lights = states['light.kallen_bedroom_lights'].state
|
|||||||
const duration = states['input_number.kallen_bedroom_lights_off_delay'].state
|
const duration = states['input_number.kallen_bedroom_lights_off_delay'].state
|
||||||
const lux = parseInt(states['sensor.kallen_bedroom_illuminance'].state)
|
const lux = parseInt(states['sensor.kallen_bedroom_illuminance'].state)
|
||||||
const threshold = parseInt(states['input_number.kallen_bedroom_lux_threshold'].state)
|
const threshold = parseInt(states['input_number.kallen_bedroom_lux_threshold'].state)
|
||||||
const sleeping = states['input_boolean.kallen_sleeping'].state
|
const kallenBedroomSleep = states['input_boolean.kallen_sleeping'].state
|
||||||
|
const masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state
|
||||||
|
const peopleSleeping = (masterBedroomSleep === 'on' || kallenBedroomSleep === 'on')
|
||||||
const payload = msg.payload
|
const payload = msg.payload
|
||||||
const newDuration = duration * 60
|
const newDuration = duration * 60
|
||||||
|
|
||||||
if (sleeping === 'off') {
|
if (peopleSleeping === false) {
|
||||||
if (payload === 'on') {
|
if (payload === 'on') {
|
||||||
if (lux <= threshold && lights === 'off') {
|
if (lux <= threshold && lights === 'off') {
|
||||||
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
node.status({fill:'green',shape:'dot',text:'Turning lights on'})
|
||||||
|
@ -1,18 +1,27 @@
|
|||||||
const states = global.get('homeassistant.homeAssistant.states')
|
const states = global.get('homeassistant.homeAssistant.states')
|
||||||
const luxThresholdLivingRoom = states['input_number.living_room_lux_threshold'].state
|
const luxThresholdLivingRoom = states['input_number.living_room_lux_threshold'].state
|
||||||
const luxThresholdStairwell = states['input_number.stairwell_lux_threshold'].state
|
const luxThresholdStairwell = states['input_number.stairwell_lux_threshold'].state
|
||||||
const timer = states['timer.sunset_lighting_timer'].state
|
const luxThresholdOutdoor = states['input_number.sunset_lights_outdoor_lux_threshold'].state
|
||||||
|
const earlyNight = states['binary_sensor.early_night_mode'].state
|
||||||
|
const triggered = states['input_boolean.sunset_lights_triggered'].state
|
||||||
const level = msg.level
|
const level = msg.level
|
||||||
const room = msg.room
|
const room = msg.room
|
||||||
|
|
||||||
if (timer === 'active') {
|
if (earlyNight === 'on' && triggered === 'off') {
|
||||||
if (room === 'living-room' && level <= luxThresholdLivingRoom) {
|
if (room === 'living-room' && level <= luxThresholdLivingRoom) {
|
||||||
node.status({fill:'green',shape:'dot',text:'Sent (Living Room)'})
|
node.status({fill:'green',shape:'dot',text:'Sent (Living Room)'})
|
||||||
node.send(msg)
|
node.send([msg,msg])
|
||||||
} else if (room === 'stairwell-bottom' && level <= luxThresholdStairwell) {
|
} else if (room === 'stairwell-bottom' && level <= luxThresholdStairwell) {
|
||||||
node.status({fill:'green',shape:'dot',text:'Sent (Stairwell Bottom)'})
|
node.status({fill:'green',shape:'dot',text:'Sent (Stairwell Bottom)'})
|
||||||
node.send(msg)
|
node.send([msg,msg])
|
||||||
|
} else if (room === 'outdoor' && level <= luxThresholdOutdoor) {
|
||||||
|
node.status({fill:'green',shape:'dot',text:'Sent (Outdoor)'})
|
||||||
|
node.send([msg,msg])
|
||||||
}
|
}
|
||||||
|
} else if (earlyNight === 'off') {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Not Evening'})
|
||||||
|
} else if (triggered === 'on') {
|
||||||
|
node.status({fill:'red',shape:'ring',text:'Already Triggered'})
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:'red',shape:'ring',text:'Blocked'})
|
node.status({fill:'red',shape:'ring',text:'No Action'})
|
||||||
}
|
}
|
@ -64,7 +64,8 @@ const booleanOff = [
|
|||||||
"input_boolean.give_me_darkness",
|
"input_boolean.give_me_darkness",
|
||||||
"input_boolean.goodnight",
|
"input_boolean.goodnight",
|
||||||
"input_boolean.kallen_computer_updates",
|
"input_boolean.kallen_computer_updates",
|
||||||
"input_boolean.night_mode"
|
"input_boolean.night_mode",
|
||||||
|
"input_boolean.sunset_lights_triggered"
|
||||||
]
|
]
|
||||||
|
|
||||||
//! ---------- NIGHT MODE ----------
|
//! ---------- NIGHT MODE ----------
|
||||||
|
@ -11,22 +11,18 @@ const sunsetLights = states['input_boolean.sunset_lights_on'].state
|
|||||||
const vacation = states['input_boolean.vacation_mode'].state
|
const vacation = states['input_boolean.vacation_mode'].state
|
||||||
const upBathOcc = states['binary_sensor.upstairs_bathroom_occupied'].state
|
const upBathOcc = states['binary_sensor.upstairs_bathroom_occupied'].state
|
||||||
const deskLights = states['light.tina_desk_lights'].state
|
const deskLights = states['light.tina_desk_lights'].state
|
||||||
const luxLivingRoom = states['sensor.living_room_front_illuminance'].state
|
|
||||||
const luxThresholdLivingRoom = states['input_number.living_room_lux_threshold'].state
|
|
||||||
const luxStairwell = states['sensor.stairwell_bottom_illuminance'].state
|
|
||||||
const luxThresholdStairwell = states['input_number.stairwell_lux_threshold'].state
|
|
||||||
const adaptiveSleep = flow.get("adaptiveSleep", "diskCon")
|
const adaptiveSleep = flow.get("adaptiveSleep", "diskCon")
|
||||||
const selScenesMain = flow.get("selScenesMain", "diskCon")
|
const selScenesMain = flow.get("selScenesMain", "diskCon")
|
||||||
const selScenesTinaDesk = flow.get("selScenesTinaDesk", "diskCon")
|
const selScenesTinaDesk = flow.get("selScenesTinaDesk", "diskCon")
|
||||||
const booleanOff = flow.get("booleanOff", "diskCon")
|
const booleanOff = flow.get("booleanOff", "diskCon")
|
||||||
|
const triggered = states['input_boolean.sunset_lights_triggered'].state
|
||||||
const payload = msg.payload
|
const payload = msg.payload
|
||||||
|
const topic = msg.topic
|
||||||
node.log("Time-based Automations: Constants Set")
|
node.log("Time-based Automations: Constants Set")
|
||||||
|
|
||||||
// Set a few important variables
|
// Set a few important variables
|
||||||
|
|
||||||
let time = {}
|
let time = {}
|
||||||
let topic = {}
|
|
||||||
let delay = {}
|
|
||||||
let eventCall = {}
|
let eventCall = {}
|
||||||
|
|
||||||
if (payload == 0) {
|
if (payload == 0) {
|
||||||
@ -37,17 +33,6 @@ if (payload == 0) {
|
|||||||
eventCall = "off"
|
eventCall = "off"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.topic === 'timer-finished' || msg.topic === 'manual-trigger' || msg.topic === 'lux') {
|
|
||||||
topic = msg.topic
|
|
||||||
}
|
|
||||||
|
|
||||||
if (topic === 'timer-finished' || topic === 'manual-trigger' || topic === 'lux') {
|
|
||||||
delay = 'off'
|
|
||||||
} else if (luxLivingRoom > luxThresholdLivingRoom && luxStairwell > luxThresholdStairwell) {
|
|
||||||
delay = 'on'
|
|
||||||
} else {
|
|
||||||
delay = 'off'
|
|
||||||
}
|
|
||||||
node.log("Time-based Automations: Main variables defined")
|
node.log("Time-based Automations: Main variables defined")
|
||||||
|
|
||||||
// ---------- Configuration ----------
|
// ---------- Configuration ----------
|
||||||
@ -96,19 +81,8 @@ if (sunsetLights === 'off') {
|
|||||||
sunsetStatus = "Skipped"
|
sunsetStatus = "Skipped"
|
||||||
} else {
|
} else {
|
||||||
notifyTitle = "Sunset Lights On"
|
notifyTitle = "Sunset Lights On"
|
||||||
if (topic === 'timer-finished') {
|
notifyMsg = "It's getting dark, evening lighting is now active"
|
||||||
notifyMsg = "Lights on because timer was finished manually"
|
sunsetStatus = "Light Level Trigger"
|
||||||
sunsetStatus = "Manual Trigger"
|
|
||||||
} else if (topic === 'lux') {
|
|
||||||
notifyMsg = "Lights on because light level dropped below threshold"
|
|
||||||
sunsetStatus = "Light Level Trigger"
|
|
||||||
} else if (delay === 'on') {
|
|
||||||
notifyMsg = "Lights on after delay due to sufficient light"
|
|
||||||
sunsetStatus = "Delayed"
|
|
||||||
} else if (delay === 'off') {
|
|
||||||
notifyMsg = "Lights on early due to low light"
|
|
||||||
sunsetStatus = "Early"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Holiday Settings
|
// Holiday Settings
|
||||||
@ -125,6 +99,17 @@ if (holidayMode === 'on') {
|
|||||||
node.log("Time-based Automations: Decision Logic Complete")
|
node.log("Time-based Automations: Decision Logic Complete")
|
||||||
|
|
||||||
// ---------- Service Calls ----------
|
// ---------- Service Calls ----------
|
||||||
|
|
||||||
|
let sendTriggered = {
|
||||||
|
"payload": {
|
||||||
|
"action": "input_boolean.turn_on",
|
||||||
|
"target": {
|
||||||
|
"entity_id": ["input_boolean.sunset_lights_triggered"]
|
||||||
|
},
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let sendLights = {
|
let sendLights = {
|
||||||
"payload": {
|
"payload": {
|
||||||
"action": "light.turn_off",
|
"action": "light.turn_off",
|
||||||
@ -199,28 +184,6 @@ let sendHoliday = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sendTimer = {
|
|
||||||
"payload": {
|
|
||||||
"action": "timer.start",
|
|
||||||
"target": {
|
|
||||||
"entity_id": timerEntity
|
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"duration": timerDuration
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let sendTimerCancel = {
|
|
||||||
"payload": {
|
|
||||||
"action": "timer.cancel",
|
|
||||||
"target": {
|
|
||||||
"entity_id": timerEntity
|
|
||||||
},
|
|
||||||
"data": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let sendNotifyPhone = {
|
let sendNotifyPhone = {
|
||||||
"payload": {
|
"payload": {
|
||||||
"action": "script.text_notify",
|
"action": "script.text_notify",
|
||||||
@ -298,11 +261,6 @@ node.log("lightsOff: " + lightsOff)
|
|||||||
node.log("holidayMode: " + holidayMode)
|
node.log("holidayMode: " + holidayMode)
|
||||||
node.log("eventCall: " + eventCall)
|
node.log("eventCall: " + eventCall)
|
||||||
if (time === 'night') {
|
if (time === 'night') {
|
||||||
node.log("luxLivingRoom: " + luxLivingRoom)
|
|
||||||
node.log("luxThresholdLivingRoom: " + luxThresholdLivingRoom)
|
|
||||||
node.log("luxStairwell: " + luxStairwell)
|
|
||||||
node.log("luxThresholdStairwell: " + luxThresholdStairwell)
|
|
||||||
node.log("delay: " + delay)
|
|
||||||
node.log("sunsetStatus: " + sunsetStatus)
|
node.log("sunsetStatus: " + sunsetStatus)
|
||||||
}
|
}
|
||||||
if (holidayMode === 'on') {
|
if (holidayMode === 'on') {
|
||||||
@ -324,18 +282,13 @@ if (vacation === 'off') {
|
|||||||
}
|
}
|
||||||
}, 5000)
|
}, 5000)
|
||||||
} else if (time === "night") {
|
} else if (time === "night") {
|
||||||
node.status({fill:"green",shape:"dot",text:"Sunset Flow"})
|
if (triggered === 'off') {
|
||||||
node.send([null,sendAdaptive,null,null])
|
node.status({fill:"green",shape:"dot",text:"Sunset Flow"})
|
||||||
if (holidayMode === 'on') {
|
node.send([null,[sendAdaptive,sendTriggered],null,null])
|
||||||
setTimeout(() => {
|
if (holidayMode === 'on') {
|
||||||
node.send([null,sendHoliday,null,null])
|
setTimeout(() => {
|
||||||
}, 1000)
|
node.send([null,sendHoliday,null,null])
|
||||||
}
|
}, 1000)
|
||||||
if (delay === 'on') {
|
|
||||||
node.send([null,sendTimer,null,null])
|
|
||||||
} else {
|
|
||||||
if (topic === 'lux') {
|
|
||||||
node.send([null,sendTimerCancel,null,null])
|
|
||||||
}
|
}
|
||||||
node.send([null,null,[sendFirstFloorScene,sendSecondFloorScene],sendExtraLights])
|
node.send([null,null,[sendFirstFloorScene,sendSecondFloorScene],sendExtraLights])
|
||||||
if (deskLights === 'on') {
|
if (deskLights === 'on') {
|
||||||
@ -344,6 +297,8 @@ if (vacation === 'off') {
|
|||||||
if (topic != 'manual-trigger') {
|
if (topic != 'manual-trigger') {
|
||||||
node.send([[sendNotifyPhone,sendNotifyTV],null,null,null])
|
node.send([[sendNotifyPhone,sendNotifyTV],null,null,null])
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
node.status({fill:'green',shape:'dot',text:'Sunset Flow (Already Triggered)'})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
weather/rain-window-alert/start.js
Normal file
17
weather/rain-window-alert/start.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const states = global.get('homeassistant.homeAssistant.states')
|
||||||
|
const precipType = states['sensor.home_tempest_precipitation_type'].state
|
||||||
|
const precipIntensity = states['sensor.home_tempest_cloud_sensors_precipitation_intensity'].state
|
||||||
|
|
||||||
|
const typeStatesRaining = ['rain','hail','rain_hail']
|
||||||
|
const intensityStatesRaining = ['very_light','light','moderate','heavy','very_heavy','extreme']
|
||||||
|
|
||||||
|
const isTypeRaining = typeStatesRaining.includes(precipType)
|
||||||
|
const isIntensityRaining = intensityStatesRaining.includes(precipIntensity)
|
||||||
|
|
||||||
|
const isRaining = isTypeRaining || isIntensityRaining
|
||||||
|
|
||||||
|
flow.set('typeStatesRaining', typeStatesRaining)
|
||||||
|
flow.set('intensityStatesRaining', intensityStatesRaining)
|
||||||
|
flow.set('isRaining', isRaining)
|
||||||
|
|
||||||
|
return null
|
41
weather/station_slp.js
Normal file
41
weather/station_slp.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
const states = global.get('homeassistant.homeAssistant.states')
|
||||||
|
const temp_F = states['sensor.home_tempest_temperature'].state
|
||||||
|
const elevation_ft = 693
|
||||||
|
|
||||||
|
// Get the pressure from the payload
|
||||||
|
let pressure_inHg = msg.payload
|
||||||
|
|
||||||
|
if (isNaN(pressure_inHg)) {
|
||||||
|
node.error("Invalid pressure value in msg.payload: " + msg.payload)
|
||||||
|
msg.payload = null
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert pressure from inHg to hPa
|
||||||
|
let pressure_hPa = pressure_inHg * 33.8639
|
||||||
|
|
||||||
|
// Convert temperature to °C
|
||||||
|
let temp_C = (temp_F - 32) * (5 / 9)
|
||||||
|
|
||||||
|
// Convert elevation from feet to meters
|
||||||
|
let elevation_m = elevation_ft / 3.28084
|
||||||
|
|
||||||
|
// Apply the barometric formula
|
||||||
|
let slp = pressure_hPa * Math.pow(
|
||||||
|
1 - ((0.0065 * elevation_m) / (temp_C + (0.0065 * elevation_m) + 273.15)),
|
||||||
|
-5.257
|
||||||
|
)
|
||||||
|
|
||||||
|
// Optional: Convert back to inHg
|
||||||
|
let slp_inHg = slp / 33.8639
|
||||||
|
|
||||||
|
// Round both values
|
||||||
|
slp = Math.round(slp * 100) / 100
|
||||||
|
slp_inHg = Math.round(slp_inHg * 100) / 100
|
||||||
|
|
||||||
|
// Return the SLP value
|
||||||
|
msg.payload = slp_inHg
|
||||||
|
|
||||||
|
node.status({fill:'Success',shape:'dot',text:'green'})
|
||||||
|
|
||||||
|
return msg
|
Reference in New Issue
Block a user