9#include "esphome/core/hal.h"
10#include "esphome/core/log.h"
23constexpr float MS_PER_SECOND = 1000.0F;
27constexpr uint32_t HEARTBEAT_INTERVAL_MS = 60000;
34 this->publish_state(ema_dbm);
39 static const char *
const TAG =
"home_io_control.rssi";
40 LOG_SENSOR(
"",
"IO-Homecontrol RSSI",
this);
41 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
47 this->set_interval(
"heartbeat", HEARTBEAT_INTERVAL_MS, [
this]() {
50 if (
const auto *dev = this->
parent_->get_device(this->device_id_); dev !=
nullptr)
57 this->publish_state(
static_cast<float>(millis() - dev.
last_seen_ms) / MS_PER_SECOND);
61 static const char *
const TAG =
"home_io_control.last_contact";
62 LOG_SENSOR(
"",
"IO-Homecontrol Last Contact",
this);
63 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
72 static const char *
const TAG =
"home_io_control.exchange_failures";
73 LOG_SENSOR(
"",
"IO-Homecontrol Exchange Failures",
this);
74 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
88 static const char *
const TAG =
"home_io_control.device_name";
89 LOG_TEXT_SENSOR(
"",
"IO-Homecontrol Device Name",
this);
90 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
101 static const char *
const TAG =
"home_io_control.active_issue";
102 LOG_TEXT_SENSOR(
"",
"IO-Homecontrol Active Issue",
this);
103 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
112 [
this](
const IoDevice &dev) { this->publish_state(this->
parent_->describe_last_commander(dev)); });
116 static const char *
const TAG =
"home_io_control.last_commanded_by";
117 LOG_TEXT_SENSOR(
"",
"IO-Homecontrol Last Commanded By",
this);
118 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
127 static const char *
const TAG =
"home_io_control.last_command_source";
128 LOG_TEXT_SENSOR(
"",
"IO-Homecontrol Last Command Source",
this);
129 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_
void setup() override
Register the device-update subscription and publish the initial cached state.
void dump_config() override
Dump text-sensor configuration to the log.
void setup() override
Register the device-update subscription and schedule an initial name fetch.
void dump_config() override
Dump text-sensor configuration to the log.
void setup() override
Register the device-update subscription and publish the initial cached state.
void dump_config() override
Dump sensor configuration to the log.
void dump_config() override
void dump_config() override
Internal helpers shared by the hub implementation .cpp files.
std::string describe_last_command_source(const IoDevice &dev)
Render the "Last Command Source" sensor string.
static constexpr const char * TAG
const char * command_result_name(uint8_t result)
Return a stable symbolic name for a CMD_ERROR_RESP result code.
static constexpr uint32_t INITIAL_STATUS_REQUEST_DELAY_MS
Delay before the first post-boot status request from an entity.
int16_t device_rssi_ema_dbm(const IoDevice &dev)
A device's smoothed RSSI in whole dBm.
static constexpr int16_t RSSI_UNKNOWN_DBM
Sentinel value meaning "no RSSI sample recorded yet" for last_rssi_dbm/rssi_ema_scaled.
IO-Homecontrol command IDs, result codes and protocol enumerations.
Runtime state of a paired IO‑Homecontrol device.
uint8_t last_result_code
Last CMD_ERROR_RESP result byte (0 = none recorded).
char name[DEVICE_NAME_BUFFER_SIZE]
Cached UTF-8 device name decoded from Latin-1 wire payloads.
uint32_t last_seen_ms
millis() of the last frame received from this device (any command), 0 = never.
uint16_t exchange_timeout_count
Cumulative count of outbound exchanges to this device with no valid response (see detail::record_exch...