Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
tuning_registry.h
Go to the documentation of this file.
1/// @file tuning_registry.h
2/// @brief Table-driven registry of runtime tuning parameters.
3/// @ingroup hioc_tuning
4///
5/// The hub exposes each tuning parameter through Home Assistant `number`/`select`
6/// entities. Rather than hand-syncing four string-dispatch functions in the hub, this
7/// registry enumerates every parameter once, as a table row pairing the parameter's
8/// wire name with getter/setter function pointers over TuningConfig. The hub's
9/// update/get methods become thin table lookups.
10///
11/// @par Adding a tuning parameter
12/// Add exactly two things and the cross-language sync check (`make tuning-sync`) will
13/// keep them honest:
14/// 1. one row in the appropriate table below (`NUMBER_PARAMS` or `SELECT_PARAMS`), and
15/// 2. one matching entry in `tuning.py` (`_NUMBER_PARAMS` or `_SELECT_OPTIONS`).
16/// The parameter `name` string must be identical on both sides.
17
18#pragma once
19
20#include "tuning_config.h"
21
22#include <string>
23
24namespace esphome {
25namespace home_io_control {
26
27/// One numeric tuning parameter: its wire name plus accessors over TuningConfig.
28///
29/// `get` returns the stored value as a float (for HA slider seeding); `set` writes the
30/// value back, narrowing to the field's underlying integer type. `applies_to_radio`
31/// marks parameters whose change must be pushed to the active radio driver immediately.
33 const char *name; ///< YAML/HA parameter name (must match tuning.py).
34 float (*get)(const TuningConfig &); ///< Read the current value as a float.
35 void (*set)(TuningConfig &, float); ///< Write a new value (narrowed to the field type).
36 bool applies_to_radio; ///< True if changes must be re-applied to the radio.
37};
38
39/// One select tuning parameter: its wire name plus string accessors over TuningConfig.
40///
41/// `get` returns the current option string (matching the HA dropdown labels). `set`
42/// parses an option string and returns false when the value is unparseable, so the hub
43/// can skip the radio re-apply exactly as the original per-parameter logic did.
45 const char *name; ///< YAML/HA parameter name (must match tuning.py).
46 std::string (*get)(const TuningConfig &); ///< Read the current option string.
47 bool (*set)(TuningConfig &, const std::string &); ///< Parse/apply an option; false if unparseable.
48 bool applies_to_radio; ///< True if changes must be re-applied to the radio.
49};
50
51/// Look up a numeric tuning parameter by name; returns nullptr if unknown.
52const TuningNumberParam *find_tuning_number(const std::string &name);
53
54/// Look up a select tuning parameter by name; returns nullptr if unknown.
55const TuningSelectParam *find_tuning_select(const std::string &name);
56
57/// @name Table iteration
58/// Range accessors over the full parameter tables, for enumeration and tests.
59/// @{
64/// @}
65
66} // namespace home_io_control
67} // namespace esphome
const TuningNumberParam * tuning_number_params_end()
const TuningSelectParam * tuning_select_params_end()
const TuningNumberParam * tuning_number_params_begin()
const TuningSelectParam * find_tuning_select(const std::string &name)
Look up a select tuning parameter by name; returns nullptr if unknown.
const TuningSelectParam * tuning_select_params_begin()
const TuningNumberParam * find_tuning_number(const std::string &name)
Look up a numeric tuning parameter by name; returns nullptr if unknown.
All runtime tunable parameters for pairing and radio diagnostics.
One numeric tuning parameter: its wire name plus accessors over TuningConfig.
float(* get)(const TuningConfig &)
Read the current value as a float.
bool applies_to_radio
True if changes must be re-applied to the radio.
void(* set)(TuningConfig &, float)
Write a new value (narrowed to the field type).
const char * name
YAML/HA parameter name (must match tuning.py).
One select tuning parameter: its wire name plus string accessors over TuningConfig.
std::string(* get)(const TuningConfig &)
Read the current option string.
bool(* set)(TuningConfig &, const std::string &)
Parse/apply an option; false if unparseable.
const char * name
YAML/HA parameter name (must match tuning.py).
bool applies_to_radio
True if changes must be re-applied to the radio.
Runtime tuning configuration for pairing and radio diagnostics.