Smart Plug Notifier (SPN) is a notification system built on an asynchronous, event-driven microservice architecture. Each service runs concurrently using non-blocking operations, which ensures scalability and responsiveness.
The system is composed of two primary services:
Tapo Service: responsible for monitoring Tapo smart plugs (P110) by polling them locally over encrypted HTTP (JSON-RPC). Whenever a device changes state, transitioning from idle to active (power consumption >
$0\, W$ ) or from active to idle (power consumption returning to$0\, W$ ), the service publishes an event to RabbitMQ.Notification Service: acts as a consumer of these events. It listens to the RabbitMQ queue, processes the incoming messages, and forwards notifications to end users. Currently, notifications are delivered via Telegram Channel using the Telegram Bot API, but the system is extensible and can support additional channels (e.g., Signal, Discord, email) through dedicated adapters.
RabbitMQ acts as the message broker and communication backbone between the microservices. It ensures that events are decoupled from their consumers, can be processed asynchronously, and remain reliable even if one service is temporarily unavailable. It’s worth noting that, messages are not persisted in the queue. If no subscriber is active at the time of publishing, the message will be lost. This is intentional, as state-change events only carry value at the moment they occur. Once missed, the information becomes stale and no longer relevant.
This architecture allows SPN to:
React in near real-time to device activity.
Scale horizontally by adding more consumers or producers.
Extend easily with new notification channels.
Fig. 1: SPN system instance overview
The SPN was built out of a personal need for real-time notifications regarding cycles of my home washer and dryer machines, as shown in the diagram above. While I currently use only two smart plugs, the system was designed to support a large number of devices, making it scalable and flexible for broader home automation setups or small-scale deployments.
SPN is containerized for simplicity and can be launched with Docker Compose. Both tapo_service
and notification_service
include their own Dockerfiles, while RabbitMQ runs as a separate container within the same setup.
A
.env
file with your environment variables (RabbitMQ credentials, Telegram bot token, Telegram channel ID).A
settings.template.py
file with required configuration (e.g., device list). After editing, rename it tosettings.py
for each service.
After cloning this repo, start the SPN by running the following docker command:
docker compose up -d --build