Odd behavior with ThermController when Weighted Average is 0

I have rules to set a temp sensor's weight variable to 0 when its temp above the thermcontroller's setpoint. So when all sensor weights are 0, the thermcontroller shows the weighted average of 0. But the thermcontroller temp, which should match the weighted average, doesn't show a zero but shows a different value... perhaps the last value before the weighted average became zero?


Also: why does the weighted average box always show a 'Not used'?


My concern is that the thermcontroller temp will be stuck at a threshold that will keep the heat on forever.

Is it a bug that the temp of the thermcontroller is not 0? Perhaps the thermcontroller should set the controlled thermostat to idle if the weighted average is zero or if it loses access to all temp sensors.

LOL.

I'm sure that as this app was developed the situation you are describing was never contemplated, given that sensor weight is a multiplicand in determining the average temperature of all of the sensors, as well as indirectly the divisor in that calculation. There had to be some protection against division by zero, which there is, so it does get to 0/0, but returns 0/1. Further to that, a descriptive string about the weights applied to sensors is built up sensor by sensor, and in the case of a variable weight whose value is zero, that sensor makes no contribution to the string (or to the calculation). When the entire descriptive string becomes empty due to every variable no longer contributing to the average (your case), the empty string matches the circumstance of there being no sensors at all, hence "not used". Now if more tests were performed to determine that a degenerate condition exists where no sensors are being used to compute the average (your case), then it could perhaps say "no average determinable" or some such thing. Effectively it's the same as that, only worse. It's worse because the entire concept of the app is that there must be a valid sensor value for it to even function. But by causing or allowing every weight variable to become zero, this has effectively reduced the app to meaninglessness, where control isn't possible since there is no control value. So, yeah, it's not going to function in any particular way in that circumstance. Garbage in garbage out.

I have no idea what you think the right thing for it do is in this circumstance. But from my perspective you've left the reasonable usage / design envelope and there is nothing meaningful it can do -- so why bother? Perhaps you need a rule that senses this condition and does whatever it is you think should happen, because there's no way Thermostat Controller should be expected to do anything specific when it has invalid inputs.

All sensor weights = 0 --> invalid inputs. How would you expect a thermostat to behave that has its temperature sensor removed?

Go into the UI of the app, and see what happens if you try to put a 0 in for the weight for any sensor. Hit Done on the weight page to see the result on the main page.

Sorry, but I'm not presenting rare scenarios to test your code. You have given use two ways to control the weighted average:

  • Manually or with rules to add/remove sensors from ThermController
  • Manually or with weight variables to essentially enable/disable the sensors connected to the ThermController

So all on and all off are possible scenarios that can happen. I have chosen to use the weight variable for each sensor to enable/disable them so they no longer influence the thermostat. Each temp sensor has a rule to change the weight between 0 (disabled) and 1 (enabled):

  • Disable when someone is no longer using the room, either by schedule or presence
  • Disable when the temperature of the room is already above the thermcontroller heating setpoint, removing it from the average calculation so more focus is on the sensors with temperatures still below the setpoint.

So when all sensors are above the heating setpoint, they will all have a weight of zero and hence the divide by zero doomsday scenario.

I decided to use the weight variable instead of adding/removing sensors because it makes it easier to account for multiple factors:
eg:
conditionA (1 or 0)
conditionB (1 or 0)
conditionB (1 or 0)
weight = conditionA x conditionB x conditionC

Finally, if the ThermController is meant to control the thermostat to make it turn on or off related heating devices, then if the ThermController finds itself in a useless state, would it be reasonable to have an option to have it make the thermostat stop the heating devices that it started and not let it run uncontrolled? If it stops heating, then eventually at least one of the sensor temperature will be below the setpoint and it'll enable itself and then the thermcontroller wil again have non-zero readings.

I guess I could have my rules add up all the sensor weights and if zero, set the thermcontroller thermostat mode to off and to auto if otherwise.

You just have to not create a situation where every weight variable is zero at the same time. This really has nothing to do with Thermostat Controller other than creating an invalid circumstance. With the power of things like variables for weights comes the responsibility of making sure that there is a valid set of weights, or like you say, intervening to control what should happen in the circumstance that there is not a valid set.

Thanks for the feedback. I'm now tracking the number of enabled sensors per controller and if it's zero, the thermcontroller is set to Off.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.