Files

25 lines
932 B
JavaScript

const states = global.get('homeassistant.homeAssistant.states')
const enabled = states['input_boolean.emma_alarm_clock'].state
const sleeping = states['input_boolean.emma_sleeping'].state
const goodnight = states['input_boolean.goodnight'].state
msg.topic = "emma_bedroom"
msg.payload = "This is your alarm clock speaking, it is time to wake up!"
msg.type = "alert"
if (enabled === 'on' && sleeping === 'on' && goodnight === 'off') {
node.status({fill:"green",shape:"dot",text:"Proceed"})
return msg
} else if (enabled === 'off') {
node.status({fill:"red",shape:"ring",text:"Disabled"})
return null
} else if (sleeping === 'off') {
node.status({fill:"red",shape:"ring",text:"Not Sleeping"})
return null
} else if (goodnight === 'off') {
node.status({fill:"red",shape:"ring",text:"Goodnight On"})
return null
} else {
node.status({fill:"red",shape:"ring",text:"Unknown Error"})
return null
}