HAMQTT 0.1.0
ESP-IDF component for integrating devices with Home Assistant over MQTT
Loading...
Searching...
No Matches
hamqtt_binary_sensor.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
47
58
64
76typedef bool (*HAMQTT_Binary_Sensor_Get_State_Func)(void *args);
77
89
98
108
Common macros and definitions used across the HAMQTT library.
bool(* HAMQTT_Binary_Sensor_Get_State_Func)(void *args)
Function pointer type for retrieving the state of a binary sensor.
Definition hamqtt_binary_sensor.h:76
Configuration parameters for a HAMQTT binary sensor.
Definition hamqtt_binary_sensor.h:36
bool enabled_by_default
Set to false if the sensor should not be enabled when the sensor is first added.
Definition hamqtt_binary_sensor.h:38
char * name
The name of the sensor shown in Home Assistant.
Definition hamqtt_binary_sensor.h:43
char * entity_picture
URL to a picture for the sensor.
Definition hamqtt_binary_sensor.h:39
int off_delay
Number of seconds after the sensor turns on that Home Assistant turns it back off....
Definition hamqtt_binary_sensor.h:44
char * icon
Icon for the sensor.
Definition hamqtt_binary_sensor.h:42
int expire_after
Number of seconds a sensor's state expires, if it's not updated. Set to -1 to disable expiration.
Definition hamqtt_binary_sensor.h:40
bool force_update
Set to true if Home Assistant should always send update events, even when the sensor's state doesn't ...
Definition hamqtt_binary_sensor.h:41
HAMQTT_Binary_Sensor_Config hamqtt_binary_sensor_config_default(void)
Returns a default-initialized binary sensor configuration.
char * device_class
The class of the sensor, which alters how its state and icon is rendered.
Definition hamqtt_binary_sensor.h:37
char * unique_id
Unique identifier used for discovery in Home Assistant.
Definition hamqtt_binary_sensor.h:45
Internal representation of a Home Assistant MQTT binary sensor.
void hamqtt_binary_sensor_destroy(HAMQTT_Binary_Sensor *sensor)
Destroy a HAMQTT binary sensor and free all resources.
const HAMQTT_Binary_Sensor_Config * hamqtt_binary_sensor_get_config(const HAMQTT_Binary_Sensor *sensor)
Get the configuration used to initialize the binary sensor.
HAMQTT_Binary_Sensor * hamqtt_binary_sensor_create(HAMQTT_Binary_Sensor_Config *config, HAMQTT_Binary_Sensor_Get_State_Func get_state_func, void *get_state_func_args)
Create a new HAMQTT binary sensor.