Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
tuning_entities.h
Go to the documentation of this file.
1#pragma once
2
3/// @file tuning_entities.h
4/// @brief Home Assistant `number` and `select` entities that control runtime tuning parameters.
5/// @ingroup hioc_tuning
6///
7/// These are thin entity classes that forward user changes from Home Assistant into the
8/// hub's `TuningConfig`. Each entity is identified by the YAML key of the parameter it
9/// controls, so the C++ side stays generic and new parameters do not require new classes.
10
11#include "esphome/core/component.h"
12#include "esphome/components/number/number.h"
13#include "esphome/components/select/select.h"
14
15#include <string>
16#include <utility>
17#include <vector>
18
19namespace esphome {
20namespace home_io_control {
21
22// Forward declaration of the hub component.
24
25/// @brief Runtime-tunable `number` entity.
26///
27/// Forwards HA slider changes to the hub via the YAML key name. The hub updates the
28/// matching `TuningConfig` field and applies the value to the radio driver when needed.
29class IOHomeTuningNumber : public number::Number, public Component {
30 public:
31 /// @brief Construct a tuning number entity.
32 /// @param parent Hub component that owns the tuning configuration.
33 /// @param name YAML key of the parameter this slider controls (used for logs and dispatch).
34 IOHomeTuningNumber(IOHomeControlComponent *parent, std::string name)
35 : parent_(parent), param_name_(std::move(name)) {}
36
37 /// @brief Publish the current tuning value so the HA slider reflects the active configuration on boot.
38 void setup() override;
39 /// @brief Empty dump_config override (kept for compatibility).
40 void dump_config() override {}
41
42 protected:
43 /// @brief Called by ESPHome when the user changes the slider value in HA.
44 /// @param value New value from the UI.
45 void control(float value) override;
46
48 std::string param_name_;
49};
50
51/// @brief Runtime-tunable `select` entity.
52///
53/// Forwards HA dropdown selections to the hub via the YAML key name. The option strings
54/// match the YAML enumeration values so the user can copy the active value back to YAML.
55class IOHomeTuningSelect : public select::Select, public Component {
56 public:
57 /// @brief Construct a tuning select entity.
58 /// @param parent Hub component that owns the tuning configuration.
59 /// @param name YAML key of the parameter this dropdown controls.
60 IOHomeTuningSelect(IOHomeControlComponent *parent, std::string name)
61 : parent_(parent), param_name_(std::move(name)) {}
62
63 /// @brief Publish the current tuning option so the HA dropdown reflects the active configuration on boot.
64 void setup() override;
65 /// @brief Empty dump_config override (kept for compatibility).
66 void dump_config() override {}
67
68 protected:
69 /// @brief Called by ESPHome when the user selects a new option in HA.
70 /// @param value Selected option string.
71 void control(const std::string &value) override;
72
74 std::string param_name_;
75};
76
77} // namespace home_io_control
78} // namespace esphome
The main IO-Homecontrol component.
Definition hub_core.h:74
void setup() override
Publish the current tuning value so the HA slider reflects the active configuration on boot.
void dump_config() override
Empty dump_config override (kept for compatibility).
IOHomeTuningNumber(IOHomeControlComponent *parent, std::string name)
Construct a tuning number entity.
void control(float value) override
Called by ESPHome when the user changes the slider value in HA.
void dump_config() override
Empty dump_config override (kept for compatibility).
void control(const std::string &value) override
Called by ESPHome when the user selects a new option in HA.
void setup() override
Publish the current tuning option so the HA dropdown reflects the active configuration on boot.
IOHomeTuningSelect(IOHomeControlComponent *parent, std::string name)
Construct a tuning select entity.