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

Mixin holding the parent + device-id binding shared by per-device entities that are not full entity platforms: the auto-generated companion diagnostic sensors (device name, active issue, RSSI, last contact, exchange failures, last commanded by, last command source) and the per-device auxiliary control entities (cover favorite/vent buttons, cover silent switch). More...

#include <platform_entity_base.h>

Inheritance diagram for esphome::home_io_control::DeviceBoundCompanion:
Collaboration diagram for esphome::home_io_control::DeviceBoundCompanion:

Public Member Functions

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 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

IOHomeControlComponentparent_ {nullptr}
std::string device_id_

Detailed Description

Mixin holding the parent + device-id binding shared by per-device entities that are not full entity platforms: the auto-generated companion diagnostic sensors (device name, active issue, RSSI, last contact, exchange failures, last commanded by, last command source) and the per-device auxiliary control entities (cover favorite/vent buttons, cover silent switch).

These differ from the main entity platforms (DeviceBoundEntity above) in that they do not own the device: they never call add_device() or configure polling. The companion sensors use register_companion_binding_() to subscribe to update notifications and republish their one value; the auxiliary control entities take only the parent + device-id pair and act on their already-registered device on demand, so register_companion_binding_() stays opt-in. Each class keeps its own value rendering / action logic (including whether a given device state is publishable at all).

Definition at line 138 of file platform_entity_base.h.

Member Function Documentation

◆ register_companion_binding_()

void esphome::home_io_control::DeviceBoundCompanion::register_companion_binding_ ( const std::function< void(const IoDevice &)> & publish)
inlineprotected

Shared setup() body: subscribe to this device's updates and publish the initial state.

No-op when no parent is wired (codegen always wires one before setup() runs).

Parameters
publishRenders and publishes the sensor's value from a device record — or skips publishing when the record has no meaningful value yet. Runs once immediately when the device is already registered, then again on every update notification for this device.

Definition at line 154 of file platform_entity_base.h.

◆ set_device_id()

void esphome::home_io_control::DeviceBoundCompanion::set_device_id ( const std::string & id)
inline

Set the device ID whose state this companion sensor exposes.

Parameters
idHexadecimal node ID string (for example "123ABC").

Definition at line 145 of file platform_entity_base.h.

◆ set_parent()

void esphome::home_io_control::DeviceBoundCompanion::set_parent ( IOHomeControlComponent * parent)
inline

Set the parent controller component.

Parameters
parentPointer to the IOHomeControlComponent instance.

Definition at line 142 of file platform_entity_base.h.

Member Data Documentation

◆ device_id_

std::string esphome::home_io_control::DeviceBoundCompanion::device_id_
protected

Definition at line 168 of file platform_entity_base.h.

◆ parent_

IOHomeControlComponent* esphome::home_io_control::DeviceBoundCompanion::parent_ {nullptr}
protected

Definition at line 167 of file platform_entity_base.h.


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