Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_accept_foreign_pairing_switch.h
Go to the documentation of this file.
1#pragma once
2
3/// @file platform_accept_foreign_pairing_switch.h
4/// @brief Hub-level switch that arms/disarms the "Accept Foreign Pairing" (key-extraction)
5/// responder.
6/// @ingroup hioc_platforms
7///
8/// Unlike IOHomeSwitch (platform_switch.h), this entity is hub-level, not device-bound — it has
9/// no `io_device_id` and isn't declared through a `switch:` platform entry at all. It is created
10/// dynamically from `home_io_control.accept_foreign_pairing: true` (see `__init__.py`'s
11/// `_create_accept_foreign_pairing_switch()`), the same way `tuning: {ui_controls: true}`
12/// dynamically creates its number/select entities, and bound directly to the hub instance being
13/// built (`set_parent()` called with that same object). See hub_key_extraction.cpp for what
14/// arming actually does.
15///
16/// @note Hardware-confirmed on real RF hardware, but not yet against a third-party hub — see
17/// hub_key_extraction.cpp.
18
19#include "esphome/components/switch/switch.h"
20#include "esphome/core/component.h"
21#include "hub_core.h"
22
23namespace esphome {
24namespace home_io_control {
25
26/// @brief Hub-level switch entity: ON arms the key-extraction responder for 10 minutes, OFF
27/// disarms it immediately. Publishes its own state changes when the hub disarms itself
28/// (successful extraction or auto-off timeout), not just on a user-initiated toggle.
29/// @ingroup hioc_platforms
30class IOHomeAcceptForeignPairingSwitch : public switch_::Switch, public Component {
31 public:
32 /// @brief Set the parent controller component.
33 /// @param parent Pointer to the IOHomeControlComponent instance.
34 void set_parent(IOHomeControlComponent *parent) { this->parent_ = parent; }
35
36 /// @brief Register the armed-state callback so this entity mirrors the hub's own disarm events.
37 void setup() override;
38
39 /// @brief Dump configuration to the log.
40 void dump_config() override;
41
42 /// @brief Get setup priority so the parent hub is available first.
43 /// @return setup_priority::DATA.
44 [[nodiscard]] float get_setup_priority() const override { return setup_priority::DATA; }
45
46 protected:
47 /// @brief Arm or disarm the hub's key-extraction responder.
48 /// @param state Desired switch state.
49 void write_state(bool state) override;
50
52};
53
54} // namespace home_io_control
55} // namespace esphome
Hub-level switch entity: ON arms the key-extraction responder for 10 minutes, OFF disarms it immediat...
void write_state(bool state) override
Arm or disarm the hub's key-extraction responder.
void setup() override
Register the armed-state callback so this entity mirrors the hub's own disarm events.
void set_parent(IOHomeControlComponent *parent)
Set the parent controller component.
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
The main IO-Homecontrol component.
Definition hub_core.h:74
IO-Homecontrol ESPHome component — protocol controller.