Documentation Index
Fetch the complete documentation index at: https://docs.nolongerevil.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Nest thermostat initiates all connections. The server never dials out to the device. Instead, the device maintains a persistent long-poll connection and relies on the server to push data on it.Device Lifecycle (Full Flow)
WoWLAN — How the Device Sleeps
The thermostat is battery-powered and aggressively manages CPU sleep. After the server sends chunked response headers, the device:- Hands the open TCP socket to its WiFi hardware chipset
- Puts the main CPU to sleep
- Relies on the WiFi hardware to monitor the socket for incoming data (WoWLAN — WiFi Wake-on-LAN)
- When data arrives, the WiFi hardware wakes the CPU in ~100–500ms
Subscribe Cycle Timing
| Phase | Duration | Who acts |
|---|---|---|
| Headers sent | Immediate | Server sends Transfer-Encoding: chunked + headers |
| Connection held | 0–290s | Server waits silently for data to push |
| Data push | When available | Server sends chunk, device wakes in ~100–500ms |
| Batch window | ≤3s | Server may send additional chunks before closing |
| Close + resubscribe | ~100–500ms | Server sends 0\r\n\r\n; device reconnects |
X-nl-suspend-time-max timer (default 300s) is a safety net, not the primary trigger.
Two-Port Architecture
The self-hosted server runs two independent HTTP services:Overlapping Subscriptions
When a device wakes early (user turns the dial), it sends a new subscribe request before the previous connection has closed. The server briefly sees two active subscriptions for the same device. The correct handling:- Track each subscription with a server-generated ID (not the device’s
sessionfield) - Push data to all active subscriptions when a change occurs
- Remove a subscription only when its specific connection closes
session field is reused across all subscribe requests during normal operation — it is not a unique connection identifier.