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

Dimmable light for a heater's night light (night_light: on a heater with io_model heater_with_light). More...

#include <platform_climate_controls.h>

Inheritance diagram for esphome::home_io_control::IOHomeHeaterNightLight:
Collaboration diagram for esphome::home_io_control::IOHomeHeaterNightLight:

Public Member Functions

void setup () override
 Subscribe to the device's updates and publish what is already known.
void dump_config () override
 Dump light configuration to the log.
float get_setup_priority () const override
 Get setup priority so the parent hub is available first.
light::LightTraits get_traits () override
 Brightness is the light's only colour mode.
void setup_state (light::LightState *state) override
 Store the LightState and swallow the write its restore_mode makes at boot.
void write_state (light::LightState *state) override
 Send the requested state to the heater and read it back.
Public Member Functions inherited from esphome::home_io_control::DeviceBoundCompanion
void set_parent (IOHomeControlComponent *parent)
 Set the parent controller component.
void set_device_id (const std::string &id)
 Set the device ID whose state this companion sensor exposes.

Protected Member Functions

void on_device_update_ (const IoDevice &dev)
 Publish the heater's light state, without echoing it back as a write.
bool write_register_ (HeatingFunction fn, float value)
 Write one light register.
Protected Member Functions inherited from esphome::home_io_control::DeviceBoundCompanion
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.

Protected Attributes

light::LightState * state_ {nullptr}
bool suppress_write_ {false}
 Swallows the write_state() that LightState::make_call().perform() causes for a state this entity publishes itself (and the boot-time restore, see setup_state()).
bool writing_ {false}
 True while write_state() runs its writes and read-backs: the device updates they cause are not published one by one (a half-updated reading would flash a stale brightness), but once at the end.
Protected Attributes inherited from esphome::home_io_control::DeviceBoundCompanion
IOHomeControlComponent * parent_ {nullptr}
std::string device_id_

Detailed Description

Dimmable light for a heater's night light (night_light: on a heater with io_model heater_with_light).

On/off is register 0x0144 and the brightness register 0x0142, a percentage that maps 1:1 onto Home Assistant's brightness (100 % = full). The light shows what the heater reports: no state until the first poll has read 0x0144, every acknowledged write is read back, and a write the heater does not acknowledge leaves the light showing the heater's last reading.

Switching on writes the brightness only when it differs from what the heater holds, then the on/off register; so on/off at an unchanged brightness never depends on the brightness write.

Todo
Experimental: confirm on a real heater that writing 0x0144 switches the light (the heater's own controller writes it, issue #222) and that writing 0x0142 dims it.

Definition at line 88 of file platform_climate_controls.h.

Member Function Documentation

◆ dump_config()

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

Dump light configuration to the log.

Definition at line 136 of file platform_climate_controls.cpp.

◆ get_setup_priority()

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

Get setup priority so the parent hub is available first.

Returns
setup_priority::DATA.

Definition at line 98 of file platform_climate_controls.h.

◆ get_traits()

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

Brightness is the light's only colour mode.

Returns
Traits with ColorMode::BRIGHTNESS.

Definition at line 72 of file platform_climate_controls.cpp.

◆ on_device_update_()

void esphome::home_io_control::IOHomeHeaterNightLight::on_device_update_ ( const IoDevice & dev)
protected

Publish the heater's light state, without echoing it back as a write.

Parameters
devThe device record.

Definition at line 78 of file platform_climate_controls.cpp.

Here is the call graph for this function:

◆ setup()

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

Subscribe to the device's updates and publish what is already known.

Definition at line 68 of file platform_climate_controls.cpp.

Here is the call graph for this function:

◆ setup_state()

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

Store the LightState and swallow the write its restore_mode makes at boot.

LightState::setup() applies its restore_mode through a real write_state() right after this call; on a radio-controlled light that would switch the heater's light at every reboot. The poll is the source of truth, so that one write is suppressed.

Parameters
stateThe LightState this output belongs to.

Definition at line 110 of file platform_climate_controls.h.

◆ write_register_()

bool esphome::home_io_control::IOHomeHeaterNightLight::write_register_ ( HeatingFunction fn,
float value )
protected

Write one light register.

Parameters
fnNIGHT_LIGHT or NIGHT_LIGHT_BRIGHTNESS.
valueValue to write.
Returns
true when the heater acknowledged it.

Definition at line 92 of file platform_climate_controls.cpp.

Here is the call graph for this function:

◆ write_state()

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

Send the requested state to the heater and read it back.

Parameters
stateThe LightState holding the requested values.

Definition at line 100 of file platform_climate_controls.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ state_

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

Definition at line 130 of file platform_climate_controls.h.

◆ suppress_write_

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

Swallows the write_state() that LightState::make_call().perform() causes for a state this entity publishes itself (and the boot-time restore, see setup_state()).

Definition at line 133 of file platform_climate_controls.h.

◆ writing_

bool esphome::home_io_control::IOHomeHeaterNightLight::writing_ {false}
protected

True while write_state() runs its writes and read-backs: the device updates they cause are not published one by one (a half-updated reading would flash a stale brightness), but once at the end.

Definition at line 136 of file platform_climate_controls.h.


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