Beyond Occupancy: Design Retrospective — How the Architecture Evolved

Edit — 2026-11-28: Added the diagrams I forgot to include in the original post and made a few minor formatting adjustments.


This article was prepared with the assistance of ChatGPT in organizing, writing, and translating my ideas.

Introduction

I know the original Beyond Occupancy article is quite long and may not be easy to read in its entirety. In this retrospective, I’d like to share the journey behind the architecture, explaining what problems led to each mechanism and how the solutions gradually evolved. By connecting these experiences to the relevant sections of the original article, I hope to make it easier to navigate the original content and apply individual mechanisms where they might be useful. Also, as time permits, I’d also like to share some of the individual implementations, along with explanations of how they work and how they can be used independently.

Looking back, Beyond Occupancy was not designed as a complete architecture from the beginning. It emerged from several initially independent attempts to solve practical problems, followed by two major architectural revisions.

The resulting architecture distinguishes three forms of presence: Filtered Presence (F), which represents managed sensor observations; Internal Presence (IP), which retains an inferred spatial state; and Effective Presence (EP), which provides the state consumed by downstream automations. However, these distinctions only became apparent as I encountered the limitations of earlier solutions.

The Origins of Active Refresh

Active Refresh originated from an observed behavior of the presence sensors: under certain conditions, they could remain ON for considerably longer than their configured occupancy timeout. Experimenting with physical resets and MQTT setting commands revealed that these interventions could sometimes restore normal sensor behavior. This eventually led to the sensitivity bump mechanism, initially used as a manual recovery tool. (Reference: Section 5.2 — Sensitivity Bump)

At this point, there was no spatial presence inference. Refresh was simply a practical way to recover an unreliable device.

When Devices Interfered with Their Own Observations

Filtered Presence originated from an interaction between automatic curtains and presence-based lighting. Curtain movement could occasionally trigger a false presence detection, causing lights to turn on in an empty room. However, simply ignoring sensor changes during curtain movement introduced another problem: genuine occupancy changes could also occur during that period.

This led to the use of interference windows, observation retention, and the reuse of Active Refresh to help obtain a new observation after the interference ended. Rather than treating every curtain movement as a reason to refresh the sensor, the system could intervene when an observation actually changed within the relevant interference window. (Reference: Sections 3.1 and 3.3 — Known Interference and Refresh-Induced Interference)


Figure 1. From interference-induced false detection to observation management. Illustrative sensor states, not recorded measurements.

Zigbee2MQTT interruptions introduced another requirement: preserving observation continuity when sensors temporarily became unavailable. Filtered Presence gradually evolved from interference filtering into a mechanism for managing the validity and continuity of observations. (Reference: Section 3.2 — Unavailable Does Not Mean Unoccupied)

From Evidence-Based Rules to Internal Presence

An earlier experiment with balcony occupancy used door events, PIR activity, indoor presence, and different time windows as evidence of occupancy. The implementation included grace periods, countdowns, a maximum session duration, and a manual clearing mechanism. Although each rule had a purpose, their interactions introduced increasingly detailed conditions and additional failure modes. For example, a maximum session duration could prevent occupancy from remaining ON indefinitely, but forcibly clearing the state could also leave genuine occupancy unrecognized.

I also briefly considered probabilistic sensor fusion. However, I preferred a model in which state changes could be traced to explicit causes and parameters could be controlled more directly.

Meanwhile, false absence detections while sitting still continued to be a practical problem. The introduction of Internal Presence marked the beginning of the current architecture. Rather than allowing different pieces of spatial evidence to independently determine occupancy, I used spatial evidence to constrain when an observed state change could update internal memory. (Reference: Sections 4.2–4.6 — Spatial Transition Evidence and Internal Presence)


Figure 2. A shift from evidence-specific occupancy rules to constrained state transitions.

The state machine itself was surprisingly simple, but introducing memory also introduced new failure modes. I had not eliminated uncertainty; I had introduced another layer that needed to manage it.

When Internal Presence Got Stuck

The first major architectural revision occurred when Internal Presence itself became stuck in an incorrect state. Someone could leave a room faster than the sensor’s occupancy timeout, causing the available spatial evidence to disappear before the sensor reported absence. The same mechanism that protected against false absence could therefore retain occupancy in an empty room indefinitely.

Forcibly clearing IP after a timeout was one possible solution, but doing so could also discard valid memory. If someone was actually still in the room, there might be no new spatial transition evidence to restore that state.

Instead, I introduced Effective Presence, separating the inferred state from the state consumed by downstream automations. Fallback allowed the system to temporarily follow sensor observations without overwriting its internal memory. The question was no longer simply how to maintain a correct internal state, but how to maintain reasonable system behavior even when that state might be incorrect. (Reference: Sections 6.1–6.3 — Retaining Memory Without Getting Stuck)


Figure 3. Separating inferred state from effective output enables non-destructive fallback.

Active Refresh also acquired a broader role within this architecture. What began as a manual recovery tool became a shared mechanism used by multiple automated strategies. Persistent conflicts between F and IP could trigger bounded recovery attempts, with user notification reserved for cases where those attempts failed. The objective was not only to automate what I previously did manually, but also to define when automatic recovery should stop. (Reference: Sections 5.3–5.5 — Refresh Strategies and Recovery Limits)

Rethinking System Recovery

The second major revision extended Fallback beyond local inconsistencies. Earlier experience with Filtered Presence had already demonstrated the importance of handling observation interruptions during system restarts. Spatial inference introduced a broader version of this problem: the conditions required for reliable inference could themselves become temporarily unavailable.

My initial approach to recovering stale occupancy states when leaving home was to clear all internal states. However, clearing the entrance IP while someone was still standing there exposed a flaw in this approach. Without a new observation or spatial transition event, the state machine might have no opportunity to restore the correct state. An operation intended to recover the system could instead introduce another inconsistency.

Rather than introducing an entirely separate recovery architecture, I extended the existing Fallback mechanism through Rebuilding and Reconciliation. System initialization, whole-home evaluation, and recovery after robot vacuum activity could now share a common recovery lifecycle without requiring individual room state machines to understand why recovery had been initiated. (Reference: Section 7.3 — Returning from Bypass and Sections 8.1–8.4 — Rebuilding and Reconciliation)

Removing Mechanisms Instead of Adding Them

Not every iteration required additional mechanisms. An earlier Stale Watch automation was intended to notify me when effective occupancy remained ON despite a prolonged absence of sensor observations. Once automatic Fallback could handle that situation, the notification became unnecessary. The automation remains in my configuration but is now disabled.

Similarly, maintaining separate presence state machines for the living and dining areas introduced unnecessary dependencies between two physically connected spaces. Instead of adding exceptions or extending transition windows, I merged them into a single presence zone while retaining separate device control zones. (Reference: Section 9.1 — Living and Dining Areas)

In both cases, reconsidering the responsibility of an existing mechanism or the definition of a spatial boundary was more useful than adding another rule.

Looking Back

What I found most interesting was that expanding the capabilities of the system did not always require changing its underlying conceptual structure. The number of mechanisms and configurable parameters certainly increased, but after the introduction of EP, the three-layer distinction between observation, inference, and effective output remained unchanged. Bypass, Rebuilding, and additional refresh strategies could be integrated without introducing another representation of presence. (Reference: Section 10.4 — Handling Exceptions at the Appropriate Layer)


Figure 4. Independent mechanisms converge into a shared architecture, which subsequently accommodates broader recovery capabilities.

Sometimes the solution was a new abstraction. Sometimes it was discovering a broader use for an existing mechanism. And sometimes it was removing a mechanism altogether. The architecture emerged by repeatedly examining not only the original problems, but also the new problems introduced by their solutions.

For me, the practical measure of success is whether I still need to notice, investigate, or intervene in the system during everyday use. Perhaps the most satisfying outcome is that, after spending so much time thinking about presence, I now rarely need to think about it at all.

I hope it offers some useful insights or inspires new ideas for your own smart home.