Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_switch.h
Go to the documentation of this file.
1#pragma once
2
3/// @file platform_switch.h
4/// @brief Experimental binary switch entity for IO‑Homecontrol devices.
5/// @ingroup hioc_platforms
6///
7/// Provides a minimal on/off switch 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 switch 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 switch 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/switch/switch.h"
19#include "hub_core.h"
20
21namespace esphome {
22namespace home_io_control {
23
24/// @brief Binary switch entity for IO‑Homecontrol on/off devices.
25/// @ingroup hioc_platforms
26class IOHomeSwitch : public switch_::Switch, public Component {
27 public:
28 /// @brief Initialize the switch 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 Set parent controller.
37 /// @param parent Pointer to IOHomeControlComponent.
38 void set_parent(IOHomeControlComponent *parent) { this->parent_ = parent; }
39 /// @brief Set device ID from YAML.
40 /// @param id Hex string node ID.
41 void set_device_id(const std::string &id) { this->device_id_ = id; }
42 /// @brief Set the declared device type (from YAML).
43 /// @param type Device type enum.
44 void set_device_type(DeviceType type) { this->device_type_ = type; }
45 /// @brief Set the declared device subtype (from YAML).
46 /// @param subtype Subtype value.
47 void set_subtype(uint8_t subtype) { this->subtype_ = subtype; }
48 /// @brief Configure bounded follow-up polling while a state change is expected.
49 /// @param poll_interval_ms Poll interval in milliseconds; zero keeps the default single settle poll only.
50 void set_status_poll_interval(uint32_t poll_interval_ms) { this->status_poll_interval_ms_ = poll_interval_ms; }
51
52 protected:
53 /// @brief Write state change to the device.
54 /// @param state Desired on/off state.
55 void write_state(bool state) override;
56 /// @brief Callback when device state changes (e.g., from a remote).
57 /// @param id Device ID.
58 /// @param dev Updated IoDevice state.
59 void on_device_update_(const std::string &id, const IoDevice &dev);
60
62 std::string device_id_;
64 uint8_t subtype_{0};
66};
67
68} // namespace home_io_control
69} // namespace esphome
The main IO-Homecontrol component.
Definition hub_core.h:68
Binary switch entity for IO‑Homecontrol on/off devices.
void set_parent(IOHomeControlComponent *parent)
Set parent controller.
float get_setup_priority() const override
Get setup priority (DATA).
void set_subtype(uint8_t subtype)
Set the declared device subtype (from YAML).
void dump_config() override
Dump configuration to log.
void on_device_update_(const std::string &id, const IoDevice &dev)
Callback when device state changes (e.g., from a remote).
void set_status_poll_interval(uint32_t poll_interval_ms)
Configure bounded follow-up polling while a state change is expected.
void set_device_type(DeviceType type)
Set the declared device type (from YAML).
void set_device_id(const std::string &id)
Set device ID from YAML.
void write_state(bool state) override
Write state change to the device.
void setup() override
Initialize the switch 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.