ESPHome 2026.11.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 <memory>
6
10
11namespace esphome::homeassistant {
12
19class HomeassistantSelect final : public select::Select, public Component {
20 public:
21 HomeassistantSelect(uint8_t max_options, uint16_t options_buffer_size)
22 : options_buffer_size_(options_buffer_size), max_options_(max_options) {}
23
24 void set_entity_id(const char *entity_id) { this->entity_id_ = entity_id; }
25
26 void setup() override;
27 void dump_config() override;
28 float get_setup_priority() const override;
29
30 protected:
33
34 void control(size_t index) override;
35
36 const char *entity_id_{nullptr};
37
38 private:
39 // The traits point at option_list_, whose entries point into options_buffer_; both are sized once in
40 // setup() and must match options_buffer_size_ and max_options_
41 std::unique_ptr<char[]> options_buffer_;
42 std::unique_ptr<const char *[]> 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(uint8_t max_options, uint16_t options_buffer_size)
Base-class for all selects.
Definition select.h:29
uint8_t options
bool state
Definition fan.h:2