From e53e6ab5f270f6f43a1bfac45542e945ba2c3adb Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 11 Mar 2025 02:00:49 -0400 Subject: [PATCH] Improve logic for when basement heater is needed --- climate/basement/basement_on.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 climate/basement/basement_on.js diff --git a/climate/basement/basement_on.js b/climate/basement/basement_on.js new file mode 100644 index 0000000..3f4401e --- /dev/null +++ b/climate/basement/basement_on.js @@ -0,0 +1,24 @@ +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'}) +}