Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_cover_controls.h
Go to the documentation of this file.
1#pragma once
2
3/// @file platform_cover_controls.h
4/// @brief Generated per-cover auxiliary controls: the command button (favorite / ventilation)
5/// and the silent-operation toggle.
6/// @ingroup hioc_platforms
7///
8/// Both are device-bound companions (DeviceBoundCompanion), generated alongside a `cover:` entity
9/// by cover.py when the device type supports them, and both act on an already-registered device
10/// rather than owning one. They live together here because they are the cover platform's small
11/// auxiliary surface, not full entity platforms of their own.
12
13#include <string>
14
15#include "esphome/components/button/button.h"
16#include "esphome/components/switch/switch.h"
17#include "esphome/core/component.h"
18#include "hub_core.h"
20#include "proto_device_model.h"
21
22namespace esphome {
23namespace home_io_control {
24
25/// @brief Button entity that sends one non-positional cover command on press.
26///
27/// One class covers both companions the cover platform generates: codegen calls set_command()
28/// with CoverCommand::FAVORITE for the favorite/"My"-position button (position-capable device
29/// types) and CoverCommand::VENT for the ventilation button (window-type devices —
30/// WINDOW_OPENER, VENTILATION_POINT — where the vent command moves the actuator to a predefined
31/// partially-open position suitable for air exchange). The press path, the parent/device guards
32/// and the log wording are identical for both; only the command byte differs.
33/// @ingroup hioc_platforms
34class IOHomeCoverCommandButton : public button::Button, public Component, public DeviceBoundCompanion {
35 public:
36 /// @brief Set which cover command a press sends.
37 /// @param command CoverCommand::FAVORITE for the favorite-position companion,
38 /// CoverCommand::VENT for the ventilation companion.
39 void set_command(CoverCommand command) { this->command_ = command; }
40
41 /// @brief Initialize the generated button.
42 void setup() override {}
43
44 /// @brief Dump button configuration to the log.
45 void dump_config() override;
46
47 /// @brief Get setup priority so the parent hub is available first.
48 /// @return setup_priority::DATA.
49 [[nodiscard]] float get_setup_priority() const override { return setup_priority::DATA; }
50
51 protected:
52 /// @brief Handle a Home Assistant button press by queueing this button's cover command, which
53 /// is then sent to the device via the authenticated exchange like any other cover command.
54 void press_action() override;
55
57};
58
59/// @brief Switch entity that selects a cover's travel profile at runtime.
60/// @ingroup hioc_platforms
61///
62/// ON sends position commands with the manufacturer app's "silent operation" extended block, which
63/// makes the motor travel more slowly; OFF sends the normal payload. Only generated when the cover
64/// declares `silent:` in YAML, so a config that never mentions it gains no entity — the YAML value
65/// is the boot state and this switch moves it afterwards.
66///
67/// Device-bound like IOHomeCoverCommandButton rather than hub-level like
68/// IOHomeAcceptForeignPairingSwitch: the setting is per actuator. Nothing on the wire reports a
69/// device's current profile, so this reflects only what this hub has been told to send — there is
70/// no readback to reconcile against, and none is faked.
71class IOHomeCoverSilentSwitch : public switch_::Switch, public Component, public DeviceBoundCompanion {
72 public:
73 /// @brief Publish the boot state declared in YAML so Home Assistant starts in sync.
74 void setup() override;
75
76 /// @brief Dump switch configuration to the log.
77 void dump_config() override;
78
79 /// @brief Get setup priority so the parent hub is available first.
80 /// @return setup_priority::DATA.
81 [[nodiscard]] float get_setup_priority() const override { return setup_priority::DATA; }
82
83 protected:
84 /// @brief Apply the requested travel profile to the bound device.
85 /// @param state True for silent (slower) operation.
86 void write_state(bool state) override;
87};
88
89} // namespace home_io_control
90} // namespace esphome
Mixin holding the parent + device-id binding shared by per-device entities that are not full entity p...
Button entity that sends one non-positional cover command on press.
void setup() override
Initialize the generated button.
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
void set_command(CoverCommand command)
Set which cover command a press sends.
void press_action() override
Handle a Home Assistant button press by queueing this button's cover command, which is then sent to t...
void dump_config() override
Dump button configuration to the log.
Switch entity that selects a cover's travel profile at runtime.
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
void write_state(bool state) override
Apply the requested travel profile to the bound device.
void setup() override
Publish the boot state declared in YAML so Home Assistant starts in sync.
void dump_config() override
Dump switch configuration to the log.
IO-Homecontrol ESPHome component — protocol controller.
CoverCommand
Named device commands for cover-type actuators.
@ FAVORITE
Move to stored favorite/"My" position.
Shared device-binding mixins for IO-Homecontrol entity platforms.
IO-Homecontrol device-type model, capabilities and runtime device state.