Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
esphome::home_io_control::IOHomeLight Class Reference

Binary or dimmable light entity for IO‑Homecontrol devices. More...

#include <platform_light.h>

Inheritance diagram for esphome::home_io_control::IOHomeLight:
Collaboration diagram for esphome::home_io_control::IOHomeLight:

Public Member Functions

void setup () override
 Initialize the light entity.
void dump_config () override
 Dump configuration to log.
float get_setup_priority () const override
 Get setup priority (DATA).
void set_dimmable (bool dimmable)
 Enable brightness control (from YAML).
light::LightTraits get_traits () override
 Return traits: ColorMode::BRIGHTNESS if dimmable, else ColorMode::ON_OFF.
void setup_state (light::LightState *state) override
 Store the HA LightState object for state updates.
void write_state (light::LightState *state) override
Public Member Functions inherited from esphome::home_io_control::DeviceBoundEntity
void set_parent (IOHomeControlComponent *parent)
 Set the parent controller component.
void set_device_id (const std::string &id)
 Set the unique IO-homecontrol device ID (from YAML).
void set_device_type (DeviceType type)
 Set the declared device type (from YAML).
void set_subtype (uint8_t subtype)
 Set the declared device subtype (from YAML).
void set_optimistic_state (bool optimistic_state)
 Enable or disable optimistic target updates for this device (from YAML).
void set_status_poll_interval (uint32_t poll_interval_ms)
 Configure bounded follow-up polling while a state change is expected.

Protected Member Functions

void on_device_update_ (const std::string &id, const IoDevice &dev)
 Handle inbound device status updates.
Protected Member Functions inherited from esphome::home_io_control::DeviceBoundEntity
void register_device_binding_ (Component *self, bool inverted, std::function< void(const std::string &, const IoDevice &)> on_update)
 Perform the shared setup() registration ritual.
bool passes_binary_update_filter_ (const std::string &id, const IoDevice &dev) const
 Shared inbound-update guard for binary endpoints.
void log_poll_interval_config_ (const char *tag) const
 Emit the shared two-branch poll-interval line for dump_config().

Protected Attributes

light::LightState * state_ {nullptr}
bool dimmable_ {false}
bool suppress_write_ {false}
 Guard so that an inbound radio status (or LightState's own boot-time restore_mode push — see setup_state()) does not echo back as a new outbound command.
Protected Attributes inherited from esphome::home_io_control::DeviceBoundEntity
IOHomeControlComponentparent_ {nullptr}
std::string device_id_
DeviceType device_type_ {DeviceType::UNKNOWN}
uint8_t subtype_ {0}
uint32_t status_poll_interval_ms_ {0}
bool optimistic_state_ {true}

Detailed Description

Binary or dimmable light entity for IO‑Homecontrol devices.

The device-binding setters, setup() registration ritual and poll-interval dump line come from DeviceBoundEntity; only the on/off/brightness command and status decoding live here.

Definition at line 31 of file platform_light.h.

Member Function Documentation

◆ dump_config()

void esphome::home_io_control::IOHomeLight::dump_config ( )
override

Dump configuration to log.

Definition at line 101 of file platform_light.cpp.

Here is the call graph for this function:

◆ get_setup_priority()

float esphome::home_io_control::IOHomeLight::get_setup_priority ( ) const
inlinenodiscardoverride

Get setup priority (DATA).

Returns
setup_priority::DATA.

Definition at line 39 of file platform_light.h.

◆ get_traits()

light::LightTraits esphome::home_io_control::IOHomeLight::get_traits ( )
override

Return traits: ColorMode::BRIGHTNESS if dimmable, else ColorMode::ON_OFF.

Definition at line 27 of file platform_light.cpp.

◆ on_device_update_()

void esphome::home_io_control::IOHomeLight::on_device_update_ ( const std::string & id,
const IoDevice & dev )
protected

Handle inbound device status updates.

Parameters
idDevice ID.
devUpdated device state.

Definition at line 62 of file platform_light.cpp.

Here is the call graph for this function:

◆ set_dimmable()

void esphome::home_io_control::IOHomeLight::set_dimmable ( bool dimmable)
inline

Enable brightness control (from YAML).

Default false: binary on/off only.

Parameters
dimmableTrue to expose ColorMode::BRIGHTNESS instead of ColorMode::ON_OFF.

Definition at line 43 of file platform_light.h.

◆ setup()

void esphome::home_io_control::IOHomeLight::setup ( )
override

Initialize the light entity.

Definition at line 14 of file platform_light.cpp.

Here is the call graph for this function:

◆ setup_state()

void esphome::home_io_control::IOHomeLight::setup_state ( light::LightState * state)
inlineoverride

Store the HA LightState object for state updates.

LightState::setup() calls this first, then — moments later in that same call, before we get a chance to do anything else — applies its own restore_mode (default ALWAYS_OFF) via a real write_state() call, exactly as if HA had requested it. That's correct for a local PWM/LED output (which needs some defined state immediately), but wrong for a radio-controlled device with no local output to initialize: it would silently turn the light off (or on) on every reflash regardless of the device's actual state. Arm suppress_write_ here so that one boot-time write is swallowed the same way an inbound-update echo already is; the delayed initial status poll (register_device_binding_(), same as covers) is the real source of truth.

Parameters
statePointer to LightState.

Definition at line 58 of file platform_light.h.

◆ write_state()

void esphome::home_io_control::IOHomeLight::write_state ( light::LightState * state)
override

Definition at line 33 of file platform_light.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ dimmable_

bool esphome::home_io_control::IOHomeLight::dimmable_ {false}
protected

Definition at line 71 of file platform_light.h.

◆ state_

light::LightState* esphome::home_io_control::IOHomeLight::state_ {nullptr}
protected

Definition at line 70 of file platform_light.h.

◆ suppress_write_

bool esphome::home_io_control::IOHomeLight::suppress_write_ {false}
protected

Guard so that an inbound radio status (or LightState's own boot-time restore_mode push — see setup_state()) does not echo back as a new outbound command.

This flag is a light-only asymmetry: LightState::make_call().perform() re-enters write_state(), so both the inbound-update path and setup_state() must suppress that. Switches publish state without re-entering write_state(), so they need no equivalent guard.

Definition at line 78 of file platform_light.h.


The documentation for this class was generated from the following files: