Functions code for Emma's bedroom climate flow
This commit is contained in:
25
climate/emma-bedroom/notifications.js
Normal file
25
climate/emma-bedroom/notifications.js
Normal 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
|
||||
}
|
Reference in New Issue
Block a user