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 }