Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_lr1121_bootloader_rewrite_switch.h
Go to the documentation of this file.
1
#pragma once
2
3
/// @file platform_lr1121_bootloader_rewrite_switch.h
4
/// @brief Hub-level arming switch for the LR1121 bootloader-rewrite (three-stage) sequence.
5
/// @ingroup hioc_platforms
6
///
7
/// Like IOHomeAcceptForeignPairingSwitch and IOHomeLr1121FirmwareUpdateButton, this entity is
8
/// hub-level, not device-bound. It is created dynamically from the presence of
9
/// `home_io_control.lr1121_firmware_update.bootloader:` (see `__init__.py`'s
10
/// `_create_lr1121_bootloader_update()`), bound directly to the hub instance being built.
11
///
12
/// This is a *permission*, not the two-press "armed" confirmation used elsewhere in this
13
/// component (`lr1121_flash_confirmation_armed_`) -- see ADR 0021 for why an arming switch
14
/// (visible in Home Assistant, so "is this armed?" is answerable by looking) was chosen over
15
/// another invisible two-press window for the one operation in this component with no undo. It
16
/// can only convert a cached `BootloaderUpgradePath::AVAILABLE` verdict into "run the three-stage
17
/// sequence"; it never affects any other verdict or guard (see
18
/// IOHomeControlComponent::set_bootloader_rewrite_allowed()).
19
20
// IOHOME_LR1121_BOOTLOADER_UPDATE is only visible after something pulls in esphome/core/defines.h
21
// (via hub_core.h's own #include "esphome/core/hal.h") — these #includes must run before the
22
// #ifdef check, not after (see radio_lr1121_firmware_updater.h for the fuller explanation of why
23
// this ordering matters and how it stayed invisible in host unit tests).
24
#include "esphome/components/switch/switch.h"
25
#include "
hub_core.h
"
26
27
#ifdef IOHOME_LR1121_BOOTLOADER_UPDATE
28
29
namespace
esphome
{
30
namespace
home_io_control
{
31
32
/// @brief Hub-level switch entity: ON permits the next flash-button press to run the three-stage
33
/// bootloader-rewrite sequence (when the cached verdict is AVAILABLE); OFF (the default, and the
34
/// restore-on-boot state -- `ALWAYS_OFF`) refuses it. No auto-off timer: see ADR 0021 for why the
35
/// window is already self-limiting.
36
/// @ingroup hioc_platforms
37
class
IOHomeLr1121BootloaderRewriteSwitch
:
public
switch_::Switch,
public
Component {
38
public
:
39
/// @brief Set the parent controller component.
40
/// @param parent Pointer to the IOHomeControlComponent instance.
41
void
set_parent(IOHomeControlComponent *parent) { this->parent_ = parent; }
42
43
/// @brief Publish the initial OFF state.
44
///
45
/// Unlike IOHomeAcceptForeignPairingSwitch, this switch has no auto-off timer, so the hub never
46
/// changes the permission on its own and there is no state to push back -- but an entity that
47
/// has never published reads as *unknown* in Home Assistant, and a safety control whose whole
48
/// justification is "is this armed? answerable by looking" (ADR 0021) must not render blank.
49
/// Publishing false also makes the configured ALWAYS_OFF restore behaviour observable rather
50
/// than merely implied. Publishing does not call write_state(), so this never touches the hub.
51
void
setup()
override
;
52
53
/// @brief Dump configuration to the log.
54
void
dump_config()
override
;
55
56
/// @brief Get setup priority so the parent hub is available first.
57
/// @return setup_priority::DATA.
58
[[nodiscard]]
float
get_setup_priority()
const override
{
return
setup_priority::DATA; }
59
60
protected
:
61
/// @brief Forward the toggle to the hub as a permission -- see
62
/// IOHomeControlComponent::set_bootloader_rewrite_allowed().
63
/// @param state Desired switch state.
64
void
write_state(
bool
state)
override
;
65
66
IOHomeControlComponent
*parent_{
nullptr
};
67
};
68
69
}
// namespace home_io_control
70
}
// namespace esphome
71
72
#endif
// IOHOME_LR1121_BOOTLOADER_UPDATE
hub_core.h
IO-Homecontrol ESPHome component — protocol controller.
esphome::home_io_control
Definition
device_registry.cpp:13
esphome
Definition
device_registry.cpp:12
home_io_control.IOHomeLr1121BootloaderRewriteSwitch
IOHomeLr1121BootloaderRewriteSwitch
Definition
__init__.py:109
home_io_control.IOHomeControlComponent
IOHomeControlComponent
Definition
__init__.py:85
components
home_io_control
platform_lr1121_bootloader_rewrite_switch.h
Generated by
1.16.1