Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
Loading...
Searching...
No Matches
platform_cover_controls.cpp
Go to the documentation of this file.
1
/// @file platform_cover_controls.cpp
2
/// @brief Generated per-cover auxiliary controls: command button and silent-operation toggle.
3
/// @ingroup hioc_platforms
4
5
#include "
platform_cover_controls.h
"
6
7
#include "esphome/core/log.h"
8
9
namespace
esphome
{
10
namespace
home_io_control
{
11
12
// One tag for the merged command button. The former per-button tags (home_io_control.favorite_button
13
// / home_io_control.vent_button) both retire with the class merge; a user greps for the entity by
14
// name, not by log tag, and this reads correctly for either command.
15
static
const
char
*
const
TAG_COMMAND_BUTTON
=
"home_io_control.cover_command_button"
;
16
static
const
char
*
const
TAG_SILENT
=
"home_io_control.cover.silent"
;
17
18
void
IOHomeCoverCommandButton::press_action
() {
19
if
(this->
parent_
==
nullptr
) {
20
ESP_LOGW(
TAG_COMMAND_BUTTON
,
"Ignoring %s press because the parent hub is not configured"
,
21
cover_command_name
(this->
command_
));
22
return
;
23
}
24
25
if
(this->
parent_
->
get_device
(this->device_id_) ==
nullptr
) {
26
ESP_LOGW(
TAG_COMMAND_BUTTON
,
"Ignoring %s press for %s because the device is not registered yet"
,
27
cover_command_name
(this->
command_
), this->
device_id_
.c_str());
28
return
;
29
}
30
31
this->
parent_
->
queue_device_command
(this->
device_id_
, this->
command_
);
32
}
33
34
void
IOHomeCoverCommandButton::dump_config
() {
35
ESP_LOGCONFIG(
TAG_COMMAND_BUTTON
,
"IO-Homecontrol %s Position Button"
,
cover_command_name
(this->
command_
));
36
ESP_LOGCONFIG(
TAG_COMMAND_BUTTON
,
" Device ID: %s"
, this->
device_id_
.c_str());
37
}
38
39
void
IOHomeCoverSilentSwitch::setup
() {
40
// The YAML value was already applied to the device at registration; mirror it outward so Home
41
// Assistant does not start out disagreeing with what the hub will actually send.
42
if
(this->
parent_
==
nullptr
)
43
return
;
44
if
(
const
IoDevice
*dev = this->
parent_
->
get_device
(this->device_id_); dev !=
nullptr
)
45
this->publish_state(dev->silent);
46
}
47
48
void
IOHomeCoverSilentSwitch::write_state
(
bool
state) {
49
if
(this->
parent_
==
nullptr
)
50
return
;
51
this->
parent_
->
set_device_silent
(this->
device_id_
, state);
52
this->publish_state(state);
53
ESP_LOGI(
TAG_SILENT
,
"Device %s: silent operation %s"
, this->
device_id_
.c_str(), state ?
"on"
:
"off"
);
54
}
55
56
void
IOHomeCoverSilentSwitch::dump_config
() {
57
ESP_LOGCONFIG(
TAG_SILENT
,
"IO-Homecontrol Silent Operation:"
);
58
ESP_LOGCONFIG(
TAG_SILENT
,
" Device ID: %s"
, this->
device_id_
.c_str());
59
}
60
61
}
// namespace home_io_control
62
}
// namespace esphome
esphome::home_io_control::DeviceBoundCompanion::device_id_
std::string device_id_
Definition
platform_entity_base.h:169
esphome::home_io_control::DeviceBoundCompanion::parent_
IOHomeControlComponent * parent_
Definition
platform_entity_base.h:168
esphome::home_io_control::IOHomeControlComponent::get_device
virtual IoDevice * get_device(const std::string &device_id)
Retrieve a device by ID; returns nullptr if not found.
Definition
hub_core.cpp:334
esphome::home_io_control::IOHomeControlComponent::queue_device_command
virtual bool queue_device_command(const std::string &device_id, CoverCommand cmd)
Queue an async named command (STOP, FAVORITE, VENT, FORCE_OPEN); returns immediately,...
Definition
hub_operations.cpp:572
esphome::home_io_control::IOHomeControlComponent::set_device_silent
virtual void set_device_silent(const std::string &device_id, bool silent)
Select a device's travel profile at runtime (see IOHomeCoverSilentSwitch).
Definition
hub_core.cpp:340
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::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
esphome::home_io_control
Definition
device_registry.cpp:13
esphome::home_io_control::TAG_COMMAND_BUTTON
static const char *const TAG_COMMAND_BUTTON
Definition
platform_cover_controls.cpp:15
esphome::home_io_control::TAG_SILENT
static const char *const TAG_SILENT
Definition
platform_cover_controls.cpp:16
esphome::home_io_control::cover_command_name
const char * cover_command_name(CoverCommand cmd)
Get a human-readable name for a CoverCommand.
Definition
proto_device_model.cpp:46
esphome
Definition
device_registry.cpp:12
platform_cover_controls.h
Generated per-cover auxiliary controls: the command button (favorite / ventilation) and the silent-op...
esphome::home_io_control::IoDevice
Runtime state of a paired IO‑Homecontrol device.
Definition
proto_device_model.h:321
components
home_io_control
platform_cover_controls.cpp
Generated by
1.18.0