Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
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
5
#include "
platform_hub_controls.h
"
6
7
#include "esphome/core/log.h"
8
9
namespace
esphome
{
10
namespace
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
17
void
HubArmingSwitch::setup
() {
18
if
(this->
parent_
==
nullptr
)
19
return
;
20
this->
subscribe_armed
([
this
](
bool
armed) { this->publish_state(armed); });
21
}
22
23
void
HubArmingSwitch::write_state
(
bool
state) {
24
if
(this->
parent_
!=
nullptr
)
25
this->
arm
(state);
26
this->publish_state(state);
27
}
28
29
void
IOHomeAcceptForeignPairingSwitch::dump_config
() {
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
35
void
IOHomeRecoverOneWayKeySwitch::dump_config
() {
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
41
void
IOHomePairingResultTextSensor::setup
() {
42
if
(this->
parent_
==
nullptr
)
43
return
;
44
45
this->
parent_
->
set_pairing_result_callback
([
this
]() { this->
on_pairing_result_
(); });
46
}
47
48
void
IOHomePairingResultTextSensor::dump_config
() {
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
55
void
IOHomePairingResultTextSensor::on_pairing_result_
() {
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
esphome::home_io_control::HubArmingSwitch::arm
virtual void arm(bool state)=0
Arm or disarm this switch's listener on the hub.
esphome::home_io_control::HubArmingSwitch::write_state
void write_state(bool state) final
Forward the toggle to the hub and publish the state.
Definition
platform_hub_controls.cpp:23
esphome::home_io_control::HubArmingSwitch::subscribe_armed
virtual void subscribe_armed(std::function< void(bool)> callback)=0
Subscribe callback to the hub's armed-state changes for this listener.
esphome::home_io_control::HubArmingSwitch::setup
void setup() final
Register the armed-state callback so this entity mirrors the hub's own disarm events.
Definition
platform_hub_controls.cpp:17
esphome::home_io_control::HubBoundEntity::parent_
IOHomeControlComponent * parent_
Definition
platform_entity_base.h:201
esphome::home_io_control::IOHomeAcceptForeignPairingSwitch::dump_config
void dump_config() override
Dump configuration to the log.
Definition
platform_hub_controls.cpp:29
esphome::home_io_control::IOHomeControlComponent::pairing_telemetry
const PairingTelemetry & pairing_telemetry() const
Definition
hub_core.h:392
esphome::home_io_control::IOHomeControlComponent::set_pairing_result_callback
void set_pairing_result_callback(std::function< void()> cb)
Register a callback invoked once, right after every discover_and_pair() attempt completes — used by t...
Definition
hub_core.h:398
esphome::home_io_control::IOHomePairingResultTextSensor::setup
void setup() override
Register the pairing-result callback.
Definition
platform_hub_controls.cpp:41
esphome::home_io_control::IOHomePairingResultTextSensor::on_pairing_result_
void on_pairing_result_()
Publish the latest pairing telemetry result string.
Definition
platform_hub_controls.cpp:55
esphome::home_io_control::IOHomePairingResultTextSensor::dump_config
void dump_config() override
Dump text-sensor configuration to the log.
Definition
platform_hub_controls.cpp:48
esphome::home_io_control::IOHomeRecoverOneWayKeySwitch::dump_config
void dump_config() override
Dump configuration to the log.
Definition
platform_hub_controls.cpp:35
esphome::home_io_control::PairingTelemetry::result_sensor_string
std::string result_sensor_string() const
Render the frozen v1; machine-readable result string.
Definition
pairing_telemetry.cpp:206
esphome::home_io_control
Definition
device_registry.cpp:13
esphome
Definition
device_registry.cpp:12
platform_hub_controls.h
Hub-level control entities: the discovery button, the scan-paired-devices button, the two arming swit...
components
home_io_control
platform_hub_controls.cpp
Generated by
1.18.0