25 lines
741 B
JavaScript
25 lines
741 B
JavaScript
const states = global.get('homeassistant.homeAssistant.states')
|
|
const allowed = states['input_boolean.basement_studio_heat_allowed'].state
|
|
const outsideTemp = states['weather.iron_nerd_weather_station'].attributes.temperature
|
|
const todaysHighTemp = states['sensor.todays_high_temp'].state
|
|
|
|
let power = {}
|
|
|
|
if (todaysHighTemp < 55 || outsideTemp < 40) {
|
|
power = 'on'
|
|
} else {
|
|
power = 'off'
|
|
}
|
|
|
|
if (allowed === 'on') {
|
|
if (power === 'on') {
|
|
node.status({fill:'green',shape:'dot',text:'Heater Needed'})
|
|
node.send(msg,null)
|
|
} else {
|
|
node.status({fill:'red',shape:'ring',text:'Heater Not Needed'})
|
|
node.send(null,msg)
|
|
}
|
|
} else {
|
|
node.status({fill:'red',shape:'ring',text:'Heat Disabled'})
|
|
}
|