How to write a reliable thermostat function ?
Posted: Fri Mar 17, 2023 9:45 am
I have been studying the guides for temperature control.
To make a thermostat I need one virtual device to turn the function on/off, and at least 4 events:
- Turn heater on when temp falls
- Turn heater off when temp rises
- Turn heater on when function is activated and temp *is* below
- Turn heater off when function is deactivated
But as the event system only triggers on the temp *passing* the threshold, this can't be trusted.
If the server is not online when the event occurs, the heater will not be activated or stay activated - I have seen both.
For increased safety I have added another event to turn the heater on if the temperature falls even lower.
And as I saw this morning, I also should have added another event to turn the heater off when the temp rises too high.
Taking this even further, I could end up adding a lot of events just to make sure.
I am quite surprised that a reliable thermostat function is not a basic element...
To make a thermostat I need one virtual device to turn the function on/off, and at least 4 events:
- Turn heater on when temp falls
- Turn heater off when temp rises
- Turn heater on when function is activated and temp *is* below
- Turn heater off when function is deactivated
But as the event system only triggers on the temp *passing* the threshold, this can't be trusted.
If the server is not online when the event occurs, the heater will not be activated or stay activated - I have seen both.
For increased safety I have added another event to turn the heater on if the temperature falls even lower.
And as I saw this morning, I also should have added another event to turn the heater off when the temp rises too high.
Taking this even further, I could end up adding a lot of events just to make sure.
I am quite surprised that a reliable thermostat function is not a basic element...