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

Diagnostic sensor that publishes seconds elapsed since the last frame received from a device (see detail::update_link_health() in hub_internal.h). More...

#include <platform_last_contact_sensor.h>

Inheritance diagram for esphome::home_io_control::IOHomeLastContactSensor:
Collaboration diagram for esphome::home_io_control::IOHomeLastContactSensor:

Public Member Functions

void setup () override
 Register the device-update subscription, start the heartbeat, and publish the initial cached state.
void dump_config () override
 Dump sensor configuration to the log.
float get_setup_priority () const override
 Get setup priority so the parent hub is available first.
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 publish_age_ (const IoDevice &dev)
 Compute and publish seconds since dev.last_seen_ms; no-op before the first frame.
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.

Additional Inherited Members

Protected Attributes inherited from esphome::home_io_control::DeviceBoundCompanion
IOHomeControlComponentparent_ {nullptr}
std::string device_id_

Detailed Description

Diagnostic sensor that publishes seconds elapsed since the last frame received from a device (see detail::update_link_health() in hub_internal.h).

This is an age, not a timestamp: it resets to ~0 on every frame from the device — including replies to the hub's own status polls and commands, not just traffic the device sends unprompted — and counts up from there. A periodic heartbeat (see HEARTBEAT_INTERVAL_MS in the .cpp) re-publishes it even when the device stays quiet, so the value keeps advancing in Home Assistant instead of freezing at whatever it was at the last frame. Publishes nothing until the first frame is seen.

Definition at line 24 of file platform_last_contact_sensor.h.

Member Function Documentation

◆ dump_config()

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

Dump sensor configuration to the log.

Definition at line 41 of file platform_last_contact_sensor.cpp.

◆ get_setup_priority()

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

Get setup priority so the parent hub is available first.

Returns
setup_priority::DATA.

Definition at line 35 of file platform_last_contact_sensor.h.

◆ publish_age_()

void esphome::home_io_control::IOHomeLastContactSensor::publish_age_ ( const IoDevice & dev)
protected

Compute and publish seconds since dev.last_seen_ms; no-op before the first frame.

Parameters
devDevice to read last_seen_ms from.

Definition at line 36 of file platform_last_contact_sensor.cpp.

◆ setup()

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

Register the device-update subscription, start the heartbeat, and publish the initial cached state.

Definition at line 25 of file platform_last_contact_sensor.cpp.

Here is the call graph for this function:

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