HAMQTT 0.1.0
ESP-IDF component for integrating devices with Home Assistant over MQTT
Loading...
Searching...
No Matches
hamqtt_device.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 Ethan Barnes
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
31
32#pragma once
33
34#include "common.h"
35#include "hamqtt_component.h"
36
55
66
71typedef struct HAMQTT_Device HAMQTT_Device;
72
82
91
105
119
131esp_err_t hamqtt_device_publish_availability(const HAMQTT_Device *device, bool availability);
132
143
Common macros and definitions used across the HAMQTT library.
Interface definition for Home Assistant MQTT components.
Base struct representing a generic Home Assistant MQTT component.
Definition hamqtt_component_internal.h:68
Configuration parameters for a HAMQTT device.
Definition hamqtt_device.h:41
char * origin_url
URL to documentation or device homepage.
Definition hamqtt_device.h:52
char * hw_version
The hardware version of the device.
Definition hamqtt_device.h:51
char * manufacturer
The manufacturer of the device.
Definition hamqtt_device.h:46
char * sw_version
The software version of the device.
Definition hamqtt_device.h:50
char * model
The model of the device.
Definition hamqtt_device.h:47
char * name
The name of the device shown in Home Assistant.
Definition hamqtt_device.h:53
char * mqtt_password
The MQTT password.
Definition hamqtt_device.h:45
char * mqtt_username
The MQTT username.
Definition hamqtt_device.h:44
char * mqtt_uri
The URI of the MQTT broker (e.g., "mqtt://broker.hivemq.com:1883").
Definition hamqtt_device.h:43
char * serial_number
The serial number of the device.
Definition hamqtt_device.h:48
HAMQTT_Device_Config hamqtt_device_config_default(void)
Returns a default-initialized device configuration.
char * mqtt_config_topic_prefix
The prefix for Home Assistant MQTT discovery topics.
Definition hamqtt_device.h:42
char * unique_id
Unique identifier used for discovery in Home Assistant.
Definition hamqtt_device.h:49
Internal representation of a Home Assistant MQTT device.
esp_err_t hamqtt_device_publish_availability(const HAMQTT_Device *device, bool availability)
Publish an availability message to Home Assistant.
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.
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.
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.