7#include "esphome/core/hal.h"
8#include "esphome/core/log.h"
13static const char *
const TAG =
"home_io_control.last_contact";
17constexpr float MS_PER_SECOND = 1000.0F;
21constexpr uint32_t HEARTBEAT_INTERVAL_MS = 60000;
28 this->set_interval(
"heartbeat", HEARTBEAT_INTERVAL_MS, [
this]() {
31 if (
const auto *dev = this->
parent_->get_device(this->device_id_); dev !=
nullptr)
38 this->publish_state(
static_cast<float>(millis() - dev.
last_seen_ms) / MS_PER_SECOND);
42 LOG_SENSOR(
"",
"IO-Homecontrol Last Contact",
this);
43 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
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.
IOHomeControlComponent * parent_
static constexpr const char * TAG
Runtime state of a paired IO‑Homecontrol device.
uint32_t last_seen_ms
millis() of the last frame received from this device (any command), 0 = never.