Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_device_name_text_sensor.h
Go to the documentation of this file.
1#pragma once
2
3/// @file platform_device_name_text_sensor.h
4/// @brief Diagnostic text sensor exposing the stored IO-Homecontrol device name.
5/// @ingroup hioc_platforms
6
7#include <string>
8
9#include "esphome/components/text_sensor/text_sensor.h"
10#include "esphome/core/component.h"
11#include "hub_core.h"
12
13namespace esphome {
14namespace home_io_control {
15
16/// @brief Diagnostic text sensor that publishes the cached device name.
17/// @ingroup hioc_platforms
18class IOHomeDeviceNameTextSensor : public text_sensor::TextSensor, public Component {
19 public:
20 /// @brief Set the parent controller component.
21 /// @param parent Pointer to the IOHomeControlComponent instance.
22 void set_parent(IOHomeControlComponent *parent) { this->parent_ = parent; }
23
24 /// @brief Set the device ID whose cached name this sensor exposes.
25 /// @param id Hexadecimal node ID string (for example "123ABC").
26 void set_device_id(const std::string &id) { this->device_id_ = id; }
27
28 /// @brief Register callbacks and schedule an initial name fetch.
29 void setup() override;
30
31 /// @brief Dump text-sensor configuration to the log.
32 void dump_config() override;
33
34 /// @brief Get setup priority so the parent hub is available first.
35 /// @return setup_priority::DATA.
36 [[nodiscard]] float get_setup_priority() const override { return setup_priority::DATA; }
37
38 protected:
39 /// @brief Publish the current cached device name after a hub update.
40 /// @param id Device ID that updated.
41 /// @param dev Updated cached device record.
42 void on_device_update_(const std::string &id, const IoDevice &dev);
43
45 std::string device_id_;
46};
47
48} // namespace home_io_control
49} // namespace esphome
The main IO-Homecontrol component.
Definition hub_core.h:68
Diagnostic text sensor that publishes the cached device name.
void setup() override
Register callbacks and schedule an initial name fetch.
void on_device_update_(const std::string &id, const IoDevice &dev)
Publish the current cached device name after a hub update.
void dump_config() override
Dump text-sensor configuration to the log.
float get_setup_priority() const override
Get setup priority so the parent hub is available first.
void set_parent(IOHomeControlComponent *parent)
Set the parent controller component.
void set_device_id(const std::string &id)
Set the device ID whose cached name this sensor exposes.
IO-Homecontrol ESPHome component — protocol controller.
Runtime state of a paired IO‑Homecontrol device.