ESPHome
2026.12.0-dev
Loading...
Searching...
No Matches
esphome
components
homeassistant
select
homeassistant_select.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstddef>
4
#include <cstdint>
5
#include <span>
6
7
#include "
esphome/components/select/select.h
"
8
#include "
esphome/core/string_ref.h
"
9
10
namespace
esphome::homeassistant
{
11
18
class
HomeassistantSelect
final :
public
select::Select
{
19
public
:
20
HomeassistantSelect
(std::span<char> options_buffer, std::span<const char *> option_list)
21
: options_buffer_(options_buffer.data()),
22
option_list_(option_list.data()),
23
options_buffer_size_(options_buffer.
size
()),
24
max_options_(option_list.
size
()) {}
25
26
void
set_entity_id
(
const
char
*
entity_id
) { this->
entity_id_
=
entity_id
; }
27
28
void
subscribe
();
29
void
dump_config
();
30
31
protected
:
32
void
options_changed_
(
StringRef
options
);
33
void
state_changed_
(
StringRef
state
);
34
35
void
control
(
size_t
index)
override
;
36
37
const
char
*
entity_id_
{
nullptr
};
38
39
private
:
40
// The traits point at option_list_, whose entries point into options_buffer_
41
char
*
const
options_buffer_;
42
const
char
**
const
option_list_;
43
uint16_t options_buffer_size_;
44
uint8_t max_options_;
45
};
46
47
}
// namespace esphome::homeassistant
esphome::StringRef
StringRef is a reference to a string owned by something else.
Definition
string_ref.h:31
esphome::homeassistant::HomeassistantSelect
Mirrors a Home Assistant select or input_select entity.
Definition
homeassistant_select.h:18
esphome::homeassistant::HomeassistantSelect::dump_config
void dump_config()
Definition
homeassistant_select.cpp:102
esphome::homeassistant::HomeassistantSelect::set_entity_id
void set_entity_id(const char *entity_id)
Definition
homeassistant_select.h:26
esphome::homeassistant::HomeassistantSelect::HomeassistantSelect
HomeassistantSelect(std::span< char > options_buffer, std::span< const char * > option_list)
Definition
homeassistant_select.h:20
esphome::homeassistant::HomeassistantSelect::entity_id_
const char * entity_id_
Definition
homeassistant_select.h:37
esphome::homeassistant::HomeassistantSelect::subscribe
void subscribe()
Definition
homeassistant_select.cpp:16
esphome::homeassistant::HomeassistantSelect::state_changed_
void state_changed_(StringRef state)
Definition
homeassistant_select.cpp:90
esphome::homeassistant::HomeassistantSelect::control
void control(size_t index) override
Definition
homeassistant_select.cpp:111
esphome::homeassistant::HomeassistantSelect::options_changed_
void options_changed_(StringRef options)
Definition
homeassistant_select.cpp:25
esphome::select::Select
Base-class for all selects.
Definition
select.h:28
esphome::select::Select::size
size_t size() const
Return the number of options in this select component.
Definition
select.h:57
options
uint8_t options
Definition
e131_packet.cpp:15
esphome::homeassistant
Definition
homeassistant_binary_sensor.cpp:7
esphome::homeassistant::entity_id
static void const char * entity_id
Definition
homeassistant_sensor.cpp:13
esphome::homeassistant::state
static void const char const char * state
Definition
homeassistant_sensor.cpp:14
select.h
string_ref.h
Generated by
1.12.0