Version 2.0 Available
Hey everyone,
I wanted to share a project I’ve been building to solve one of the most frustrating aspects of smart home presence: accurate, contactless sleep tracking. Wearables are great, but I wanted my house to know when we were actually asleep, just getting up to pee, or tossing and turning—using only standard vibration and motion sensors. Simple "If vibration stops and motion starts" rules always lead to false positives (like folding laundry on the bed, or a parent checking on a sleeping child).
So, I built Advanced Sleep Metrics (BMS Edition). It shifts away from basic "A then B" rules and uses Behavioral Telemetry and Signal Processing to figure out what’s actually happening in the room.
It is designed to run independently, but it pairs perfectly with my Advanced Good Night application to drive your home's ambient routines.
Key Features & Logic Engines
Machine Learning Behavioral Engine The app maintains a rolling 14-day ledger of your sleep patterns (separating Weekdays from Weekends). Once it learns your baseline, it dynamically adjusts its own sensitivity. If you get into bed near your learned average time, it fast-tracks your entry. If you trigger a motion sensor near your average wake time, it accelerates your morning routines. (Can be disabled per-user for guest rooms).
Pre-Emptive Presence Lockout (Ghost Filter & Parental Guard) Tired of your kids being marked "Awake" because they rolled over right as you walked in to check on them? The app takes a microsecond snapshot of room motion when bed vibration stops. If motion was already active before the bed stopped moving, it flags an "External Presence Override" and protects the sleeper's status.
Sustained Entry (Anti-Bounce) & Settling Locks If you sit on the bed to fold laundry, the app puts you in a "Pending Entry" state and watches the room for 3 minutes. If you keep moving around, it aborts the entry. Once you are officially "In Bed," it gives you a 30-minute absolute Settling Lock where you can toss, turn, and adjust blankets without triggering a false exit.
The Partner Shield (Cross-Talk Cancellation) When one partner physically gets out of bed, the mattress naturally bounces. The app intelligently deafens the sleeping partner's vibration sensor for 60 seconds to prevent false movement tracking.
Dynamic Stitching & Terminal Wake (Shower Sensor) If you get up to use the bathroom in the middle of the deep sleep window, the app gives you a 45-minute grace period to return and seamlessly stitches your sleep session back together. But, if you walk into the bathroom and trigger the Shower Motion Sensor within 10 minutes, the app triggers a "Terminal Wake," rolls back the bathroom trip, and instantly wakes the house up for the day.
Kinetic Speed Limits You can define exact "Wake Sequences" (Step 1: Bedside Motion -> Step 2: Hallway Motion). The app enforces physical kinetic speed limits. If Step 2 triggers 1 second after Step 1, it rejects it as a physical impossibility (ignoring dogs running by or parents walking out).
Live HTML Dashboards Automatically generates virtual info devices with beautiful HTML tiles showing live Sleep Scores, Session Durations, Nightly Movements, Bathroom Trips, and AI-predicted target times for your Hubitat dashboards.
Hardware Requirements
- 1x Vibration/Acceleration Sensor per sleeper (under the mattress or taped to the slats).
- Standard Room/Bathroom Motion Sensors (to track wake paths and bathroom trips).
- (Optional) Dedicated bedside, hallway, and shower motion sensors for ultra-strict tracking sequences.
The Code & Support This app is entirely free to use. You are welcome to take the code, strip it down, repurpose the logic for your own apps, or use it exactly as is.
I’m actively running this in my own home, so if you run into any bugs, have weird edge-case use cases (pets, unusual shift-work schedules), or have feature requests, please let me know below and I’m more than happy to help patch the code!

