Home IO Control
ESPHome add-on for IO-Homecontrol devices
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
6
7#include "esphome/core/log.h"
8
9namespace esphome {
10namespace 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.
15static const char *const TAG_COMMAND_BUTTON = "home_io_control.cover_command_button";
16static const char *const TAG_SILENT = "home_io_control.cover.silent";
17
19 if (this->parent_ == nullptr) {
20 ESP_LOGW(TAG_COMMAND_BUTTON, "Ignoring %s press because the parent hub is not configured",
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
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
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
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
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
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.
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.
static const char *const TAG_COMMAND_BUTTON
static const char *const TAG_SILENT
const char * cover_command_name(CoverCommand cmd)
Get a human-readable name for a CoverCommand.
Generated per-cover auxiliary controls: the command button (favorite / ventilation) and the silent-op...
Runtime state of a paired IO‑Homecontrol device.