Home Assistant Cat Alarm
Overview
A Home Assistant automation that monitors a front door contact sensor and announces repeated warnings on an Alexa Echo Dot when the door is left open. Built to keep cats from slipping out unnoticed.
Runs in Docker on a Raspberry Pi 4B. The automation logic is written in Python using AppDaemon, which lets you write event-driven HA automations as plain Python classes rather than YAML.
How It Works
When the door opens, a 20-second timer starts. If the door is still open when the timer fires, Alexa announces a warning. The warning repeats every 20 seconds with an escalating duration count until the door closes. Closing the door at any point cancels the timer immediately.
Architecture
Two Docker containers run side by side on the Pi:
- homeassistant: integrates the TP-Link Tapo T110 contact sensor (via the T100 hub) and the Alexa Devices integration for TTS announcements
- appdaemon: runs
cat_alarm.py, a Python class that listens for state changes on the door sensor and drives the announcement logic
Optional Telegram notifications send a message when warnings start and stop, useful if you're not near the Echo.
Hardware
- Raspberry Pi 4B (2 GB+ RAM)
- TP-Link Tapo T100 smart hub
- TP-Link Tapo T110 door/window contact sensor
- Amazon Echo Dot (any generation)
- Telegram account (optional)
Technical Notes
- AppDaemon over YAML automations: AppDaemon lets you write the escalation loop and cancellation logic cleanly in Python, where YAML automations would require several template workarounds
- Host networking on Pi: switching to
network_mode: hostindocker-compose.ymlis required for reliable mDNS/Zeroconf discovery of LAN devices on a Raspberry Pi - bridge networking drops packets from Tapo and Alexa integrations - Tapo firmware quirk: a late-2024 TP-Link firmware update disabled third-party API access by default - re-enabling it requires toggling "Third-Party Services" in the Tapo mobile app
- Entity IDs in secrets: door sensor and Alexa notify entity IDs live in a gitignored
secrets.yaml, keeping them out of version control alongside API tokens
Configuration
All timing and message content is configurable in apps.yaml:
initial_delay(default: 20s) - delay after the door opens before the first warningrepeat_interval(default: 20s) - gap between repeated warningswarning_message- TTS message template ({duration}= elapsed seconds)telegram_message- Telegram message template (optional)