Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aanikei/hamqdisco
A library to generate MQTT discovery payloads and configuration, state, and command topics for Home Assistant..
https://github.com/aanikei/hamqdisco
home-assistant homeassistant mqtt
Last synced: 19 days ago
JSON representation
A library to generate MQTT discovery payloads and configuration, state, and command topics for Home Assistant..
- Host: GitHub
- URL: https://github.com/aanikei/hamqdisco
- Owner: aanikei
- License: mit
- Created: 2024-04-02T17:53:51.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-20T17:50:02.000Z (5 months ago)
- Last Synced: 2024-11-08T00:18:02.168Z (2 months ago)
- Topics: home-assistant, homeassistant, mqtt
- Language: C++
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### About HAMQDisco
This library enables creation of MQTT entities in Home Assistant using [MQTT discovery feature](https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery). The library allows the generation of discovery payloads and configuration, state, and command topics.
As the purpose of the library is mostly the creation of repetitive entities (button 1, button 2, etc.), it’s sufficient to create one object and then use a positive integer as a method argument to get entities with the corresponding number in their name, e.g.:
```
DiscoverySwitch switch1("Device Name", "swt", "switch", {{"icon", "mdi:resistor"}});
switch1.getDiscoveryMessage(); // ... "name":"DeviceName switch"
switch1.getDiscoveryMessage(1); // ... "name":"DeviceName switch 1"
switch1.getConfigurationTopic();
switch1.getConfigurationTopic(1);
switch1.getStateTopic();
switch1.getStateTopic(1);
switch1.getCommandTopic();
switch1.getCommandTopic(1);
```
For sensor entities, an additional level of numbers in the name can be used:
```
DiscoverySensor sensor("DeviceName", "snsr", "sensor", {{"exp_aft", "4000"}});
sensor.getDiscoveryMessage(1, 1); // ... "name":"DeviceName sensor 1 / 1"
sensor.getConfigurationTopic(1, 1);
sensor.getStateTopic(1, 1);
```Check examples for further details. Note that only a limited number of configuration variables are supported, and testing was only done on ESP32 microcontrollers.
Next controls are currently supported:
- Binary Sensor
- Button
- Light
- Number
- Select
- Sensor
- Switch### How to use
To use it with Arduino IDE, download the archive (Code / Download ZIP), unzip it and put it in `libraries` folder. Note that this library has a dependency on the ArduinoJson library.