Replace all "var" usage with const and/or let
This commit is contained in:
17
alarm-clocks/emma-bedroom/processing-end.js
Normal file
17
alarm-clocks/emma-bedroom/processing-end.js
Normal 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
|
||||
}
|
25
alarm-clocks/emma-bedroom/processing.js
Normal file
25
alarm-clocks/emma-bedroom/processing.js
Normal 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
|
||||
}
|
17
alarm-clocks/kallen-bedroom/processing-end.js
Normal file
17
alarm-clocks/kallen-bedroom/processing-end.js
Normal 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
|
||||
}
|
25
alarm-clocks/kallen-bedroom/processing.js
Normal file
25
alarm-clocks/kallen-bedroom/processing.js
Normal 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
|
||||
}
|
17
alarm-clocks/master-bedroom/processing-end.js
Normal file
17
alarm-clocks/master-bedroom/processing-end.js
Normal 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
|
||||
}
|
25
alarm-clocks/master-bedroom/processing.js
Normal file
25
alarm-clocks/master-bedroom/processing.js
Normal 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
|
||||
}
|
90
climate/master-bedroom/shower-off.js
Normal file
90
climate/master-bedroom/shower-off.js
Normal file
@ -0,0 +1,90 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const ac = states['input_boolean.master_bedroom_aircon_installed'].state
|
||||
const temp = global.get('tempStr')
|
||||
const threshold = states['input_number.master_bedroom_aircon_run_threshold'].state
|
||||
const dayTemp = states['input_number.master_bedroom_daytime_temp'].state
|
||||
const nightTemp = states['input_number.master_bedroom_night_temp'].state
|
||||
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
|
||||
const currentSetTemp = states['climate.master_bedroom_aircon'].attributes.temperature
|
||||
const coolingTime = states['input_boolean.master_bedroom_cooling_on'].state
|
||||
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
|
||||
const hotDay = states['input_boolean.hot_day'].state
|
||||
const topic = msg.topic
|
||||
|
||||
let setTemp = {}
|
||||
let ecoMode = {}
|
||||
let duration = {}
|
||||
let end = {}
|
||||
let hvac = {}
|
||||
|
||||
if (topic === 'toggle') {
|
||||
if (hotDay === 'on' || sleeping === 'on') {
|
||||
setTemp = bedTemp
|
||||
ecoMode = 'none'
|
||||
} else {
|
||||
setTemp = nightTemp
|
||||
ecoMode = 'eco'
|
||||
}
|
||||
} else if (topic === 'timer') {
|
||||
if (currentSetTemp == bedTemp) {
|
||||
setTemp = nightTemp
|
||||
if (hotDay === 'on') {
|
||||
ecoMode = 'none'
|
||||
} else {
|
||||
ecoMode = 'eco'
|
||||
}
|
||||
} else {
|
||||
setTemp = dayTemp
|
||||
ecoMode = 'eco'
|
||||
}
|
||||
}
|
||||
|
||||
if (setTemp == bedTemp) {
|
||||
duration = 3600
|
||||
} else if (setTemp == nightTemp && hotDay === 'off') {
|
||||
duration = 3600
|
||||
} else {
|
||||
duration = 1800
|
||||
}
|
||||
|
||||
if (setTemp == dayTemp) {
|
||||
end = true
|
||||
if (hotDay === 'off') {
|
||||
hvac = 'off'
|
||||
} else {
|
||||
hvac = 'cool'
|
||||
}
|
||||
} else if (setTemp != bedTemp && coolingTime === 'on') {
|
||||
end = true
|
||||
hvac = 'cool'
|
||||
} else {
|
||||
end = false
|
||||
hvac = 'cool'
|
||||
}
|
||||
|
||||
let setMsg = {
|
||||
"set": setTemp,
|
||||
"eco": ecoMode,
|
||||
"hvac": hvac,
|
||||
"end": end
|
||||
}
|
||||
|
||||
let timerStart = {
|
||||
"duration": duration
|
||||
}
|
||||
|
||||
if (ac === 'on' && temp >= threshold) {
|
||||
if (sleeping === 'on' || coolingTime === 'on' || end === true) {
|
||||
node.status({fill:"green",shape:"dot",text:"Finished"})
|
||||
return [setMsg, null]
|
||||
} else {
|
||||
node.status({fill:"blue",shape:"dot",text:"Next Cycle"})
|
||||
return [setMsg, timerStart]
|
||||
}
|
||||
} else if (ac === 'off') {
|
||||
node.status({fill:"red",shape:"ring",text:"A/C Not Installed"})
|
||||
return null
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Too Cold"})
|
||||
return null
|
||||
}
|
27
climate/master-bedroom/shower-on.js
Normal file
27
climate/master-bedroom/shower-on.js
Normal file
@ -0,0 +1,27 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const ac = states['input_boolean.master_bedroom_aircon_installed'].state
|
||||
const temp = global.get('tempStr')
|
||||
const threshold = states['input_number.master_bedroom_aircon_run_threshold'].state
|
||||
const nightTemp = states['input_number.master_bedroom_night_temp'].state
|
||||
const bedTemp = states['input_number.master_bedroom_bedtime_temp'].state
|
||||
const sleeping = states['input_boolean.master_bedroom_sleeping'].state
|
||||
|
||||
if (ac === 'on') {
|
||||
if (temp >= threshold) {
|
||||
if (sleeping === 'on') {
|
||||
msg.set = bedTemp
|
||||
node.status({fill:"green",shape:"dot",text:"Shower Mode On: " + bedTemp})
|
||||
return msg
|
||||
} else {
|
||||
msg.set = nightTemp
|
||||
node.status({fill:"green",shape:"dot",text:"Shower Mode On: " + nightTemp})
|
||||
return msg
|
||||
}
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"Too Cold"})
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
node.status({fill:"red",shape:"ring",text:"A/C Not Installed"})
|
||||
return null
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
var states = global.get('homeassistant.homeAssistant.states')
|
||||
var room = states['input_select.kallen_activity_room'].state
|
||||
var activity = states['input_select.kallen_activities'].state
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const room = states['input_select.kallen_activity_room'].state
|
||||
const activity = states['input_select.kallen_activities'].state
|
||||
|
||||
msg.topic = room
|
||||
msg.activity = activity
|
||||
|
@ -1,8 +1,8 @@
|
||||
var states = global.get('homeassistant.homeAssistant.states')
|
||||
var room = states['input_select.kallen_activity_room'].state
|
||||
var activity = states['input_select.kallen_activities'].state
|
||||
var minutes = states['sensor.kallen_timer_remaining_minutes'].state
|
||||
var seconds = states['sensor.kallen_timer_remaining_seconds'].state
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const room = states['input_select.kallen_activity_room'].state
|
||||
const activity = states['input_select.kallen_activities'].state
|
||||
const minutes = states['sensor.kallen_timer_remaining_minutes'].state
|
||||
const seconds = states['sensor.kallen_timer_remaining_seconds'].state
|
||||
|
||||
msg.room = room
|
||||
msg.activity = activity
|
||||
|
@ -1,8 +1,8 @@
|
||||
var states = global.get('homeassistant.homeAssistant.states')
|
||||
var room = states['input_select.kallen_activity_room'].state
|
||||
var activity = states['input_select.kallen_activities'].state
|
||||
var minutes = states['sensor.kallen_timer_remaining_minutes'].state
|
||||
var seconds = states['sensor.kallen_timer_remaining_seconds'].state
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const room = states['input_select.kallen_activity_room'].state
|
||||
const activity = states['input_select.kallen_activities'].state
|
||||
const minutes = states['sensor.kallen_timer_remaining_minutes'].state
|
||||
const seconds = states['sensor.kallen_timer_remaining_seconds'].state
|
||||
|
||||
msg.room = room
|
||||
msg.activity = activity
|
||||
|
@ -1,4 +1,4 @@
|
||||
var readout = msg.duration
|
||||
const readout = msg.duration
|
||||
|
||||
msg.duration = +readout.toFixed(0)
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
var states = global.get('homeassistant.homeAssistant.states')
|
||||
var room = states['input_select.kallen_activity_room'].state
|
||||
var activity = states['input_select.kallen_activities'].state
|
||||
var controlLights = states['input_boolean.kallen_timer_control_lights'].state
|
||||
var duration = states['input_number.kallen_activity_duration'].state
|
||||
var fixDuration = parseFloat(duration)
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const room = states['input_select.kallen_activity_room'].state
|
||||
const activity = states['input_select.kallen_activities'].state
|
||||
const controlLights = states['input_boolean.kallen_timer_control_lights'].state
|
||||
const duration = states['input_number.kallen_activity_duration'].state
|
||||
const fixDuration = parseFloat(duration)
|
||||
|
||||
msg.room = room
|
||||
msg.activity = activity
|
||||
|
Reference in New Issue
Block a user