33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
const topic = msg.topic
|
|
const nightTemp = msg.nighttemp
|
|
const acMode = msg.acmode
|
|
const fanMode = msg.fanmode
|
|
|
|
let coolMsg = {
|
|
"payload": 'Master bedroom AC temp has been set to ' + nightTemp + '°F as scheduled',
|
|
"topic": 'AC Mode: Cooling'
|
|
}
|
|
let fanOnlyMsg = {
|
|
"payload": 'Too cold outside, AC running fan only.',
|
|
"topic": "AC Mode: Fan Only"
|
|
}
|
|
let fanSchedMsg = {
|
|
"payload": 'Master bedroom fan has been activated as scheduled.',
|
|
"topic": 'Fan Schedule Activated'
|
|
}
|
|
|
|
if (topic === 'mrbedroom-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 if (topic === 'mrbedroom-fan' && fanMode === 'Fan') {
|
|
node.status({fill:"green",shape:"dot",text:"Fan Schedule"})
|
|
return fanSchedMsg
|
|
} else {
|
|
node.status({fill:"red",shape:"ring",text:"Notification not sent"})
|
|
return null
|
|
} |