Home automation field notes All concepts

sleep

How calm was the night

A sleep score computed from the house's own sensors, with the wearable on the wrist admitted only as a witness that testifies when it was actually there.

The wearable on the wrist gives a sleep score every morning, and it is not wrong. It is also not the house's. It knows nothing about the door to the bathroom, the CO₂ in the bedroom at three in the morning, the light in the hall, or the fan that ran all night because the room was too warm.

The house had been watching us sleep for years without drawing any conclusions, which is either discretion or a missed opportunity. We decided it was the latter, and taught it to grade the night.

The house knows all of that and had been throwing it away. So now, at a quarter past six and again when the sleep flag drops, a script reads the night back out of the recorder and scores it.

What counts as a bad night

The window runs from "went to bed", the sleep detector's flag capped at half past midnight, to "got up", the flag dropping after four. Inside it the script counts things a person would recognise as a bad night, each with a cost:

The wearable's score is blended in at thirty percent, but only when its bedtime belongs to this night. It syncs in the afternoon, so at six in the morning it is usually still telling us about yesterday, and a score from the wrong night is worse than none.

The morning after

The number feeds three places. The house spirit's ladder gets a morning branch: a night under fifty makes it sleepy until ten, and its diary says why ("restless night: 3× to the toilet, 25 degrees, light on twice"). The display's morning thoughts open with the verdict. And a card on the dashboard shows the breakdown, so a bad score can be argued with.

The first night scored 67, "solid": two trips, a warm room, the hall light three times, one cardio session, and perfect air because the window was open. The second scored 58 and blamed the heat again. We believe the direction more than the number.

Twenty-six radar flips in six hours might be a restless sleeper or might be the normal noise of two people turning over; a week of logged nights will tell us which, and the thresholds will move. They are written down as a first draft, in the code and on the page, so that nobody, including the nightly reviewer, mistakes them for calibration.

Early for a reason

Since the calendars arrived, the script also checks whether a timed event before nine (a flight, an appointment, anything longer than half an hour) sits on today's date. If so, a short night is not scored as a bad one, and the reason says so. Getting up at five for a plane is not insomnia, and a spirit that pouts about it would be wrong.

The first score was 67. We chose to take that as encouraging, on the grounds that it was the house's opinion and the house had been up all night too.

The house already has the data for a sleep score; it only needs to be asked. Read it back from the recorder, name every penalty, and keep the wearable as a witness that testifies only when it was actually there.