Home IO Control
ESPHome add-on for IO-Homecontrol devices
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"
23
24namespace esphome {
25namespace 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)`.
33std::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
41class 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
60};
61
62/// @brief Button entity that registers a configured controller identity as a 1W controller.
63///
64/// A press sends `0x39` then `0x30`, back to back (OneWayTransmitter::send_enrollment()) — the
65/// documented 1W pairing handshake. The receiver's half of enrollment is a physical 2s PROG hold
66/// on the actuator itself; that physical requirement is the real interlock against a stray or
67/// unintended enrollment, not a software arming switch — see ADR 0026.
68/// @ingroup hioc_platforms
69class IOHomeOneWayEnrollButton : public button::Button, public Component, public OneWayControllerBound {
70 public:
71 void setup() override {}
72 void dump_config() override;
73
74 /// @brief Get setup priority so the parent hub is available first.
75 /// @return setup_priority::DATA.
76 [[nodiscard]] float get_setup_priority() const override { return setup_priority::DATA; }
77
78 protected:
79 /// @brief Queue the enrollment. It goes through the operation queue like all radio work, so it
80 /// cannot interleave with a 2W exchange (ADR 0013).
81 void press_action() override { this->parent_->send_oneway_enroll(this->controller_id_); }
82};
83
84/// @brief Diagnostic text sensor: what this identity last put on air.
85///
86/// **This is the only feedback 1W transmit can ever give.** There is no reply frame, so a command
87/// a device ignored is indistinguishable on the radio from one it obeyed. A user with a wrong key,
88/// a desynced counter or a missing enrollment would otherwise see nothing at all — not an error,
89/// not a timeout, nothing.
90///
91/// So this sensor deliberately does *not* claim the device acted, and its text must never be
92/// worded as if it did. It reports what the hub transmitted, which is the half that is knowable,
93/// and it surfaces the **sequence** used so a stuck user can judge whether the counter is the
94/// problem and whether `initial_sequence:` needs bumping.
95/// @ingroup hioc_platforms
96class IOHomeOneWayLastCommandTextSensor : public text_sensor::TextSensor,
97 public Component,
99 public:
100 /// @brief Subscribe to the hub's per-command reports.
101 void setup() override;
102
103 /// @brief Dump text-sensor configuration to the log.
104 void dump_config() override;
105
106 /// @brief Get setup priority so the parent hub is available first.
107 /// @return setup_priority::DATA.
108 [[nodiscard]] float get_setup_priority() const override { return setup_priority::DATA; }
109};
110
111} // namespace home_io_control
112} // namespace esphome
Button entity that sends one 1W command as a configured controller identity.
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
void set_action(OneWayButtonAction action)
Set which command a press sends.
Button entity that registers a configured controller identity as a 1W controller.
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
Diagnostic text sensor: what this identity last put on air.
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
void setup() override
Subscribe to the hub's per-command reports.
void dump_config() override
Dump text-sensor configuration to the log.
Mixin for the hub-level entities that additionally scope themselves to one oneway_controllers: identi...
OneWayButtonAction
The command a generated 1W button sends.
IO-Homecontrol ESPHome component — protocol controller.
std::string format_oneway_command_report(const OneWayCommandReport &report)
Build the sensor string for one command report.
Controller identities for the one-way (1W) protocol.
One-way (1W) transmit collaborator.
Shared device-binding mixins for IO-Homecontrol entity platforms.
What a 1W command attempt did — the only feedback this feature can ever produce.