Home Assistant MQTT CLI
A command-line interface (CLI) tool to easily send custom sensor data to Home Assistant using MQTT Discovery.
!!! warning "Rename Notice"
This project has been renamed from ha-cli to hamqtt to avoid a name clash with an existing PyPI package.
Legacy configurations in ~/.config/ha-cli will be automatically migrated to ~/.config/hamqtt on the first run.
Features
- Easy Configuration: Interactive setup for MQTT broker connection. Supports
--showto view and--resetto clear configuration. - Auto-Discovery: Automatically registers entities with Home Assistant.
- Flexible: Supports sensors, binary sensors, and various device classes.
- Scriptable: output JSON payloads for use with other tools or scripts.
Installation
pip install hamqtt
Or using uv or pipx:
uv tool install hamqtt
Quick Start
-
Configure MQTT Connection:
bash hamqtt configureFollow the prompts to enter your broker details. -
Register a Sensor:
bash hamqtt register --unique-id my_temp_sensor --name "Living Room Temperature" --device-class temperature --unit "°C" -
Send Data:
bash hamqtt send --unique-id my_temp_sensor --state 22.5
CLI Reference
See the API Reference for detailed documentation on internal modules.
For CLI help, run:
hamqtt --help