Version 0.0.1. Send a retained MQTT message to Home Assistant when a task finishes, with optional logging, email notifications, and a post-run shell command.
For the source CLI or a local executable build, create a Python 3 venv from the project directory and install the pinned dependencies:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r dependencies.txt
python -m pip check
python Python3-MQTT-To-HomeAssistant.py --help
python Python3-MQTT-To-HomeAssistant.py --versionTo build the Linux executable:
python build.pySee BUILDING.md for all build steps, prerequisites, output checks,
and platform limitations. The checked-in executable is
bin/Python3-MQTT-To-HomeAssistant-0.0.1-linux-x86_64.
Download it using GitHub's file download/Raw button, or obtain it through a clone.
It bundles Python and Paho MQTT, so the build venv is not required to run it:
chmod +x bin/Python3-MQTT-To-HomeAssistant-0.0.1-linux-x86_64
./bin/Python3-MQTT-To-HomeAssistant-0.0.1-linux-x86_64 --help
./bin/Python3-MQTT-To-HomeAssistant-0.0.1-linux-x86_64 --versionThe binary targets Linux x86-64 and was built on glibc 2.43. Other architectures, operating systems, and older distributions need their own compatible local build. Bundled third-party notices are preserved under licenses/ and embedded in the executable.
cp Message-Example.cfg Message.cfgEdit Message.cfg before running. It is ignored by Git and must stay outside the
binary and source uploads. All settings belong to [MQTT-To-HomeAssistant]:
| Key | Meaning |
|---|---|
Mail |
Email recipient, or No to disable. Requires a configured system mail program when enabled. |
DateTime |
strftime format for log filenames, for example %Y-%m-%d_%H_%M_%S. |
LogDestination |
Log directory, or No to disable file logs. Console logging remains enabled. |
SystemAction |
Post-run shell command, or No to disable. Can shut down the machine if configured to do so. |
broker_address |
MQTT broker hostname or IP address; replace the sample placeholder. |
broker_port |
Integer MQTT broker port; replace the sample placeholder. |
mqtt_username |
Broker account username. |
mqtt_password |
Broker account password; keep real values in the ignored local config. |
mqtt_topic |
State/command topic to publish. |
mqtt_message |
MQTT payload, such as ON for the supplied Home Assistant example. |
Use_HomeAssistant |
Yes enables publishing the availability message; otherwise leave it disabled. |
HomeAssistant_Available |
Availability topic, published with online when enabled. |
Start with Mail=No, LogDestination=No, and SystemAction=No. Configure the real
broker settings explicitly. The current CLI uses the configured username/password
over its existing MQTT connection and has no TLS configuration option. A normal
run publishes retained messages; it is not a dry run. Mail can include logs.
Adapt HomeAssistant-Configuration-For-MQTT.yaml into your Home Assistant MQTT
configuration if needed. Keep its topics and payloads consistent with your local
config, then reload the appropriate Home Assistant configuration.
# Source CLI from the activated venv:
python Python3-MQTT-To-HomeAssistant.py --config Message.cfg
# Bundled Linux CLI:
./bin/Python3-MQTT-To-HomeAssistant-0.0.1-linux-x86_64 -c Message.cfg| Flag | Purpose |
|---|---|
-h, --help |
Show help and exit before reading config or running actions. |
--version |
Print the app version and exit before reading config or running actions. |
-c PATH, --config PATH |
Required external configuration file for a normal run. |
After source/build use, run deactivate to leave the venv. Past changes are in
versioning.md; function and command explanations are in
commented_code_map.md.
Use this script at your own risk.
The author takes no responsibility or liability for any data loss, service disruption, misconfiguration, service outage, missed backups, credential exposure, or other damage that may occur from using this script.
Before running it in production, you must:
- Read the entire source code
- Understand exactly what it does (and what it does not do)
- Review and adapt it to your own environment
- Test it carefully in a non‑production setup
By using this script, you accept full responsibility for its effects.
This project is AI-assisted / vibe-coded software created as a hobby project. It has not been professionally audited and may contain bugs, unsafe behavior, data-loss issues, security problems, or incorrect assumptions.
You are responsible for reviewing the code, testing it in a safe environment, making backups, and understanding what it does before using it on real data. The author is not responsible for damage, data loss, broken systems, security issues, or other problems caused by using this software.