Hardware: Intel Q9650 on Dell 0G261D motherboard
OS: Ubuntu 18.04.1 LTS
JRE: OpenJDK 1.8.0_192
OpenHAB 2.5.0
I’m running a z-wave thermostat that overall is working well. However the code isn’t as clean as it could be. I have a number of variables built into the rules:
- The house has an “HVAC Mode” (heating, cooling, hold temp, etc…) that is selected input
- The “HVAC_Time” variable is adjusted by a cron statement, and changes setpoints based on the time of the day (for example, cooler during the night, when heating)
The scheme works well enough, but in order to see if the heating setpoints have been changed I run a cron statement to trigger the rule the rule that writes the setpoint to the thermostat. A portion of the rule is below, which obviously continues with additional cases until I hit the end statement.
The cron is set for 10 seconds currently for testing and I’d like a regular check of the setpoint inputs. But right now the system sends the update command at that interval and it’s clogging up the logs. Not that it’s a huge problem, but this is just not efficient programming.
Any suggestions on how to clean this up? It works really well and I don’t mind keeping it, but there’s always a better way!
rule "HVAC Assign House Heating Setpoints"
when
Time cron "0/10 * * ? * * *"
then
switch HVAC_Time.state {
case "WEEKEND-DAY": {
if (House_HVAC_Mode.state == "1") {
House_Thermostat_Heating_Setpoint.sendCommand(House_Heating_AtHome_Temp.state as Number)
}
else if (House_HVAC_Mode.state == "2") {
House_Thermostat_Cooling_Setpoint.sendCommand(House_Cooling_Away_Temp.state as Number)
}
else if (House_HVAC_Mode.state == "3") {
House_Thermostat_Heating_Setpoint.sendCommand(House_Hold_Temp.state as Number)
}
else if (House_HVAC_Mode.state == "4") {
House_Thermostat_Cooling_Setpoint.sendCommand(House_Hold_Temp.state as Number)
}
}