HAMQTT 0.1.0
ESP-IDF component for integrating devices with Home Assistant over MQTT
|
Internal representation of a Home Assistant MQTT device. More...
#include <hamqtt_device.h>
Public Member Functions | |
HAMQTT_Device * | hamqtt_device_create (HAMQTT_Device_Config *config) |
Create a new HAMQTT device. | |
void | hamqtt_device_destroy (HAMQTT_Device *device) |
Destroy a HAMQTT device and free all resources. | |
esp_err_t | hamqtt_device_add_component (HAMQTT_Device *device, HAMQTT_Component *component) |
Add a component (e.g. sensor, switch) to the device. | |
esp_err_t | hamqtt_device_connect (HAMQTT_Device *device) |
Connect the device to the MQTT broker and publish its Home Assistant discovery config. | |
esp_err_t | hamqtt_device_publish_availability (const HAMQTT_Device *device, bool availability) |
Publish an availability message to Home Assistant. | |
void | hamqtt_device_loop (const HAMQTT_Device *device) |
Update the state of all components and publish to MQTT. | |
const HAMQTT_Device_Config * | hamqtt_device_get_config (const HAMQTT_Device *device) |
Get the configuration used to initialize the device. |
Internal representation of a Home Assistant MQTT device.
esp_err_t hamqtt_device_add_component | ( | HAMQTT_Device * | device, |
HAMQTT_Component * | component ) |
Add a component (e.g. sensor, switch) to the device.
device | Pointer to the device. |
component | Pointer to a component implementing the HAMQTT_Component interface. |
esp_err_t hamqtt_device_connect | ( | HAMQTT_Device * | device | ) |
Connect the device to the MQTT broker and publish its Home Assistant discovery config.
This must be called before calling hamqtt_device_loop.
device | Pointer to the device. |
HAMQTT_Device * hamqtt_device_create | ( | HAMQTT_Device_Config * | config | ) |
Create a new HAMQTT device.
config | Pointer to a device configuration. Must remain valid for the lifetime of the device. |
void hamqtt_device_destroy | ( | HAMQTT_Device * | device | ) |
Destroy a HAMQTT device and free all resources.
device | Pointer to the device to destroy. Must not be NULL. |
const HAMQTT_Device_Config * hamqtt_device_get_config | ( | const HAMQTT_Device * | device | ) |
Get the configuration used to initialize the device.
device | Pointer to the device. |
void hamqtt_device_loop | ( | const HAMQTT_Device * | device | ) |
Update the state of all components and publish to MQTT.
This should be called periodically to keep sensor states up to date.
device | Pointer to the device. |
esp_err_t hamqtt_device_publish_availability | ( | const HAMQTT_Device * | device, |
bool | availability ) |
Publish an availability message to Home Assistant.
device | Pointer to the device. |
availability | true if available, false if offline. |