Area Occupancy Detection Simulator
This simulator lets you interactively explore how sensor states, weights, and prior probabilities affect occupancy calculations. It uses the exact same Python code that runs in your Home Assistant integration, ensuring calculations match exactly what happens in your actual setup.
Getting Started
Step 1: In Home Assistant, run the "Run Analysis" service for your area(s). This generates YAML output with all your sensors, their states, likelihoods, and current probability calculations.
Step 2: Copy the entire YAML output from the service call and paste it into the "Service YAML Input" text area below.
Step 3: Click "Load Simulation" to send the data to the simulator server. The simulator will populate with your sensors, current states, and all configuration values.
Step 4: If your analysis output contains multiple areas, use the Area dropdown to switch between them.
Understanding the Interface
Header Section
- Area Name: The name of the currently selected area
- Probability Value: The calculated occupancy probability (0-100%)
- Probability Bar: Visual representation of the current probability
- Probability Chart: Time-series graph showing how probability changes over time as you interact with sensors
Sensors Section
Each sensor card displays:
- Sensor Name: Friendly name or entity ID
- Current State: The sensor's current value or state
- Type & Weight: Sensor type (motion, media, door, etc.) and its weight in calculations
- Likelihood Values: P(active|occupied) and P(active|vacant) probabilities
- Controls:
- Binary Sensors: Toggle switch or buttons to set active/inactive states
- Numeric Sensors: Input field to enter temperature, humidity, illuminance, or other numeric values
- Metrics: Contribution (how much this sensor affects probability), Likelihood, and Decay Factor (if sensor is decaying)
Prior Probabilities Section
- Global Prior: Base probability that the area is occupied, independent of time or sensor evidence
- Time Prior: Learned probability based on schedules or historical activity patterns
- Combined Prior: Weighted combination of global and time priors
- Final Prior: Effective prior after Bayesian factor and clamping are applied
- Area Purpose: Select a purpose (Social, Work, Rest, etc.) to auto-populate decay settings
- Half-life: Time in seconds for sensor evidence to decay by 50% when inactive
Entity Type Weights Section
Adjust the weight (influence) of each sensor type on the overall probability calculation:
- Motion: Motion sensors (default: 1.0)
- Media: Media players (default: 0.85)
- Appliance: Appliances (default: 0.4)
- Door: Door sensors (default: 0.3)
- Window: Window sensors (default: 0.2)
- Illuminance: Light level sensors (default: 0.1)
- Humidity: Humidity sensors (default: 0.1)
- Temperature: Temperature sensors (default: 0.1)
Higher weights mean that sensor type has more influence on the final probability. Weights apply to all sensors of that type.
What You Can Do
- Toggle Binary Sensors: Use switches or buttons to change motion, door, window, and appliance states. See immediate probability updates.
- Adjust Numeric Sensors: Enter new values for temperature, humidity, or illuminance sensors to see how they affect probability.
- Modify Entity Type Weights: Use sliders to change how much each sensor type contributes. Changes apply to all sensors of that type.
- Experiment with Priors: Adjust global and time priors to see how base probabilities affect calculations.
- Change Area Purpose: Select different purposes to see how decay settings change based on area type.
- Observe Decay: When sensors become inactive, watch how their evidence decays over time based on the half-life setting.
- View Detailed Metrics: See likelihood, contribution, and decay factors for each sensor to understand its impact.
- Track Changes: The probability chart shows the last 30 updates, helping you visualize how probability evolves.
- Switch Between Areas: If your analysis contains multiple areas, use the Area dropdown to simulate different areas.
How It Works
The simulator uses a stateless architecture where each interaction sends the current configuration to a server running the actual Python code from the Area Occupancy Detection integration. This ensures:
- Calculations match exactly what happens in Home Assistant
- You can test different scenarios and configurations before implementing them
- You can understand how each sensor, weight, and prior affects the final probability
- The probability chart provides a visual history of changes
- Real-time updates occur automatically every second, or immediately when you change a control
Tips
- The API Status badge shows whether the simulator server is online and responding.
- Sensor contributions show positive values when the sensor increases probability and negative values when it decreases probability.
- Decay factors apply when sensors transition from active to inactive, gradually reducing their influence over time.
- All changes are calculated in real-time, so you get immediate feedback on how your configuration behaves.
- The simulator preserves your YAML data when switching between areas, so you can easily compare different areas from the same analysis.