Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
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
"
19
#include "
platform_entity_base.h
"
20
#include "
proto_device_model.h
"
21
22
namespace
esphome
{
23
namespace
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
34
class
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
56
CoverCommand
command_
{
CoverCommand::FAVORITE
};
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.
71
class
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
esphome::home_io_control::DeviceBoundCompanion
Mixin holding the parent + device-id binding shared by per-device entities that are not full entity p...
Definition
platform_entity_base.h:139
esphome::home_io_control::IOHomeCoverCommandButton
Button entity that sends one non-positional cover command on press.
Definition
platform_cover_controls.h:34
esphome::home_io_control::IOHomeCoverCommandButton::setup
void setup() override
Initialize the generated button.
Definition
platform_cover_controls.h:42
esphome::home_io_control::IOHomeCoverCommandButton::get_setup_priority
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
Definition
platform_cover_controls.h:49
esphome::home_io_control::IOHomeCoverCommandButton::set_command
void set_command(CoverCommand command)
Set which cover command a press sends.
Definition
platform_cover_controls.h:39
esphome::home_io_control::IOHomeCoverCommandButton::command_
CoverCommand command_
Definition
platform_cover_controls.h:56
esphome::home_io_control::IOHomeCoverCommandButton::press_action
void press_action() override
Handle a Home Assistant button press by queueing this button's cover command, which is then sent to t...
Definition
platform_cover_controls.cpp:18
esphome::home_io_control::IOHomeCoverCommandButton::dump_config
void dump_config() override
Dump button configuration to the log.
Definition
platform_cover_controls.cpp:34
esphome::home_io_control::IOHomeCoverSilentSwitch
Switch entity that selects a cover's travel profile at runtime.
Definition
platform_cover_controls.h:71
esphome::home_io_control::IOHomeCoverSilentSwitch::get_setup_priority
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
Definition
platform_cover_controls.h:81
esphome::home_io_control::IOHomeCoverSilentSwitch::write_state
void write_state(bool state) override
Apply the requested travel profile to the bound device.
Definition
platform_cover_controls.cpp:48
esphome::home_io_control::IOHomeCoverSilentSwitch::setup
void setup() override
Publish the boot state declared in YAML so Home Assistant starts in sync.
Definition
platform_cover_controls.cpp:39
esphome::home_io_control::IOHomeCoverSilentSwitch::dump_config
void dump_config() override
Dump switch configuration to the log.
Definition
platform_cover_controls.cpp:56
hub_core.h
IO-Homecontrol ESPHome component — protocol controller.
esphome::home_io_control
Definition
device_registry.cpp:13
esphome::home_io_control::CoverCommand
CoverCommand
Named device commands for cover-type actuators.
Definition
proto_device_model.h:215
esphome::home_io_control::CoverCommand::FAVORITE
@ FAVORITE
Move to stored favorite/"My" position.
Definition
proto_device_model.h:217
esphome
Definition
device_registry.cpp:12
platform_entity_base.h
Shared device-binding mixins for IO-Homecontrol entity platforms.
proto_device_model.h
IO-Homecontrol device-type model, capabilities and runtime device state.
components
home_io_control
platform_cover_controls.h
Generated by
1.18.0