A self-hosted server implementation for Nest thermostats, written in Python. This server emulates Nest cloud endpoints, allowing you to maintain control of your Nest thermostat locally without relying on external cloud services.
- Full Nest Protocol Support: Emulates Nest cloud API endpoints for seamless device communication
- Dual-Port Architecture: Separate APIs for thermostat communication and dashboard/automation
- Long-Polling Subscriptions: Real-time device state updates without constant polling
- Temperature Safety Bounds: Configurable min/max temperature limits to prevent extreme settings
- Device Availability Tracking: Monitor device connectivity with automatic timeout detection
- Weather Service: Proxied weather data with caching to reduce API calls
- MQTT Integration: Publish device state to MQTT brokers for Home Assistant integration
- Home Assistant Auto-Discovery: Automatic device discovery in Home Assistant via MQTT
- Network Scanner: Scan your local subnet to discover unconfigured Nest devices and point them at this server in one click
- Device Credentials: Captures and displays each thermostat's api_key in the dashboard for easy local API configuration
- API Key Authentication: Secure control API access with API keys
- Device Sharing: Share device access with other users
- Persistent Storage: SQLite3 database for reliable state persistence
- Docker Support: Easy deployment with Docker and Docker Compose
Pre-built images are published to ghcr.io/codykociemba/nolongerevil-selfhosted for every release. No build step required, works great on Unraid, TrueNAS, Portainer, or any Docker host.
docker run -d \
-p 8000:8000 \
-p 8082:8082 \
-e API_ORIGIN=http://YOUR_SERVER_IP:8000 \
-v nolongerevil-data:/data \
ghcr.io/codykociemba/nolongerevil-selfhosted:latestReplace
YOUR_SERVER_IPwith the LAN IP of the machine running the container. Do not uselocalhostas Nest devices need a reachable IP.
Unraid / TrueNAS / Portainer users: Use the image ghcr.io/codykociemba/nolongerevil-selfhosted:latest, map host ports 8000 and 8082, set the API_ORIGIN environment variable, and mount a volume to /data for persistence.
-
Clone the repository:
git clone https://github.com/codykociemba/NoLongerEvil-SelfHosted.git cd nolongerevil-selfhosted -
Edit
docker-compose.ymlwith your settings (network, ports, environment variables). -
Start the server:
docker compose up -d
-
Prepare your thermostat. The thermostat only sends its complete state during a fresh boot. If your thermostat was previously connected to another server (or Nest's cloud), it will only send small updates and the server won't have a full picture of the device. Either:
- Factory reset the thermostat before connecting it to the server, or
- Reboot the thermostat after the server is running (press and hold the display until the screen goes black, wait a few seconds, then press it again until the Nest logo appears)
The server will be available at:
- Device API: Port 8000
- Control API: Port 8082
Requires Python 3.11 or higher.
-
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install the package (uses
pyproject.tomlfor dependencies):pip install . -
Configure environment:
cp .env.example .env # Edit .env with your settings -
Run the server:
nolongerevil-server # Or: python -m nolongerevil.main -
Prepare your thermostat (same as Docker above). Factory reset it before connecting, or reboot it after the server is running, so it sends its full state.
For Docker Compose, edit the environment: block in docker-compose.yml. For local Python, copy .env.example to .env and edit it. Available settings:
| Variable | Default | Description |
|---|---|---|
API_ORIGIN |
http://localhost:8000 |
Base URL for thermostat connections. Set to your LAN IP, e.g. http://192.168.1.100:8000 |
SERVER_PORT |
8000 |
Port for thermostat connections |
CONTROL_PORT |
8082 |
Port for control API |
CERT_DIR |
- | Directory containing TLS certificates |
ENTRY_KEY_TTL_SECONDS |
3600 |
Pairing code expiration (seconds) |
REQUIRE_DEVICE_PAIRING |
false |
Require entry key pairing before device transport access |
WEATHER_CACHE_TTL_MS |
600000 |
Weather cache duration (ms) |
MAX_SUBSCRIPTIONS_PER_DEVICE |
100 |
Max concurrent subscriptions |
SUSPEND_TIME_MAX |
600 |
Device sleep duration before fallback wake (seconds) |
DEFER_DEVICE_WINDOW |
15 |
Delay before device sends updates after local changes (seconds) |
SQLITE3_DB_PATH |
./data/database.sqlite |
Database file path |
DEBUG_LOGGING |
false |
Enable detailed request/response logging |
DEBUG_LOGS_DIR |
./data/debug-logs |
Directory for debug log files |
STORE_DEVICE_LOGS |
false |
Store uploaded device logs to disk |
DEVICE_LOGS_DIR |
./data/device-logs |
Directory for device log files |
To enable MQTT integration for Home Assistant:
| Variable | Default | Description |
|---|---|---|
MQTT_HOST |
- | MQTT broker hostname (required to enable MQTT) |
MQTT_PORT |
1883 |
MQTT broker port |
MQTT_USER |
- | MQTT username (optional) |
MQTT_PASSWORD |
- | MQTT password (optional) |
MQTT_TOPIC_PREFIX |
nolongerevil |
Prefix for MQTT topics |
MQTT_DISCOVERY_PREFIX |
homeassistant |
Home Assistant discovery prefix |
These endpoints emulate Nest cloud services:
| Endpoint | Method | Description |
|---|---|---|
/nest/entry |
GET | Service discovery |
/nest/ping |
GET | Health check |
/nest/passphrase |
GET | Generate pairing code |
/nest/transport |
POST | Subscribe to device updates |
/nest/transport/put |
POST | Push device state updates |
/nest/transport/device/{serial} |
GET | Get device objects |
/nest/weather/v1 |
GET | Weather data proxy |
These endpoints are for dashboards and automation:
| Endpoint | Method | Description |
|---|---|---|
/command |
POST | Send commands to thermostat |
/status |
GET | Get device status |
/api/devices |
GET | List all devices |
/api/stats |
GET | Server statistics |
/api/scan-network |
POST | Scan local /24 subnet for Nest devices |
/api/configure-nest |
POST | Point a discovered Nest device at this server |
/notify-device |
POST | Force notification to subscribers |
/health |
GET | Health check |
Set Temperature:
curl -X POST http://localhost:8082/command \
-H "Content-Type: application/json" \
-d '{"serial": "YOUR_SERIAL", "command": "set_temperature", "value": 21.5}'Set Mode:
curl -X POST http://localhost:8082/command \
-H "Content-Type: application/json" \
-d '{"serial": "YOUR_SERIAL", "command": "set_mode", "value": "heat"}'Set Away Mode:
curl -X POST http://localhost:8082/command \
-H "Content-Type: application/json" \
-d '{"serial": "YOUR_SERIAL", "command": "set_away", "value": true}'Set Fan:
curl -X POST http://localhost:8082/command \
-H "Content-Type: application/json" \
-d '{"serial": "YOUR_SERIAL", "command": "set_fan", "value": "on"}'The easiest way to run NoLongerEvil with Home Assistant is the official add-on, which handles configuration, MQTT auto-discovery, and ingress automatically.
π NoLongerEvil Home Assistant Add-on
If you are running the server standalone (Docker or Python), point it at your MQTT broker and Home Assistant will auto-discover the devices:
- Set
MQTT_HOST(and optionallyMQTT_USER/MQTT_PASSWORD) in your environment. - The server publishes Home Assistant discovery messages automatically on startup.
- Devices appear in Home Assistant under the Climate integration.
If you prefer fully manual MQTT configuration, add to your configuration.yaml:
climate:
- platform: mqtt
name: "Nest Thermostat"
current_temperature_topic: "nolongerevil/YOUR_SERIAL/device/current_temperature"
temperature_command_topic: "nolongerevil/YOUR_SERIAL/device/target_temperature/set"
temperature_state_topic: "nolongerevil/YOUR_SERIAL/device/target_temperature"
mode_command_topic: "nolongerevil/YOUR_SERIAL/device/mode/set"
mode_state_topic: "nolongerevil/YOUR_SERIAL/device/mode"
modes:
- "off"
- "heat"
- "cool"
- "heat_cool"Pull and run the pre-built image:
docker run -d \
-p 8000:8000 \
-p 8082:8082 \
-e API_ORIGIN=http://192.168.1.100:8000 \
-v nolongerevil-data:/data \
ghcr.io/codykociemba/nolongerevil-selfhosted:latestTo build locally instead:
docker build -t nolongerevil-server .
docker run -d \
-p 8000:8000 \
-p 8082:8082 \
-e API_ORIGIN=http://192.168.1.100:8000 \
-v nolongerevil-data:/data \
nolongerevil-serverFor production deployments with HTTPS:
-
Place your certificates in a directory:
certs/ βββ fullchain.pem βββ privkey.pem -
Configure the server:
CERT_DIR=/path/to/certs SERVER_PORT=443
-
Mount the certificates in Docker:
volumes: - ./certs:/app/certs:ro environment: - CERT_DIR=/app/certs
See the CONTRIBUTING guide for development setup instructions.
MIT License - see LICENSE for details.