Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_hub_controls.cpp
Go to the documentation of this file.
1/// @file platform_hub_controls.cpp
2/// @brief Hub-level control entities: arming switches and the pairing-result text sensor.
3/// @ingroup hioc_platforms
4
6
7#include "esphome/core/log.h"
8
9namespace esphome {
10namespace home_io_control {
11
12// Each dump_config() keeps its own log tag as a `static` function-local constant: the ESPHome
13// LOG_SWITCH / LOG_TEXT_SENSOR macros expand to a bare `TAG` identifier, so one shared file-scope
14// constant could not carry the different values. Values are unchanged from the former per-entity
15// files. (`static` so clang-tidy's identifier-naming check treats it as a StaticConstant.)
16
18 if (this->parent_ == nullptr)
19 return;
20 this->subscribe_armed([this](bool armed) { this->publish_state(armed); });
21}
22
24 if (this->parent_ != nullptr)
25 this->arm(state);
26 this->publish_state(state);
27}
28
30 static const char *const TAG = "home_io_control.key_extraction_switch";
31 LOG_SWITCH("", "IO-Homecontrol Recover System Key (Key Extraction)", this);
32 ESP_LOGCONFIG(TAG, " Status: hardware-confirmed protocol; not yet confirmed against a third-party hub");
33}
34
36 static const char *const TAG = "home_io_control.oneway_key_switch";
37 LOG_SWITCH("", "IO-Homecontrol Recover 1W Controller Key", this);
38 ESP_LOGCONFIG(TAG, " Receive-only: listens for an add-controller broadcast, never transmits");
39}
40
42 if (this->parent_ == nullptr)
43 return;
44
45 this->parent_->set_pairing_result_callback([this]() { this->on_pairing_result_(); });
46}
47
49 // [[maybe_unused]]: LOG_TEXT_SENSOR consumes TAG only in the firmware build; the host stub
50 // expands it away, and there is no ESP_LOGCONFIG line here to reference it.
51 [[maybe_unused]] static const char *const TAG = "home_io_control.pairing_result";
52 LOG_TEXT_SENSOR("", "IO-Homecontrol Last Pairing Result", this);
53}
54
56 if (this->parent_ == nullptr)
57 return;
58 this->publish_state(this->parent_->pairing_telemetry().result_sensor_string());
59}
60
61} // namespace home_io_control
62} // namespace esphome
virtual void arm(bool state)=0
Arm or disarm this switch's listener on the hub.
void write_state(bool state) final
Forward the toggle to the hub and publish the state.
virtual void subscribe_armed(std::function< void(bool)> callback)=0
Subscribe callback to the hub's armed-state changes for this listener.
void setup() final
Register the armed-state callback so this entity mirrors the hub's own disarm events.
void dump_config() override
Dump configuration to the log.
void setup() override
Register the pairing-result callback.
void on_pairing_result_()
Publish the latest pairing telemetry result string.
void dump_config() override
Dump text-sensor configuration to the log.
void dump_config() override
Dump configuration to the log.
static constexpr const char * TAG
Hub-level control entities: the discovery button, the scan-paired-devices button, the two arming swit...