Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_active_issue_text_sensor.cpp
Go to the documentation of this file.
1/// @file platform_active_issue_text_sensor.cpp
2/// @brief Diagnostic text sensor exposing a device's currently outstanding CMD_ERROR_RESP reason.
3/// @ingroup hioc_platforms
4
6
7#include "proto_constants.h"
8#include "esphome/core/log.h"
9
10namespace esphome {
11namespace home_io_control {
12
13static const char *const TAG = "home_io_control.active_issue";
14
16 this->register_companion_binding_([this](const IoDevice &dev) {
17 // Empty string when no result is recorded; otherwise the symbolic result name.
18 this->publish_state(dev.last_result_code == 0 ? "" : command_result_name(dev.last_result_code));
19 });
20}
21
23 LOG_TEXT_SENSOR("", "IO-Homecontrol Active Issue", this);
24 ESP_LOGCONFIG(TAG, " Device ID: %s", this->device_id_.c_str());
25}
26
27} // namespace home_io_control
28} // namespace esphome
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.
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.
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.
Diagnostic text sensor exposing a device's currently outstanding CMD_ERROR_RESP reason.
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).