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,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
}