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
36
typedef
struct
{
37
char
*
device_class
;
38
bool
enabled_by_default
;
39
char
*
entity_picture
;
40
char
*
icon
;
41
char
*
name
;
42
char
*
unique_id
;
43
}
HAMQTT_Button_Config
;
44
54
HAMQTT_Button_Config
hamqtt_button_config_default
(
void
);
55
60
typedef
struct
HAMQTT_Button
HAMQTT_Button
;
61
71
typedef
void (*
HAMQTT_Button_On_Press_Func
)(
void
*args);
72
83
HAMQTT_Button
*
hamqtt_button_create
(
HAMQTT_Button_Config
*config,
HAMQTT_Button_On_Press_Func
on_press_func,
void
*on_press_func_args);
84
92
void
hamqtt_button_destroy
(
HAMQTT_Button
*button);
93
102
const
HAMQTT_Button_Config
*
hamqtt_button_get_config
(
const
HAMQTT_Button
*button);
103
common.h
Common macros and definitions used across the HAMQTT library.
HAMQTT_Button_On_Press_Func
void(* HAMQTT_Button_On_Press_Func)(void *args)
Function pointer type for receiving button press events.
Definition
hamqtt_button.h:71
HAMQTT_Button_Config
Configuration parameters for a HAMQTT button.
Definition
hamqtt_button.h:36
HAMQTT_Button_Config::entity_picture
char * entity_picture
URL to a picture for the button.
Definition
hamqtt_button.h:39
HAMQTT_Button_Config::device_class
char * device_class
The class of the button, which alters how its state and icon is rendered.
Definition
hamqtt_button.h:37
HAMQTT_Button_Config::enabled_by_default
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
HAMQTT_Button_Config hamqtt_button_config_default(void)
Returns a default-initialized button configuration.
HAMQTT_Button_Config::icon
char * icon
Icon for the button.
Definition
hamqtt_button.h:40
HAMQTT_Button_Config::name
char * name
The name of the button shown in Home Assistant.
Definition
hamqtt_button.h:41
HAMQTT_Button_Config::unique_id
char * unique_id
Unique identifier used for discovery in Home Assistant.
Definition
hamqtt_button.h:42
HAMQTT_Button
Internal representation of a Home Assistant MQTT button.
HAMQTT_Button::hamqtt_button_create
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.
HAMQTT_Button::hamqtt_button_get_config
const HAMQTT_Button_Config * hamqtt_button_get_config(const HAMQTT_Button *button)
Get the configuration used to initialize the button.
HAMQTT_Button::hamqtt_button_destroy
void hamqtt_button_destroy(HAMQTT_Button *button)
Destroy a HAMQTT button and free all resources.
include
HAMQTT
hamqtt_button.h
Generated by
1.14.0