Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
Loading...
Searching...
No Matches
platform_oneway_entities.h
Go to the documentation of this file.
1
#pragma once
2
3
/// @file platform_oneway_entities.h
4
/// @brief The per-identity 1W entities: command buttons, the enrollment button, and the
5
/// "Last 1W Command" diagnostic text sensor.
6
/// @ingroup hioc_platforms
7
///
8
/// All three are created from the hub's `oneway_controllers:` block, never declared as a
9
/// `button:` / `text_sensor:` platform entry — for the shared reason, see HubBoundEntity in
10
/// platform_entity_base.h.
11
///
12
/// All three scope themselves to one identity via OneWayControllerBound (parent + controller_id_).
13
14
#include <string>
15
16
#include "esphome/components/button/button.h"
17
#include "esphome/components/text_sensor/text_sensor.h"
18
#include "esphome/core/component.h"
19
#include "
hub_core.h
"
20
#include "
oneway_controller.h
"
21
#include "
oneway_transmitter.h
"
22
#include "
platform_entity_base.h
"
23
24
namespace
esphome
{
25
namespace
home_io_control
{
26
27
/// @brief Build the sensor string for one command report.
28
///
29
/// Pure and free-standing so the wording is unit-testable: the host ESP_LOG stub discards its
30
/// arguments, so a formatter buried in a publish call could not be asserted on at all.
31
/// @param report The attempt to describe.
32
/// @return Human-readable summary, e.g. `STOP -> awning seq 1234` or `STOP -> awning seq 1234 (not sent)`.
33
std::string
format_oneway_command_report
(
const
OneWayCommandReport
&report);
34
35
/// @brief Button entity that sends one 1W command as a configured controller identity.
36
///
37
/// A press is fire-and-forget. Nothing replies, so a press that a device ignores looks exactly
38
/// like one it obeyed — IOHomeOneWayLastCommandTextSensor reports what was transmitted, which is
39
/// the only half of that the hub can know.
40
/// @ingroup hioc_platforms
41
class
IOHomeOneWayCommandButton
:
public
button::Button,
public
Component,
public
OneWayControllerBound
{
42
public
:
43
/// @brief Set which command a press sends.
44
/// @param action Button action (see encode_oneway_action()).
45
void
set_action
(
OneWayButtonAction
action) { this->
action_
= action; }
46
47
void
setup
()
override
{}
48
void
dump_config
()
override
;
49
50
/// @brief Get setup priority so the parent hub is available first.
51
/// @return setup_priority::DATA.
52
[[nodiscard]]
float
get_setup_priority
()
const override
{
return
setup_priority::DATA; }
53
54
protected
:
55
/// @brief Queue the command. It goes through the operation queue like all radio work, so it
56
/// cannot interleave with a 2W exchange (ADR 0013).
57
void
press_action
()
override
{ this->
parent_
->
send_oneway_action
(this->
controller_id_
, this->
action_
); }
58
59
OneWayButtonAction
action_
{
OneWayButtonAction::STOP
};
60
};
61
62
/// @brief Button entity that registers a configured controller identity as a 1W controller.
63
///
64
/// A press sends the gesture its manufacturer expects (OneWayTransmitter::send_enrollment(), ADR
65
/// 0032). The receiver's half of enrollment is a physical gesture on the receiver side — a
66
/// multi-second PROG hold on the actuator (Somfy), or a ~1 s Gear press on an already-registered
67
/// control followed by the product's ready sequence (VELUX); that physical requirement is the real interlock against a
68
/// stray or unintended enrollment, not a software arming switch — see ADR 0026.
69
/// @ingroup hioc_platforms
70
class
IOHomeOneWayEnrollButton
:
public
button::Button,
public
Component,
public
OneWayControllerBound
{
71
public
:
72
void
setup
()
override
{}
73
void
dump_config
()
override
;
74
75
/// @brief Get setup priority so the parent hub is available first.
76
/// @return setup_priority::DATA.
77
[[nodiscard]]
float
get_setup_priority
()
const override
{
return
setup_priority::DATA; }
78
79
protected
:
80
/// @brief Queue the enrollment. It goes through the operation queue like all radio work, so it
81
/// cannot interleave with a 2W exchange (ADR 0013).
82
void
press_action
()
override
{ this->
parent_
->
send_oneway_enroll
(this->
controller_id_
); }
83
};
84
85
/// @brief Diagnostic text sensor: what this identity last put on air.
86
///
87
/// **This is the only feedback 1W transmit can ever give.** There is no reply frame, so a command
88
/// a device ignored is indistinguishable on the radio from one it obeyed. A user with a wrong key,
89
/// a desynced counter or a missing enrollment would otherwise see nothing at all — not an error,
90
/// not a timeout, nothing.
91
///
92
/// So this sensor deliberately does *not* claim the device acted, and its text must never be
93
/// worded as if it did. It reports what the hub transmitted, which is the half that is knowable,
94
/// and it surfaces the **sequence** used so a stuck user can judge whether the counter is the
95
/// problem and whether `initial_sequence:` needs bumping.
96
/// @ingroup hioc_platforms
97
class
IOHomeOneWayLastCommandTextSensor
:
public
text_sensor::TextSensor,
98
public
Component,
99
public
OneWayControllerBound
{
100
public
:
101
/// @brief Subscribe to the hub's per-command reports.
102
void
setup
()
override
;
103
104
/// @brief Dump text-sensor configuration to the log.
105
void
dump_config
()
override
;
106
107
/// @brief Get setup priority so the parent hub is available first.
108
/// @return setup_priority::DATA.
109
[[nodiscard]]
float
get_setup_priority
()
const override
{
return
setup_priority::DATA; }
110
};
111
112
}
// namespace home_io_control
113
}
// namespace esphome
esphome::home_io_control::HubBoundEntity::parent_
IOHomeControlComponent * parent_
Definition
platform_entity_base.h:201
esphome::home_io_control::IOHomeControlComponent::send_oneway_action
void send_oneway_action(const std::string &controller_id, OneWayButtonAction action)
Queue whichever of position/command a generated button's action resolves to.
Definition
hub_core.h:350
esphome::home_io_control::IOHomeControlComponent::send_oneway_enroll
void send_oneway_enroll(const std::string &controller_id)
Queue a 1W enrollment for the given controller identity — the enroll button's press handler.
Definition
hub_core.h:365
esphome::home_io_control::IOHomeOneWayCommandButton
Button entity that sends one 1W command as a configured controller identity.
Definition
platform_oneway_entities.h:41
esphome::home_io_control::IOHomeOneWayCommandButton::setup
void setup() override
Definition
platform_oneway_entities.h:47
esphome::home_io_control::IOHomeOneWayCommandButton::get_setup_priority
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
Definition
platform_oneway_entities.h:52
esphome::home_io_control::IOHomeOneWayCommandButton::press_action
void press_action() override
Queue the command.
Definition
platform_oneway_entities.h:57
esphome::home_io_control::IOHomeOneWayCommandButton::action_
OneWayButtonAction action_
Definition
platform_oneway_entities.h:59
esphome::home_io_control::IOHomeOneWayCommandButton::dump_config
void dump_config() override
Definition
platform_oneway_entities.cpp:28
esphome::home_io_control::IOHomeOneWayCommandButton::set_action
void set_action(OneWayButtonAction action)
Set which command a press sends.
Definition
platform_oneway_entities.h:45
esphome::home_io_control::IOHomeOneWayEnrollButton
Button entity that registers a configured controller identity as a 1W controller.
Definition
platform_oneway_entities.h:70
esphome::home_io_control::IOHomeOneWayEnrollButton::dump_config
void dump_config() override
Definition
platform_oneway_entities.cpp:34
esphome::home_io_control::IOHomeOneWayEnrollButton::get_setup_priority
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
Definition
platform_oneway_entities.h:77
esphome::home_io_control::IOHomeOneWayEnrollButton::press_action
void press_action() override
Queue the enrollment.
Definition
platform_oneway_entities.h:82
esphome::home_io_control::IOHomeOneWayEnrollButton::setup
void setup() override
Definition
platform_oneway_entities.h:72
esphome::home_io_control::IOHomeOneWayLastCommandTextSensor
Diagnostic text sensor: what this identity last put on air.
Definition
platform_oneway_entities.h:99
esphome::home_io_control::IOHomeOneWayLastCommandTextSensor::get_setup_priority
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
Definition
platform_oneway_entities.h:109
esphome::home_io_control::IOHomeOneWayLastCommandTextSensor::setup
void setup() override
Subscribe to the hub's per-command reports.
Definition
platform_oneway_entities.cpp:39
esphome::home_io_control::IOHomeOneWayLastCommandTextSensor::dump_config
void dump_config() override
Dump text-sensor configuration to the log.
Definition
platform_oneway_entities.cpp:51
esphome::home_io_control::OneWayControllerBound
Mixin for the hub-level entities that additionally scope themselves to one oneway_controllers: identi...
Definition
platform_entity_base.h:211
esphome::home_io_control::OneWayControllerBound::controller_id_
std::string controller_id_
Definition
platform_entity_base.h:218
esphome::home_io_control::OneWayButtonAction
OneWayButtonAction
The command a generated 1W button sends.
Definition
oneway_controller.h:266
esphome::home_io_control::OneWayButtonAction::STOP
@ STOP
CoverCommand::STOP.
Definition
oneway_controller.h:269
hub_core.h
IO-Homecontrol ESPHome component — protocol controller.
esphome::home_io_control
Definition
device_registry.cpp:13
esphome::home_io_control::format_oneway_command_report
std::string format_oneway_command_report(const OneWayCommandReport &report)
Build the sensor string for one command report.
Definition
platform_oneway_entities.cpp:12
esphome
Definition
device_registry.cpp:12
oneway_controller.h
Controller identities for the one-way (1W) protocol.
oneway_transmitter.h
One-way (1W) transmit collaborator.
platform_entity_base.h
Shared device-binding mixins for IO-Homecontrol entity platforms.
esphome::home_io_control::OneWayCommandReport
What a 1W command attempt did — the only feedback this feature can ever produce.
Definition
oneway_transmitter.h:44
components
home_io_control
platform_oneway_entities.h
Generated by
1.18.0