# Show HN: Levoit air purifier scolds me over Sonos like an angry mom when I smoke

> Source: <https://github.com/guneriu/levoit-mom-mode>
> Published: 2026-11-29 17:56:33+00:00

**Key takeaway:** The levoit-mom-mode CLI polls Levoit PM2.5 data via pyvesync, triggers on an absolute PM25_THRESHOLD or PM25_DELTA with a COOLDOWN_SECONDS gap, and generates speech with gemini-2.5-flash-preview-tts (Kore voice), falling back to Edge TTS then macOS say when offline.

Your Levoit air purifier doesn't have a speaker—but your Sonos does.

Whenever PM2.5 spikes in the room, this script uses **Gemini TTS** to scold you out loud over your **Sonos speaker** like an angry mom who *literally just finished cleaning*.

```
Levoit Purifier ──► VeSync Cloud (pyvesync) ──► PM2.5 Spike Detector
                                                         │
Sonos Speaker ◄── Local HTTP Audio Server ◄── Gemini TTS (Kore + acting prompt)
```

- **Angry Mom Voice Persona:** Powered by Gemini TTS (`gemini-2.5-flash-preview-tts` , voice`Kore` ) with expressive acting direction—supports Turkish (`tr` ), English (`en` ), or any language via`--language` .
- **Broad Levoit Support:** Works with standard`pyvesync` air purifiers**plus** newer models not yet in`pyvesync` 's device map (like the**Eleva 300X / `LAP-C341S-WEU`** ) via direct` deviceProp` parsing.
- **Smart Spike Detection:** Triggers on either an absolute`PM25_THRESHOLD` or a sudden upward jump (`PM25_DELTA` ), with a configurable`COOLDOWN_SECONDS` so it doesn't yell every 45 seconds.
- **Sonos Snapshot & Resume:** Uses`SoCo`` Snapshot` to capture current Sonos state, play the scolding clip at your chosen volume, and restore playback afterward.
- **On-Demand Trigger & Custom Lines:** Speak immediately with`levoit-blame say` or pass`-s` /`--sentence` to deliver any exact phrase.
- **Clip Caching & Offline Fallbacks:** Caches generated audio in`audio_cache/` and automatically falls back from Gemini TTS → Edge TTS → macOS`say` if offline or unconfigured.

- **Python 3.12+** and[`uv`](https://docs.astral.sh/uv/)
- **macOS** (uses`/usr/bin/afconvert` and`/usr/bin/afinfo` for M4A conversion & duration inspection, plus`say` as the offline fallback)
- A **Levoit** smart air purifier connected to**VeSync**
- A **Sonos** speaker on the same local network
- A **Google Gemini API key** (optional if you use`--backend edge` or`--backend macos` )

1. 
**Clone and install dependencies:**

```
git clone https://github.com/guneriu/levoit-mom-mode.git
cd levoit-mom-mode
uv sync
```

2. 
**Create your `.env` file from `.env.example`:**

```
cp .env.example .env
```

3. 
**Fill in your credentials in `.env`:**
  - `VESYNC_EMAIL` &`VESYNC_PASSWORD` : Your VeSync mobile app email and password.**Signed up with Google?** VeSync doesn't provide a separate API key and`pyvesync` cannot use Google SSO directly. Log out of the VeSync mobile app, tap**Forgot Password** with the same Gmail address, and set a standalone VeSync password (this does not change your Google password).
  - `VESYNC_COUNTRY_CODE` : Your VeSync account region (`US` ,`DE` , etc.).
  - `GEMINI_API_KEY` : Your Gemini API key for Gemini TTS.
  - `SONOS_IP` : Optional—leave blank to auto-discover your Sonos speaker, or set its LAN IP.

Check Sonos discovery (read-only) and live Levoit PM2.5 telemetry:

```
uv run levoit-blame status --sonos-only
uv run levoit-blame status
```

Generate a TTS clip locally without playing on Sonos:

```
uv run levoit-blame test-tts -l tr
uv run levoit-blame test-tts -l en -s "I just cleaned it, why are you doing this?!"
```

Trigger an immediate scolding clip on Sonos (`say` or `test-sonos`):

```
# Random angry Turkish mom line
uv run levoit-blame say -l tr

# Random angry English mom line
uv run levoit-blame say -l en

# Exact custom sentence
uv run levoit-blame say -l en -s "I just cleaned it, why are you doing this?!"
uv run levoit-blame test-sonos -l tr -s "Ya daha yeni temizledim burayı!"
```

Simulate a PM2.5 spike end-to-end (dry-run by default; add `--play-sonos` to play):

```
uv run levoit-blame simulate --pm25 45 -l tr
uv run levoit-blame simulate --pm25 45 -l en --play-sonos
```

Run the continuous polling monitor:

```
uv run levoit-blame run --dry-run
uv run levoit-blame run -l tr
uv run levoit-blame run -l en -s "I just cleaned it, why are you doing this?!"
```

| Variable | Default | Description | 
|---|---|---|
| `VESYNC_EMAIL` | `""` | VeSync account email | 
| `VESYNC_PASSWORD` | `""` | VeSync account password | 
| `VESYNC_TIMEZONE` | `Europe/Berlin` | IANA timezone | 
| `VESYNC_COUNTRY_CODE` | `DE` | VeSync account country code | 
| `SONOS_IP` | `""` | Sonos speaker IP (blank = auto-discover) | 
| `SONOS_VOLUME` | `35` | Announcement volume ( `0–100` ) | 
| `PM25_THRESHOLD` | `20` | Trigger when PM2.5 reaches this value (µg/m³) | 
| `PM25_DELTA` | `10` | Or trigger on a single-poll jump of this size | 
| `POLL_INTERVAL_SECONDS` | `45` | VeSync polling interval (keep ≥ 30s to avoid rate limits) | 
| `COOLDOWN_SECONDS` | `300` | Minimum seconds between announcements | 
| `TTS_BACKEND` | `gemini` | `gemini` ,`edge` , or`macos` | 
| `GEMINI_API_KEY` | `""` | Google Gemini API key | 
| `TTS_MODEL` | `gemini-2.5-flash-preview-tts` | Gemini TTS model | 
| `TTS_VOICE` | `Kore` | Voice name ( `Kore` ,`Gacrux` ,`Algenib` ,`Charon` , etc.) | 
| `TTS_LANGUAGE` | `tr` | Default phrase & prompt language ( `tr` ,`en` , or any code) | 
| `TTS_STYLE_PROMPT` | Angry Turkish mom prompt | Custom acting direction prepended for Gemini TTS | 
| `HTTP_PORT` | `8765` | Local HTTP port for serving clips to Sonos | 

Want to switch back to a grumpy uncle or try another vibe? Update `.env`:

- **Angry Mom (default):**`TTS_VOICE=Kore` (or`Gacrux` for a slightly more mature tone)
- **Grumpy Uncle:**`TTS_VOICE=Algenib` (deep/gravelly) and customize`TTS_STYLE_PROMPT`

```
uv run pytest -v
```


