Table of Contents
| Module | Repository | README | License |
|---|---|---|---|
| Project overview | |||
| Cloudflare | |||
| Server | |||
| Microcontroller (ESP32) | |||
| Client |
This repository is part of the Easy Homelab Server Switch project. If you are exploring it for the first time, start with the Project Overview README which explains the architecture and interaction between all components.
The server MQTT agent is organized into small modules, each responsible for a specific part of the system.
- Orchestrates the application.
- Executes the system shutdown sequence using dbus-send to communicate with the host's power management service.
- Defines the central dictionary for broker settings, credentials, and MQTT topic.
- Provides validation to ensure all critical parameters are present before the system attempts to start.
- Manages the secure TLS connection to the MQTT broker.
- Implements the Last Will and Testament (LWT) feature to automatically broadcast a
"DEAD"state onTOPIC_HEARTBEATif the agent loses connection (expectedly or unexpectedly). - Subscribes to
TOPIC_SYSTEMand triggers local actions based on incoming remote commands.
- Performs network validation by checking physical interface link states and system routing tables.
- Verifies actual internet reachability via low-level socket checks to public DNS server.
- Manages the CA certificate required for secure MQTT communication.
- Ensures secure storage and retrieval of certificate data within the application's data directory.
- Defines shared constants used across the application.
- Resolves and creates the application data directory.
The system is configured via the config.py file using environment variables.
| Category | Variable | Description |
|---|---|---|
| MQTT_CONFIG | ip | The IP address of the cloud cluster in MQTT broker. |
| port | The secure MQTT port (default: 8883 for TLS) | |
| user | Username used for authenticating with the broker. | |
| pass | Password used for authenticating with the broker. | |
| TOPICS | Check here | and here |
| --- | MQTT_CA_CERTIFICATE | ISRG Root X1 certificate for validating the MQTT broker connection. |