8#include "esphome/core/log.h"
19static const char *
const TAG_SILENT =
"home_io_control.cover.silent";
21static const char *
const TAG_RAIN =
"home_io_control.cover.rain_sensor";
22static const char *
const TAG_BATTERY =
"home_io_control.cover.battery";
23static const char *
const TAG_SUN_LEVEL =
"home_io_control.cover.sun_level";
28 ESP_LOGW(
TAG_COMMAND_BUTTON,
"Ignoring %s press because the parent hub is not configured",
34 ESP_LOGW(
TAG_COMMAND_BUTTON,
"Ignoring %s press for %s because the device is not registered yet",
60 this->publish_state(state);
61 ESP_LOGI(
TAG_SILENT,
"Device %s: silent operation %s", this->
device_id_.c_str(), state ?
"on" :
"off");
65 ESP_LOGCONFIG(
TAG_SILENT,
"IO-Homecontrol Silent Operation:");
88 this->publish_state(value);
104 this->publish_state(
true);
107 this->publish_state(
false);
111 this->invalidate_state();
117 ESP_LOGCONFIG(
TAG_RAIN,
"IO-Homecontrol Rain Sensor:");
129 this->publish_state(dev.
sun_level.has_value() ?
static_cast<float>(*dev.
sun_level) : NAN);
135 LOG_SENSOR(
"",
"IO-Homecontrol Sun Level",
this);
136 ESP_LOGCONFIG(TAG,
" Device ID: %s", this->
device_id_.c_str());
151 LOG_SENSOR(
"",
"IO-Homecontrol Battery Level",
this);
152 ESP_LOGCONFIG(TAG,
" Device ID: %s", this->
device_id_.c_str());
162 this->publish_state(
true);
166 this->publish_state(
false);
172 this->invalidate_state();
174 if (dev.
last_status != 0 && !this->logged_not_reported_) {
176 ESP_LOGI(
TAG_BATTERY,
"Device %s reports no battery state; it is probably mains powered", this->
device_id_.c_str());
181 ESP_LOGCONFIG(
TAG_BATTERY,
"IO-Homecontrol Battery Low:");
193 ESP_LOGCONFIG(
TAG_BATTERY,
"IO-Homecontrol Battery:");
void register_companion_binding_(const std::function< void(const IoDevice &)> &publish)
Shared setup() body: subscribe to this device's updates and publish the initial state.
IOHomeControlComponent * parent_
void setup() override
Subscribe to the device's updates and publish what is already known.
std::optional< uint16_t > published_
Last value handed to publish_state(); avoids re-publishing on every update.
bool published_once_
True once anything (a value or "unknown") was published.
void dump_config() override
Dump sensor configuration to the log.
void setup() override
Subscribe to the device's updates and publish what is already known.
void dump_config() override
Dump sensor configuration to the log.
void publish_battery_(const IoDevice &dev)
Publish from a device record: ON for LOW_CHARGE, OFF for NORMAL/FULL, no state otherwise.
bool logged_not_reported_
The "reports no battery" INFO line was written once already.
void setup() override
Subscribe to the device's updates and publish what is already known.
void dump_config() override
Dump sensor configuration to the log.
virtual IoDevice * get_device(const std::string &device_id)
Retrieve a device by ID; returns nullptr if not found.
virtual void set_device_travel_speed(const std::string &device_id, TravelSpeed speed)
Select a device's travel speed at runtime (see IOHomeCoverTravelSpeedSelect and IOHomeCoverSilentSwit...
virtual bool queue_device_command(const std::string &device_id, CoverCommand cmd)
Queue an async named command (STOP, FAVORITE, VENT, PARTIAL, PEDESTRIAN, FORCE_OPEN); returns immedia...
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.
void dump_config() override
Dump select configuration to the log.
void control(const std::string &value) override
Apply the selected travel speed 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 sensor configuration to the log.
void publish_rain_state_(RainSensorState state)
Publish a rain state: true for RAIN, false for DRY, no state for UNKNOWN.
void setup() override
Subscribe to the device's updates and publish what is already known.
void dump_config() override
Dump sensor configuration to the log.
std::optional< uint16_t > published_
Last value handed to publish_state(); avoids re-publishing on every update.
void setup() override
Subscribe to the device's updates and publish what is already known.
bool published_once_
True once anything (a value or "unknown") was published.
static const char *const TAG_BATTERY_LEVEL
static const char *const TAG_COMMAND_BUTTON
const char * travel_speed_name(TravelSpeed speed)
Get the name a travel speed is configured and published under.
RainSensorState
What the hub's latest minimum-limitation read says about a rain-protection limit.
@ UNKNOWN
No usable reading: never read, or the last reads went unanswered.
@ DRY
The device answered and reports no rain-sized opening limit.
@ RAIN
The device answered and reports an opening limit of rain size.
static const char *const TAG_SUN_LEVEL
static const char *const TAG_SILENT
bool parse_travel_speed(const std::string &name, TravelSpeed &speed)
Look up a travel speed by the name travel_speed_name() gives it.
@ FULL_CHARGE
Battery full.
@ NORMAL_CHARGE
Battery neither low nor full.
@ NOT_REPORTED
The device does not report a battery (mains powered), or no status was read yet.
const char * cover_command_name(CoverCommand cmd)
Get a human-readable name for a CoverCommand.
static const char *const TAG_TRAVEL_SPEED
static const char *const TAG_BATTERY
static const char *const TAG_RAIN
const char * battery_state_name(BatteryState state)
Get the name a battery level is published under.
TravelSpeed
The speed a cover's position moves ask the motor for (ADR 0065).
@ SILENT
Profile 0x05, the manufacturer app's silent operation: slower than the motor's own.
@ FAST
Profile 0x06, what the hub sends unless a cover says otherwise.
Runtime state of a paired IO‑Homecontrol device.
uint32_t last_status
millis() timestamp of last received status.
std::optional< uint16_t > sun_level
Raw sun value from the opt-in EVENT_LOCAL_SENSOR poll.
std::optional< uint16_t > battery_level
Battery level in percent (0-100) from the opt-in EVENT_BATTERY_LEVEL_CHANGE poll (decode_battery_leve...
RainSensorState rain_sensor
Rain state from the opt-in minimum-limitation poll.
BatteryState battery
Coarse battery level from byte 1 of the device's own status: a reply to a status poll or an authentic...