Mastering Robust Presence Detection: Leveraging Home Assistant's Bayesian Binary Sensors for Unwavering Reliability
- #Home_Assistant
- #Presence_Detection
- #Automation
- #Binary_Sensor
- #Bayesian
- #Reliability
- #Smart_Home

Mastering Robust Presence Detection: Home Assistant's Bayesian Binary Sensors
Reliable presence detection is crucial for a truly smart home. Simple methods often fail, leading to frustrating 'ghost' automations. Home Assistant's Bayesian Binary Sensor offers a powerful solution, combining multiple uncertain observations into a single, highly reliable state using conditional probability.
What are Bayesian Binary Sensors?
Instead of relying on a single sensor's 'on' or 'off' signal, a Bayesian sensor takes several inputs (observations). Each observation is assigned a probability of being 'true' when the desired state (e.g., 'home') is true, and a probability of being 'true' when the desired state is false (a false positive). The sensor continuously updates its belief about the true state based on these probabilities and the current state of all observations.
For example, to determine if someone is 'home': if their phone's Wi-Fi is connected AND a motion sensor triggers, the probability of 'home' skyrockets. If Wi-Fi disconnects AND no motion is detected for a while, 'not home' becomes highly probable.
Setting Up Your Bayesian Binary Sensor
Configure it in your configuration.yaml
. Here's an example for `person.john_doe`:
binary_sensor:
- platform: bayesian
name: John Doe Home Reliable
entity_id: binary_sensor.john_doe_home_reliable
prior_true: 0.5 # Initial probability of being home
probability_threshold: 0.9 # Threshold for 'on' state
observations:
- entity_id: device_tracker.john_doe_phone_wifi
probability_true: 0.9 # Likely connected if home
probability_false: 0.05 # Unlikely connected if not home (false positive)
- entity_id: binary_sensor.john_doe_car_bluetooth
probability_true: 0.8
probability_false: 0.1
- entity_id: binary_sensor.front_door_contact
probability_true: 0.7
probability_false: 0.01
delay_off: "00:05:00" # Impact lasts 5 mins after opening
- entity_id: binary_sensor.living_room_motion
probability_true: 0.6
probability_false: 0.05
delay_off: "00:10:00" # Impact lasts 10 mins after motion
Key Parameters:
prior_true
: Initial probability of true state. Adjust if your person is typically home more often.probability_threshold
: Probability above which the sensor turnson
. Higher for more certainty.observations
: List of input entities.probability_true
: Likelihood observation is 'on' GIVEN target state is true. Should be high.probability_false
: Likelihood observation is 'on' GIVEN target state is false (false positive). Should be low.delay_on
/delay_off
: Extends observation's influence after its state changes (useful for momentary sensors like motion).
Choosing and Fine-tuning Observations
Effectiveness hinges on diverse, quality observations and accurate probability estimates.
Good Observation Candidates:
- Wi-Fi Device Trackers: Router, Home Assistant Companion App.
- Bluetooth LE Scanners: ESPHome, Passive BLE monitor.
- Door/Window Sensors: Momentary events (use
delay_off
). - Motion Sensors: Especially in common areas (use
delay_off
). - NFC Tags/Readers: Manual tap-in/out.
- Car Presence: Car's Wi-Fi, Bluetooth, or specific integrations.
Estimating Probabilities:
Start with reasonable estimates and refine. Ask yourself:
- "If I am home, how likely is this sensor to be ON?" (
probability_true
) - "If I am not home, how likely is this sensor to be ON (a false positive)?" (
probability_false
)
Tips: Observe the sensor's behavior. If it's often wrong, adjust the probabilities of contributing observations. Use Developer Tools -> States to debug.
Best Practices for a Robust Presence Ecosystem
- Diversify Inputs: Combine Wi-Fi, Bluetooth, physical sensors for best results.
- Use Person Entities: Assign the Bayesian sensor to your
person
entity for seamless integration with existing automations. - Monitor & Debug: Regularly check sensor states in Developer Tools to understand behavior.
- Graceful Degradation: Design automations to have fallback behaviors if presence detection temporarily fails.
Conclusion
The Bayesian Binary Sensor is a powerful, yet often overlooked, tool for achieving highly accurate and reliable presence detection in Home Assistant. By intelligently combining multiple imperfect signals, you can build a smart home that truly understands your comings and goings, leading to more responsive automations and a seamless user experience. Invest the time to implement this, and elevate your smart home's intelligence!

NGC 224
Author bio: