Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
proto_device_types.h
Go to the documentation of this file.
1#pragma once
2
3/// @file proto_device_types.h
4/// @brief The IO node-type and subtype table: names, entity class, platform and behaviour flags.
5/// @ingroup hioc_protocol
6///
7/// One row per (node type, subtype) the project knows by name. Every per-type fact that is not a
8/// bare number — the lowercase identifier, the YAML selectability, the capability class, whether a
9/// platform can drive the device yet, and the behaviour flags — is read from that table, so there is
10/// exactly one place to add a type or a subtype. A lookup falls back from (type, subtype) to
11/// (type, 0) to "not in the table".
12///
13/// Subtype names agree across manufacturers, so rows are keyed on (type, subtype) only. A row names
14/// a wire type, not a product: products that share a (type, subtype) are told apart by data the wire
15/// does not carry, which is why the names stay generic.
16
17#include "proto_device_model.h"
18
19#include <cstdint>
20#include <string>
21
22namespace esphome {
23namespace home_io_control {
24
25/// @brief Subtype value that marks a device taking the main parameter only, on any node type.
26/// The subtype is defined that way in the public VELUX KLF 200 API specification (Appendix 2).
27static constexpr uint8_t SUBTYPE_MAIN_PARAMETER_ONLY = 58;
28
29/// @brief Subtype of the electrical heater (node type 52) with an adjustable setpoint, the one driven
30/// over the private register protocol (proto_heating.h).
31static constexpr uint8_t SUBTYPE_HEATER_WITH_SETPOINT = 1;
32
33/// @brief Bit flags carried by a DeviceTypeInfo row.
35/// Type rows only: the type's identifier is accepted by the YAML `io_device_type` key
36/// (hub_validators.py `DEVICE_TYPE_OPTIONS` lists exactly these).
37static constexpr uint8_t YAML_SELECTABLE = 1U << 0U;
38/// An ESPHome platform of the row's capability class can drive this (type, subtype). Rows without
39/// it are reported as "not supported yet" and get no paste-ready YAML.
40static constexpr uint8_t HAS_PLATFORM = 1U << 1U;
41/// Movement commands carry the main parameter only (no functional-parameter block), see
42/// device_takes_main_parameter_only().
43static constexpr uint8_t MAIN_PARAMETER_ONLY = 1U << 2U;
44/// Light rows only: brightness is the only controllable property (no colour, no colour temperature).
45static constexpr uint8_t BRIGHTNESS_ONLY = 1U << 3U;
46/// Subtype rows only: `name` already is the complete description ("window lock") and is printed
47/// alone, instead of being appended to the type's name ("roller shutter, with projection").
48static constexpr uint8_t STANDALONE_NAME = 1U << 4U;
49} // namespace device_type_flags
50
51/// @brief One row of the node-type / subtype table.
53 DeviceType type; ///< Node type.
54 uint8_t subtype; ///< Subtype; 0 is the type's own row.
55 const char *name; ///< Type row: lowercase identifier ("roller_shutter"). Subtype row:
56 ///< a description that follows the type name ("with projection").
57 DeviceCapabilityClass capability; ///< Entity family the device maps to.
58 uint8_t flags; ///< device_type_flags bits.
59};
60
61/// @brief Look up the table row for a (type, subtype) pair.
62/// @param type Node type.
63/// @param subtype Subtype; a subtype with no row of its own falls back to the type's row (subtype 0).
64/// @return The matching row, or nullptr when the type is not in the table.
65const DeviceTypeInfo *find_device_type_info(DeviceType type, uint8_t subtype);
66
67/// @brief Look up the table row with exactly this (type, subtype), without falling back.
68/// @param type Node type.
69/// @param subtype Subtype.
70/// @return The row, or nullptr when there is none.
71const DeviceTypeInfo *find_exact_device_type_info(DeviceType type, uint8_t subtype);
72
73/// @brief Can an ESPHome platform drive this (type, subtype) today?
74/// @param type Node type.
75/// @param subtype Subtype.
76/// @return true when the resolved row carries device_type_flags::HAS_PLATFORM.
77bool device_has_platform(DeviceType type, uint8_t subtype);
78
79/// @brief Name of the ESPHome platform that drives this (type, subtype).
80/// @param type Node type.
81/// @param subtype Subtype.
82/// @return "cover", "light", "switch", "lock", "climate" or "fan", or nullptr when no platform drives it yet.
83const char *device_platform_name(DeviceType type, uint8_t subtype);
84
85/// @brief Capability class of a (type, subtype), subtype-aware.
86/// @details device_capability_class(DeviceType) answers for the type alone; this overload lets a
87/// subtype row differ from its type (for example a heater with an adjustable setpoint).
88/// @param type Node type.
89/// @param subtype Subtype.
90/// @return The resolved row's class, or DeviceCapabilityClass::UNKNOWN when the type is not in the table.
92
93/// @brief Is this light limited to brightness (no colour, no colour temperature)?
94/// @param type Node type.
95/// @param subtype Subtype.
96/// @return true when the resolved row carries device_type_flags::BRIGHTNESS_ONLY.
97bool device_light_is_brightness_only(DeviceType type, uint8_t subtype);
98
99/// @brief Human-readable description of a (type, subtype) for logs and reports.
100/// @param type Node type.
101/// @param subtype Subtype.
102/// @return "<type name>, <subtype name>" (for example "electrical heater, with adjustable setpoint"),
103/// "<type name>, subtype N" when the subtype has no name, the bare type name for subtype 0,
104/// and "unknown type 0xNN" when the type is not in the table.
105std::string format_device_kind(DeviceType type, uint8_t subtype);
106
107/// @brief Wire values of a (type, subtype), for logs that must stay readable without the table.
108/// @param type Node type.
109/// @param subtype Subtype.
110/// @return "0xTT/S", for example "0x34/1".
111std::string format_device_ids(DeviceType type, uint8_t subtype);
112
113} // namespace home_io_control
114} // namespace esphome
Bit flags carried by a DeviceTypeInfo row.
static constexpr uint8_t YAML_SELECTABLE
Type rows only: the type's identifier is accepted by the YAML io_device_type key (hub_validators....
static constexpr uint8_t BRIGHTNESS_ONLY
Light rows only: brightness is the only controllable property (no colour, no colour temperature).
static constexpr uint8_t MAIN_PARAMETER_ONLY
Movement commands carry the main parameter only (no functional-parameter block), see device_takes_mai...
static constexpr uint8_t HAS_PLATFORM
An ESPHome platform of the row's capability class can drive this (type, subtype).
static constexpr uint8_t STANDALONE_NAME
Subtype rows only: name already is the complete description ("window lock") and is printed alone,...
std::string format_device_ids(DeviceType type, uint8_t subtype)
Wire values of a (type, subtype), for logs that must stay readable without the table.
DeviceCapabilityClass device_capability_class(DeviceType type)
Map a raw IO‑Homecontrol type to the closest ESPHome/Home Assistant entity family.
DeviceType
IO-Homecontrol node types.
static constexpr uint8_t SUBTYPE_MAIN_PARAMETER_ONLY
Subtype value that marks a device taking the main parameter only, on any node type.
static constexpr uint8_t SUBTYPE_HEATER_WITH_SETPOINT
Subtype of the electrical heater (node type 52) with an adjustable setpoint, the one driven over the ...
const DeviceTypeInfo * find_exact_device_type_info(DeviceType type, uint8_t subtype)
Look up the table row with exactly this (type, subtype), without falling back.
const char * device_platform_name(DeviceType type, uint8_t subtype)
Name of the ESPHome platform that drives this (type, subtype).
bool device_has_platform(DeviceType type, uint8_t subtype)
Can an ESPHome platform drive this (type, subtype) today?
const DeviceTypeInfo * find_device_type_info(DeviceType type, uint8_t subtype)
Look up the table row for a (type, subtype) pair.
DeviceCapabilityClass
High‑level capability class derived from DeviceType.
std::string format_device_kind(DeviceType type, uint8_t subtype)
Human-readable description of a (type, subtype) for logs and reports.
bool device_light_is_brightness_only(DeviceType type, uint8_t subtype)
Is this light limited to brightness (no colour, no colour temperature)?
IO-Homecontrol device-type model, capabilities and runtime device state.
One row of the node-type / subtype table.
uint8_t flags
device_type_flags bits.
uint8_t subtype
Subtype; 0 is the type's own row.
const char * name
Type row: lowercase identifier ("roller_shutter").
DeviceCapabilityClass capability
Entity family the device maps to.