ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
homeassistant_select.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <span>
6
9
10namespace esphome::homeassistant {
11
18class 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:
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
StringRef is a reference to a string owned by something else.
Definition string_ref.h:31
Mirrors a Home Assistant select or input_select entity.
HomeassistantSelect(std::span< char > options_buffer, std::span< const char * > option_list)
Base-class for all selects.
Definition select.h:28
size_t size() const
Return the number of options in this select component.
Definition select.h:57
uint8_t options
static void const char * entity_id
static void const char const char * state