Automating Routines Based on Sensors

Kerry Clendinning from The Smarter Home Club explains how to use sensor data to help focus your home automation system.

Your home air conditioning unit has a case of hysteresis. But before you call a repairman or a psychiatrist, rest assured, you need it that way.

Your scripts, routines or “automations” as they are called in Home Assistant might need a little hysteresis as well, especially if you are basing their execution on sensors that interact with the real world. You might’ve even been using hysteresis and didn’t realize it.

So what is it? In your AC thermostat, the temperature you select, say 70˚F actually defines a small range, around 69.5 to 70.5, which will be the “set points” your AC uses to turn on and off the heating or cooling, in order to maintain a temperature close to, but not exactly 70˚. Why shouldn’t it just try to exactly match 70˚ at all times? Glad you asked. If it worked like that it would very quickly come on, cool a tiny bit and then turn back off all throughout the day.

It’s important that the AC comes on and operates for a little while each time, for a lot of reasons. First, the thermostat measures the air temperature only in a very limited space around it. If it came on and changed the temperature just enough to detect that it is back to the set point, there would be little air circulated and much greater variation throughout your house. It’s also bad on the system to run for very short periods of time, starting and stopping motors and stressing the system in other ways. Energy efficiency is yet another reason: It’s more efficient to keep the fans and compressors on for a bit once they are started.

The same thing goes on inside a freezer. Here’s an actual temperature graph showing the compressor cycles and a defrost cycle in my freezer.

Now how does this all relate to automating routines based on sensors?

You might find an automated routine runs too frequently, turning on and off a light or fan in response to a sensor.

Temperature is one thing you might use as a trigger for some routine in a home automation system, and you could model the same sort of dual-setpoint logic as a thermostat. Open the shades at one temperature close them at another, to avoid an oscillation effect that might take place if the shades contribute to changing the temperature in the room. Many other types of sensors might have similar issues. Detecting sunlight to have porch lights go off at dawn, if the lights are near enough to the detector to also register some light.

A second way to add hysteresis is timing. When some threshold is reached or an event is detected, either delay a little and check again… Is it really dusk? Is it still dark now, a minute later? Or react immediately and then hold off for a period of time before either negating or retriggering the same event. These types of hysteresis would be useful, for instance if detecting motion to turn on a closet light. Don’t immediately turn back off just because no motion is sensed.

How the setpoints, thresholds and timing delays work in particular home automation systems are topics for another discussion. If you have questions, jump right in and ask on https://www.facebook.com/groups/smarterhomeclub

SmarterHome.club is the website for our Facebook community, The Smarter Home Club – which is an umbrella for all kinds of smart home technologies – home automation, security, custom electronics, weather stations, alternative energy, you name it. DIY focused.

If you’re interested in joining the Smarter Home Club’s Facebook group, please follow this link:

The Smarter Home Club on Facebook