Replace all "var" usage with const and/or let

This commit is contained in:
2024-02-13 13:59:21 -05:00
parent c70268b854
commit e666b306fa
13 changed files with 263 additions and 20 deletions

View File

@ -0,0 +1,17 @@
const states = global.get('homeassistant.homeAssistant.states')
const enabled = states['input_boolean.emma_alarm_clock'].state
const sleeping = states['input_boolean.emma_sleeping'].state
if (enabled === 'on' && sleeping === '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 === 'on') {
node.status({fill:"red",shape:"ring",text:"Sleeping"})
return null
} else {
node.status({fill:"red",shape:"ring",text:"Unknown Error"})
return null
}

View File

@ -0,0 +1,25 @@
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
}

View File

@ -0,0 +1,17 @@
const states = global.get('homeassistant.homeAssistant.states')
const enabled = states['input_boolean.kallen_alarm_clock'].state
const sleeping = states['input_boolean.kallen_sleeping'].state
if (enabled === 'on' && sleeping === '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 === 'on') {
node.status({fill:"red",shape:"ring",text:"Sleeping"})
return null
} else {
node.status({fill:"red",shape:"ring",text:"Unknown Error"})
return null
}

View File

@ -0,0 +1,25 @@
const states = global.get('homeassistant.homeAssistant.states')
const enabled = states['input_boolean.kallen_alarm_clock'].state
const sleeping = states['input_boolean.kallen_sleeping'].state
const goodnight = states['input_boolean.goodnight'].state
msg.topic = "kallen_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
}

View File

@ -0,0 +1,17 @@
const states = global.get('homeassistant.homeAssistant.states')
const enabled = states['input_boolean.master_bedroom_alarm_clock'].state
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
if (enabled === 'on' && sleeping === '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 === 'on') {
node.status({fill:"red",shape:"ring",text:"Sleeping"})
return null
} else {
node.status({fill:"red",shape:"ring",text:"Unknown Error"})
return null
}

View File

@ -0,0 +1,25 @@
const states = global.get('homeassistant.homeAssistant.states')
const enabled = states['input_boolean.master_bedroom_alarm_clock'].state
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
const goodnight = states['input_boolean.goodnight'].state
msg.topic = "master_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
}