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///
6/// Provides a minimal on/off switch representation. Position < 50 is treated as on.
7/// This platform is experimental and not yet validated on real hardware.
8///
9/// @warning This platform has not been tested with physical IO‑Homecontrol switch devices.
10/// Behavior is inferred from the protocol specification and may be incomplete.
11/// Use with caution and verify with actual hardware before production deployment.
12
13#include "esphome/core/component.h"
14#include "esphome/components/switch/switch.h"
15#include "hub_core.h"
16
17namespace esphome {
18namespace home_io_control {
19
20/// @brief Binary switch entity for IO‑Homecontrol on/off devices.
21class IOHomeSwitch : public switch_::Switch, public Component {
22 public:
23 /// @brief Initialize the switch entity.
24 void setup() override;
25 /// @brief Dump configuration to log.
26 void dump_config() override;
27 /// @brief Get setup priority (DATA).
28 /// @return setup_priority::DATA.
29 [[nodiscard]] float get_setup_priority() const override { return setup_priority::DATA; }
30
31 /// @brief Set parent controller.
32 /// @param parent Pointer to IOHomeControlComponent.
33 void set_parent(IOHomeControlComponent *parent) { this->parent_ = parent; }
34 /// @brief Set device ID from YAML.
35 /// @param id Hex string node ID.
36 void set_device_id(const std::string &id) { this->device_id_ = id; }
37 /// @brief Set the declared device type (from YAML).
38 /// @param type Device type enum.
39 void set_device_type(DeviceType type) { this->device_type_ = type; }
40 /// @brief Set the declared device subtype (from YAML).
41 /// @param subtype Subtype value.
42 void set_subtype(uint8_t subtype) { this->subtype_ = subtype; }
43 /// @brief Configure bounded follow-up polling while a state change is expected.
44 /// @param poll_interval_ms Poll interval in milliseconds; zero keeps the default single settle poll only.
45 void set_status_poll_interval(uint32_t poll_interval_ms) { this->status_poll_interval_ms_ = poll_interval_ms; }
46
47 protected:
48 /// @brief Write state change to the device.
49 /// @param state Desired on/off state.
50 void write_state(bool state) override;
51 /// @brief Callback when device state changes (e.g., from a remote).
52 /// @param id Device ID.
53 /// @param dev Updated IoDevice state.
54 void on_device_update_(const std::string &id, const IoDevice &dev);
55
57 std::string device_id_;
59 uint8_t subtype_{0};
61};
62
63} // namespace home_io_control
64} // namespace esphome
The main IO-Homecontrol component.
Definition hub_core.h:60
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.