Functions code for Emma's bedroom climate flow

This commit is contained in:
2025-03-28 21:35:05 -04:00
parent 71db65fca2
commit 02ce030fe7
5 changed files with 516 additions and 0 deletions

View File

@ -0,0 +1,25 @@
const topic = msg.topic
const nightTemp = msg.nighttemp
const acMode = msg.acmode
let coolMsg = {
"payload": `Emma bedroom AC temp has been set to ${nightTemp} °F as scheduled`,
"topic": 'Emma AC Mode: Cooling'
}
let fanOnlyMsg = {
"payload": 'Mildly chilly outside, AC running fan only.',
"topic": "Emma AC Mode: Fan Only"
}
if (topic === 'emmabedroom-cooling') {
if (acMode === 'AC') {
node.status({fill:"green",shape:"dot",text:"AC Cooling"})
return coolMsg
} else if (acMode === 'Fan') {
node.status({fill:"green",shape:"dot",text:"AC Fan Only"})
return fanOnlyMsg
}
} else {
node.status({fill:"red",shape:"ring",text:"Notification not sent"})
return null
}