Compare commits

..

3 Commits

View File

@@ -1,15 +1,30 @@
const states = global.get('homeassistant.homeAssistant.states')
const sleeping = states['input_boolean.emma_sleeping'].state
if (sleeping !== 'on') {
// Check if all settings support aircon usage
const ac = global.get('emmaBedroom.aircon.installed', "diskCon")
const allowed = states['input_boolean.emma_bedroom_climate_protocol'].state
const schedMode = states['input_select.scheduled_climate_mode_emma_bedroom'].state
const coolingActive = states["input_boolean.emma_bedroom_cooling_on"].state
const sleeping = states["input_boolean.emma_sleeping"].state
let proceed = false
if (ac === 'on' && allowed === 'on' && schedMode === 'AC' && coolingActive === 'on') {
proceed = true
}
if (sleeping != 'on') {
node.status({fill:'red',shape:'ring',text:'Emma not sleeping, watchdog disabled'})
return null
} else if (proceed === false) {
node.status({fill:'red',shape:'ring',text:'Aircon not in use, watchdog disabled'})
return null
}
const airconEntity = ['climate.emma_bedroom_aircon']
// Gather relevant attributes from the aircon entity
const airconEntity = ['climate.emma_bedroom_aircon']
const airconState = msg.payload.state
const airconAttributes = msg.payload.attributes
const airconEco = airconAttributes['eco_mode']