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

Mixin holding the hub/device binding shared by the auto-generated per-device companion diagnostic sensors (device name, active issue, RSSI, last contact, exchange failures). 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 hub/device binding shared by the auto-generated per-device companion diagnostic sensors (device name, active issue, RSSI, last contact, exchange failures).

Companions differ from the main entity platforms (DeviceBoundEntity above) in that they only observe a device the main entity already registered: they never call add_device() or configure polling, they just subscribe to update notifications and republish their one value. This mixin centralizes that subscribe-and-republish ritual; each sensor class keeps only its value rendering (including its decision whether a given device state is publishable at all).

Definition at line 115 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 131 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 122 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 119 of file platform_entity_base.h.

Member Data Documentation

◆ device_id_

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

Definition at line 145 of file platform_entity_base.h.

◆ parent_

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

Definition at line 144 of file platform_entity_base.h.


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