6#include "esphome/core/log.h"
11static const char *
const TAG =
"home_io_control.cover";
20 this->
parent_->register_device_callback(
29 auto traits = cover::CoverTraits();
30 traits.set_supports_position(
true);
31 traits.set_supports_stop(
true);
33 traits.set_is_assumed_state(
false);
50 return dev !=
nullptr && dev->inverted;
54 if (call.get_stop()) {
59 const auto &tilt_opt = call.get_tilt();
60 if (tilt_opt.has_value()) {
61 auto const tilt =
static_cast<uint8_t
>(*tilt_opt * 100.0F);
66 const auto &position_opt = call.get_position();
67 if (position_opt.has_value()) {
68 float const ha_pos = *position_opt;
77 io_pos = (uint8_t) (ha_pos * 100.0F);
79 io_pos = (uint8_t) ((1.0F - ha_pos) * 100.0F);
98 ha_pos = 1.0F - (dev.
position / 100.0F);
101 this->position = ha_pos;
105 this->tilt = dev.
tilt / 100.0F;
110 this->current_operation = cover::COVER_OPERATION_IDLE;
114 this->current_operation =
115 (dev.
target > dev.
position) ? cover::COVER_OPERATION_OPENING : cover::COVER_OPERATION_CLOSING;
118 this->current_operation =
119 (dev.
target < dev.
position) ? cover::COVER_OPERATION_OPENING : cover::COVER_OPERATION_CLOSING;
123 this->publish_state();
127 LOG_COVER(
"",
"IO-Homecontrol Cover",
this);
128 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
131 ESP_LOGCONFIG(
TAG,
" Status Poll Interval: default single settle poll");
IOHomeControlComponent * parent_
bool supports_tilt() const
Query whether this device supports tilt (slat angle) control.
void on_device_update_(const std::string &id, const IoDevice &dev)
Callback invoked when the underlying device state changes.
bool effective_invert_() const
Resolve the current inversion mode.
cover::CoverTraits get_traits() override
Return the traits object describing this cover's capabilities.
void setup() override
Initialize the cover entity (register device, subscribe to updates, schedule initial status poll).
uint32_t status_poll_interval_ms_
void dump_config() override
Dump configuration to log.
void control(const cover::CoverCall &call) override
Handle cover commands from Home Assistant (open/close/stop/set_position).
Internal helpers shared by the hub implementation .cpp files.
constexpr uint32_t INITIAL_STATUS_REQUEST_DELAY_MS
Delay before the first post-boot status request from an entity.
static constexpr float UNKNOWN_POSITION
Sentinel value meaning "position is not known yet".
bool default_inverted_for_type(DeviceType type)
Determine whether a device type has inverted position mapping by default.
static constexpr uint8_t POS_STOP
Position values in the IO protocol.
bool device_supports_tilt(DeviceType type)
Does this device type support tilt (slat angle) control?
static const char *const TAG
Runtime state of a paired IO‑Homecontrol device.
float target
Target position the device is moving toward.
float tilt
Current tilt: 0=closed, 100=open, or UNKNOWN_POSITION.
float position
Current position: 0=open, 100=closed, or UNKNOWN_POSITION.
bool is_stopped
True if device is not moving.