Play wakeup briefing in master bedroom

This commit is contained in:
2023-10-10 12:33:30 -04:00
parent 237041de10
commit 31d29146d5

View File

@ -39,6 +39,8 @@ let time = []
let type = msg.type
let topic = msg.topic
let echoDotService = []
let setBriefing = []
let setBriefingDelay = []
node.log("Master Bedroom Climate: Variables Defined")
// Sleep Switch Handling
@ -62,10 +64,23 @@ if (topic === 'mrbedroom-wakeup') {
setSleep = 'turn_off'
}
// Setup TTS briefing
if (time === 'day') {
setBriefing = "master_bedroom_wakeup_briefing"
if (topic === 'mrbedroom-wakeup') {
setBriefingDelay = 60
} else if (type === 'sleep' && payload === 'off') {
setBriefingDelay = 15
}
}
// Day Time
if (time === 'day') {
if (type === 'auto') {
setCool = 'turn_off'
setBriefingDelay = 60
} else if (type === 'manual') {
setBriefingDelay = 15
}
if (earlyNight === 'off') {
setFan = "turn_off"
@ -207,6 +222,14 @@ let notify = {
"fanmode": fanMode
}
let sendBriefing = {
"payload": {
"domain": "script",
"service": setBriefing
},
"delay": setBriefingDelay
}
let sendHvac = {
"payload": {
"domain": "climate",
@ -281,7 +304,9 @@ node.log("setHvac: " + setHvac)
node.log("setFan: " + setFan)
node.log("setCool: " + setCool)
node.log("setSleep: " + setSleep)
node.log("setDisplay " + setDisplay)
node.log("setDisplay: " + setDisplay)
node.log("setBriefing: " + setBriefing)
node.log("setBriefingDelay: " + setBriefingDelay)
node.log("time: " + time)
node.log("type: " + type)
node.log("topic: " + topic)
@ -290,7 +315,7 @@ node.log("----- Master Bedroom Climate: End Parameters -----")
// If this was an automated trigger, set the cooling context for the bedroom accordingly.
if (type === 'auto' && time != 'bedtime') {
node.send([null, null, sendCool, null])
node.send([null, null, sendCool, null, null])
node.log("Master Bedroom Climate: Cooling Context Set")
}
@ -303,35 +328,36 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
} else {
if (topic === 'mrbedroom-cooling' && ac === 'on') {
node.status({ fill: "green", shape: "dot", text: "Cooling Schedule" })
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null])
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.log("Master Bedroom Climate: Auto/Cooling")
} else if (topic === 'mrbedroom-bedtime') {
node.status({ fill: "green", shape: "dot", text: "Bedtime" })
node.log("Master Bedroom Climate: Auto/Bedtime")
if (ac === 'on') {
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], 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') {
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([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
node.log("Master Bedroom Climate: Auto/Wakeup/AC On")
}
} else if (sleeping === 'on') {
node.send([null, null, sendSleep, null])
node.send([null, null, sendSleep, null, null])
node.log("Master Bedroom Climate: Auto/Wakeup/Sleep On")
}
}
@ -341,26 +367,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([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], 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([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], 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([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
node.log("Master Bedroom Climate: Manual/Bedtime/AC")
}
}
@ -368,7 +394,7 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
node.log("Master Bedroom Climate: Sleep")
if (time === 'night') {
node.status({ fill: "blue", shape: "dot", text: "Wakeup (Hot Day)" })
node.send([null, sendFan, sendEchoDotDND, null])
node.send([null, sendFan, sendEchoDotDND, null, null])
node.log("Master Bedroom Climate: Sleep/Night")
if (ac === 'on') {
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
@ -376,18 +402,18 @@ if (type === 'auto' && allowed === 'on' && meltdown === 'off' && vacation === 'o
}
} else if (time === 'day') {
node.status({ fill: "blue", shape: "dot", text: "Wakeup" })
node.send([null, sendFan, sendEchoDotDND, null])
node.send([null, sendFan, sendEchoDotDND, null, sendBriefing])
node.log("Master Bedroom Climate: Sleep/Day")
if (ac === 'on') {
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
node.log("Master Bedroom Climate: Sleep/Day/AC")
}
} else if (time === 'bedtime') {
node.status({ fill: "blue", shape: "dot", text: "Sleep" })
node.send([null, sendFan, sendEchoDotDND, null])
node.send([null, sendFan, sendEchoDotDND, null, null])
node.log("Master Bedroom Climate: Sleep/Bedtime")
if (ac === 'on') {
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null])
node.send([[sendDisplay, sendHvac, sendTemp, sendEco, sendAcFan], null, null, null, null])
node.log("Master Bedroom Climate: Sleep/Bedtime/AC")
}
}