The ‘bee in a box’ algorithm enables you to detect presence in a given area of your smart home. It will enable your smart home system to know whether in a given area anybody is present or not. No special sensors or other additional hardware is required to do so.
Bee in a box algorithm: The theory
Imagine somebody handing you over a small box made out of cardboard. On the top side of the box, there is a yellow warning symbol ‘Warning: there might be a bee inside’.
There is no way to see inside the box. You also don’t want to open it, since it could result in a painful sting. So how would you know wether in your particular box, there is really a bee inside?
The answer is pretty simple: You listen for the bee huming!
In case you have heard the bee huming, and the box was not opened since you heard it, you can consider the bee to be still in the box. This easy principle can also be applied to your smart home!
Bee in a box Person in a room algorithm: How to use for precence detection
Transfering the ‘bee in a box’ algorithm to a smart home environment is farly simple:
- The bee equals any person
- The cardbox containing the bee is any area in your smart home. Could be a single room, your flat or even the whole house
- The huming sound is in reality any interaction with a triggered sensor or actor
Lets assume a very simple smart home setup: You have a flat with a single smart light attached to your Home Assistant (or any other) smart home system. Any person switching the light on or off will let your smart home server know that there is somebody in the flat. Adding a door sensor to the main door, will make sure the system knows that somebody could potentially have left the flat.
Thats all you need: Presence detection with just a door sensor and a light switch!
Presence detection with ‘bee in a box’ algorithm summarized
- Assume nobody is present
- When any sensor in the room was triggered, assume somebody is present
- In case the room door was opened, go back to state 1.)
The above states could easily be implemented as automation rules in your smart home server. For Homeassistant such a setup can utilize the input_boolean Integration to hold the state of whether there was precence detected within a room or not.
Extended presence detection
However, the algorithm described here allows you to detect wether anybody is present in a given room, it cannot determine which person is present. To do so, there are other alternatives which might be subject of a future blog post.
Until then, you might use the ‘bee in a box’ at least for simple scenarios such as ‘switch the lights off when nobody is in the room’.