Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
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
19
namespace
esphome
{
20
namespace
home_io_control
{
21
22
// Forward declaration of the hub component.
23
class
IOHomeControlComponent
;
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.
29
class
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
47
IOHomeControlComponent
*
parent_
{
nullptr
};
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.
55
class
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
73
IOHomeControlComponent
*
parent_
{
nullptr
};
74
std::string
param_name_
;
75
};
76
77
}
// namespace home_io_control
78
}
// namespace esphome
esphome::home_io_control::IOHomeControlComponent
The main IO-Homecontrol component.
Definition
hub_core.h:91
esphome::home_io_control::IOHomeTuningNumber::setup
void setup() override
Publish the current tuning value so the HA slider reflects the active configuration on boot.
Definition
tuning_entities.cpp:11
esphome::home_io_control::IOHomeTuningNumber::parent_
IOHomeControlComponent * parent_
Definition
tuning_entities.h:47
esphome::home_io_control::IOHomeTuningNumber::dump_config
void dump_config() override
Empty dump_config override (kept for compatibility).
Definition
tuning_entities.h:40
esphome::home_io_control::IOHomeTuningNumber::IOHomeTuningNumber
IOHomeTuningNumber(IOHomeControlComponent *parent, std::string name)
Construct a tuning number entity.
Definition
tuning_entities.h:34
esphome::home_io_control::IOHomeTuningNumber::control
void control(float value) override
Called by ESPHome when the user changes the slider value in HA.
Definition
tuning_entities.cpp:24
esphome::home_io_control::IOHomeTuningNumber::param_name_
std::string param_name_
Definition
tuning_entities.h:48
esphome::home_io_control::IOHomeTuningSelect::dump_config
void dump_config() override
Empty dump_config override (kept for compatibility).
Definition
tuning_entities.h:66
esphome::home_io_control::IOHomeTuningSelect::control
void control(const std::string &value) override
Called by ESPHome when the user selects a new option in HA.
Definition
tuning_entities.cpp:30
esphome::home_io_control::IOHomeTuningSelect::parent_
IOHomeControlComponent * parent_
Definition
tuning_entities.h:73
esphome::home_io_control::IOHomeTuningSelect::setup
void setup() override
Publish the current tuning option so the HA dropdown reflects the active configuration on boot.
Definition
tuning_entities.cpp:16
esphome::home_io_control::IOHomeTuningSelect::param_name_
std::string param_name_
Definition
tuning_entities.h:74
esphome::home_io_control::IOHomeTuningSelect::IOHomeTuningSelect
IOHomeTuningSelect(IOHomeControlComponent *parent, std::string name)
Construct a tuning select entity.
Definition
tuning_entities.h:60
esphome::home_io_control
Definition
device_registry.cpp:13
esphome
Definition
device_registry.cpp:12
components
home_io_control
tuning_entities.h
Generated by
1.18.0