Publish file content as MQTT topic compatible with HomeAssistant.
Project description
HomeAssistant MQTT filesystem publisher
Publish file content as an MQTT topic compatible with HomeAssistant.
It can be useful, e.g., to publish system metrics from /sys
.
Quick start
- Install the Python package:
pip install hamqtt-fs-publisher
. If you want to have support for YAML configuration format install withruamel
orpyyaml
extras depending on the YAML library of choice (recommendedruamel
, e.g.,pip install hamqtt-fs-publisher[ruamel]
). - Create a configuration (example in
examples/config.example.yaml
). It can be in either YAML or JSON format. There is a pre-generated JSON schema inhamqtt_fs_publisher/configuration.schema.json
, which can be used, e.g., with VS Code (the current repository is pre-configured forconfig.json
andconfig.yaml
). Remember to set proper authorization details for the MQTT broker. If you are using the standard Mosquitto broker add-on in Home Assistant, please refer to the official documentation. - Run
hamqtt_fs_publisher --config <config_file_name>
.
Note: The configuration file path could be either a relative/absolute path, or a file under
/etc/hamqtt_fs_publisher
or~/.config/hamqtt_fs_publisher
.
Systemd service
If you want to run this script as a systemd service you could copy the example
service file from examples/hamqtt_fs_publisher@.service
to either
/etc/systemd/system/
or ~/.config/systemd/user/
(if you want to run it in
user mode). Then copy the configuration file to one of the standard
configuration directories (i.e., /etc/hamqtt_fs_publisher
or
~/.config/hamqtt_fs_publisher
.)
To enable and start the unit in system mode run:
$ systemd daemon-reload
$ systemd enable --now hamqtt_fs_publisher@<config_file_name>
Supported features
- Auto-discovery in HomeAssistant.
- Configuration with a simple YAML/JSON file.
- Possibility to create read-only sensor device entities with values taken from a file and published to the MQTT broker periodically with set intervals.
TODO
- Add a logger to connect/disconnect events.
- Add an option to read a value on a button push in GUI (not only periodically).
- Add a switch endpoint (i.e., a file writer).
- Add a generic writer endpoint.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hamqtt_fs_publisher-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6d2b24f11eb75cf1f5bd3215af2db590397791c045c261998deda4041d69caf |
|
MD5 | be7dccf335842223a5a61f1b10bf0b38 |
|
BLAKE2b-256 | 36a000346909a6abbf9949b1984c7109248db3a306d1b51f3d87b8ee4a408f97 |
Hashes for hamqtt_fs_publisher-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be94cfa46132f552d4f714636701c61407bed6f93e5263358c3a756bb358306f |
|
MD5 | 143d1eff3dfe42a4bd6e2c22a61681ce |
|
BLAKE2b-256 | ecb3099f31228eeaab0b8a39656ec7c9f47ad85a22d1edd81ce75e2ba96a2eec |