HAMQTT 0.1.0
ESP-IDF component for integrating devices with Home Assistant over MQTT
Loading...
Searching...
No Matches
hamqtt_button.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
28
29#pragma once
30
31#include "common.h"
32
36typedef struct {
40 char *icon;
41 char *name;
42 char *unique_id;
44
55
60typedef struct HAMQTT_Button HAMQTT_Button;
61
71typedef void (*HAMQTT_Button_On_Press_Func)(void *args);
72
84
93
103
Common macros and definitions used across the HAMQTT library.
void(* HAMQTT_Button_On_Press_Func)(void *args)
Function pointer type for receiving button press events.
Definition hamqtt_button.h:71
Configuration parameters for a HAMQTT button.
Definition hamqtt_button.h:36
char * entity_picture
URL to a picture for the button.
Definition hamqtt_button.h:39
char * device_class
The class of the button, which alters how its state and icon is rendered.
Definition hamqtt_button.h:37
bool enabled_by_default
Set to false if the button should not be enabled when the button is first added.
Definition hamqtt_button.h:38
HAMQTT_Button_Config hamqtt_button_config_default(void)
Returns a default-initialized button configuration.
char * icon
Icon for the button.
Definition hamqtt_button.h:40
char * name
The name of the button shown in Home Assistant.
Definition hamqtt_button.h:41
char * unique_id
Unique identifier used for discovery in Home Assistant.
Definition hamqtt_button.h:42
Internal representation of a Home Assistant MQTT button.
HAMQTT_Button * hamqtt_button_create(HAMQTT_Button_Config *config, HAMQTT_Button_On_Press_Func on_press_func, void *on_press_func_args)
Create a new HAMQTT button.
const HAMQTT_Button_Config * hamqtt_button_get_config(const HAMQTT_Button *button)
Get the configuration used to initialize the button.
void hamqtt_button_destroy(HAMQTT_Button *button)
Destroy a HAMQTT button and free all resources.