7#include "esphome/core/log.h"
12static const char *
const TAG =
"home_io_control.light";
28 auto traits = light::LightTraits();
29 traits.set_supported_color_modes({this->
dimmable_ ? light::ColorMode::BRIGHTNESS : light::ColorMode::ON_OFF});
40 float brightness = 0.0F;
47 state->current_values.as_brightness(&brightness);
58 state->current_values_as_binary(&on);
71 const float brightness = 1.0F - (dev.
position / 100.0F);
72 const bool on = brightness > 0.0F;
73 if (this->
state_->current_values.is_on() == on && this->state_->remote_values.is_on() == on &&
74 this->state_->current_values.get_brightness() == brightness &&
75 this->state_->remote_values.get_brightness() == brightness)
79 auto call = this->
state_->make_call();
81 call.set_brightness(brightness);
90 if (this->
state_->current_values.is_on() == on && this->state_->remote_values.is_on() == on)
95 auto call = this->
state_->make_call();
102 ESP_LOGCONFIG(
TAG,
"IO-Homecontrol %s Light", this->
dimmable_ ?
"Dimmable" :
"Binary");
103 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
void register_device_binding_(Component *self, bool inverted, std::function< void(const std::string &, const IoDevice &)> on_update)
Perform the shared setup() registration ritual.
void log_poll_interval_config_(const char *tag) const
Emit the shared two-branch poll-interval line for dump_config().
IOHomeControlComponent * parent_
bool passes_binary_update_filter_(const std::string &id, const IoDevice &dev) const
Shared inbound-update guard for binary endpoints.
void write_state(light::LightState *state) override
bool suppress_write_
Guard so that an inbound radio status (or LightState's own boot-time restore_mode push — see setup_st...
light::LightState * state_
void on_device_update_(const std::string &id, const IoDevice &dev)
Handle inbound device status updates.
void dump_config() override
Dump configuration to log.
light::LightTraits get_traits() override
Return traits: ColorMode::BRIGHTNESS if dimmable, else ColorMode::ON_OFF.
void setup() override
Initialize the light entity.
Internal helpers shared by the hub implementation .cpp files.
constexpr float BINARY_ENTITY_ON_POSITION_THRESHOLD
Shared 0-100 cutoff: values below this mean binary "on".
uint8_t round_percent(float fraction)
Convert a 0.0-1.0 HA fraction (position, tilt, or brightness) to a 0-100 IO percent.
static constexpr const char * TAG
Runtime state of a paired IO‑Homecontrol device.
float position
Current position: 0=open, 100=closed, or UNKNOWN_POSITION.