Files
HA-NerdFlows-Functions/climate/master-bedroom/shower-on.js

28 lines
1.0 KiB
JavaScript

const states = global.get('homeassistant.homeAssistant.states')
const ac = global.get('masterBedroom.aircon.installed', "diskCon")
const temp = global.get('outdoorTemp.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
}