Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_light.h
Go to the documentation of this file.
1#pragma once
2
3/// @file platform_light.h
4/// @brief Experimental binary light entity for IO‑Homecontrol devices.
5/// @ingroup hioc_platforms
6///
7/// Provides a minimal on/off light representation. Position < 50 is treated as on.
8/// This platform is experimental and not yet validated on real hardware.
9/// @todo Validate end-to-end behavior with physical IO-Homecontrol light devices,
10/// including passive state updates, startup state restoration, and any vendor-specific
11/// position encodings that do not map cleanly to binary on/off semantics.
12///
13/// @warning This platform has not been tested with physical IO‑Homecontrol light devices.
14/// Behavior is inferred from the protocol specification and may be incomplete.
15/// Use with caution and verify with actual hardware before production deployment.
16
17#include "esphome/core/component.h"
18#include "esphome/components/light/light_output.h"
19#include "hub_core.h"
20
21namespace esphome {
22namespace home_io_control {
23
24/// @brief Binary light entity for IO‑Homecontrol on/off devices.
25/// @ingroup hioc_platforms
26class IOHomeLight : public light::LightOutput, public Component {
27 public:
28 /// @brief Initialize the light entity.
29 void setup() override;
30 /// @brief Dump configuration to log.
31 void dump_config() override;
32 /// @brief Get setup priority (DATA).
33 /// @return setup_priority::DATA.
34 [[nodiscard]] float get_setup_priority() const override { return setup_priority::DATA; }
35
36 /// @brief Return traits: binary on/off only (no dimming).
37 /// @return LightTraits with ColorMode::ON_OFF.
38 light::LightTraits get_traits() override;
39 /// @brief Store the HA LightState object for state updates.
40 /// @param state Pointer to LightState.
41 void setup_state(light::LightState *state) override { this->state_ = state; }
42 void write_state(light::LightState *state) override;
43
44 /// @brief Set parent controller.
45 /// @param parent Pointer to IOHomeControlComponent.
46 void set_parent(IOHomeControlComponent *parent) { this->parent_ = parent; }
47 /// @brief Set device ID from YAML.
48 /// @param id Hex string node ID.
49 void set_device_id(const std::string &id) { this->device_id_ = id; }
50 /// @brief Set the declared device type (from YAML).
51 /// @param type Device type enum.
52 void set_device_type(DeviceType type) { this->device_type_ = type; }
53 /// @brief Set the declared device subtype (from YAML).
54 /// @param subtype Subtype value.
55 void set_subtype(uint8_t subtype) { this->subtype_ = subtype; }
56 /// @brief Configure bounded follow-up polling while a state change is expected.
57 /// @param poll_interval_ms Poll interval in milliseconds; zero keeps the default single settle poll only.
58 void set_status_poll_interval(uint32_t poll_interval_ms) { this->status_poll_interval_ms_ = poll_interval_ms; }
59
60 protected:
61 /// @brief Handle inbound device status updates.
62 /// @param id Device ID.
63 /// @param dev Updated device state.
64 void on_device_update_(const std::string &id, const IoDevice &dev);
65
67 light::LightState *state_{nullptr};
68 std::string device_id_;
70 uint8_t subtype_{0};
72 /// Guard so that an inbound radio status does not echo back as a new outbound command.
73 bool suppress_write_{false};
74};
75
76} // namespace home_io_control
77} // namespace esphome
The main IO-Homecontrol component.
Definition hub_core.h:68
Binary light entity for IO‑Homecontrol on/off devices.
void set_device_id(const std::string &id)
Set device ID from YAML.
void set_subtype(uint8_t subtype)
Set the declared device subtype (from YAML).
void write_state(light::LightState *state) override
bool suppress_write_
Guard so that an inbound radio status does not echo back as a new outbound command.
void set_status_poll_interval(uint32_t poll_interval_ms)
Configure bounded follow-up polling while a state change is expected.
void setup_state(light::LightState *state) override
Store the HA LightState object for state updates.
void on_device_update_(const std::string &id, const IoDevice &dev)
Handle inbound device status updates.
void set_parent(IOHomeControlComponent *parent)
Set parent controller.
void set_device_type(DeviceType type)
Set the declared device type (from YAML).
float get_setup_priority() const override
Get setup priority (DATA).
void dump_config() override
Dump configuration to log.
light::LightTraits get_traits() override
Return traits: binary on/off only (no dimming).
void setup() override
Initialize the light entity.
IO-Homecontrol ESPHome component — protocol controller.
DeviceType
Device type identifiers reported by IO‑Homecontrol products.
@ UNKNOWN
Unknown/unspecified device.
Runtime state of a paired IO‑Homecontrol device.