Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
proto_device_features.h
Go to the documentation of this file.
1#pragma once
2
3/// @file proto_device_features.h
4/// @brief Capability bits of a device kind: what a (node type, subtype) can do.
5/// @ingroup hioc_protocol
6///
7/// The bits are carried by the rows of the node-type table (proto_device_types.h) and resolved onto
8/// each device record, so the hub, the platforms and the Python codegen ask one place whether a
9/// device has a feature instead of branching on a device type. A bit says *whether* a device has a
10/// capability; how it is commanded stays in the command builders and the profile tables.
11///
12/// This leaf header includes only `<cstdint>`: IoDevice (proto_device_model.h) carries a
13/// DeviceFeatures word, and proto_device_types.h already includes proto_device_model.h.
14
15#include <cstdint>
16
17namespace esphome {
18namespace home_io_control {
19
20/// @brief Capability bits of a device kind; see device_feature.
21using DeviceFeatures = uint16_t;
22
23/// @brief Capability bits carried by a DeviceTypeInfo row and resolved onto a device record.
24/// hub_validators.py mirrors the whole word bit for bit (`FEATURE_*`, `DEVICE_FEATURES`) and
25/// device_features_sync_test.cpp checks it. Bit 15 is never a capability: the Python mirror uses it
26/// for the row's experimental marker.
27namespace device_feature {
28/// EXECUTE carries no functional parameter at all (VELUX KLF 200 API specification, Appendix 2:
29/// "main parameter only"). Read by main_parameter_only_variant() and the table invariants; the frame
30/// shape itself is EXTENDED_POSITION_FRAME's job.
31static constexpr DeviceFeatures MAIN_PARAMETER_ONLY = 1U << 0U;
32/// Intermediate main-parameter values: a percent position, a brightness or a heat level.
33static constexpr DeviceFeatures LEVELS = 1U << 1U;
34/// Slat angle (functional parameter 3) through the extended status and the tilt EXECUTE.
35static constexpr DeviceFeatures TILT = 1U << 2U;
36/// Named position 0xD800, the favourite ("my") position. Absent where a device has refused the alias
37/// (garage openers, issue #163).
38static constexpr DeviceFeatures FAVORITE = 1U << 3U;
39/// Named position 0xD803, the window opener's secured ventilation position (VELUX KLF 200 API
40/// specification, section 14.2).
41static constexpr DeviceFeatures VENT = 1U << 4U;
42/// Named position 0xD809, sent by the Partial Position button: a garage opener runs its stored
43/// partial position (issue #163).
44static constexpr DeviceFeatures PARTIAL = 1U << 5U;
45/// Named position 0xD807, sent by the Pedestrian Position button.
46/// \todo Confirm on a real gate opener that 0xD807 opens it to a pedestrian position (experimental).
47static constexpr DeviceFeatures PEDESTRIAN = 1U << 6U;
48/// Position and force-open EXECUTEs use the 8-byte form with functional parameter 1 set (the form
49/// validated on roller shutters, awnings, the Izymo dimmer and the pergola); without it they use the
50/// 6-byte main-parameter form. On covers functional parameter 1 is the travel speed (VELUX KLF 200
51/// API specification, Appendix 2), so `silent:` (the slow profile in that parameter) needs this bit;
52/// that proxy holds only for covers, which are the only kinds with `silent:`.
53static constexpr DeviceFeatures EXTENDED_POSITION_FRAME = 1U << 7U;
54/// Heater window sensor and open-window-detection switch.
55static constexpr DeviceFeatures WINDOW_COMPANIONS = 1U << 8U;
56/// Direction inverted by default (horizontal awnings: IO 0 is closed).
57static constexpr DeviceFeatures INVERTED = 1U << 9U;
58/// Read and commanded as a domestic hot water heater: family-0x00 registers (proto_dhw.h) for its
59/// readings and mode, the status main parameter for its target temperature. Gates the water heater
60/// poll, its register reads and writes, and the `water_heater:` platform.
61static constexpr DeviceFeatures WATER_HEATER = 1U << 10U;
62/// A night light built into a heater with private registers: on/off in register 0x0144, brightness in
63/// 0x0142 (proto_heating.h). Gates the heater's `night_light:` light entity.
64static constexpr DeviceFeatures NIGHT_LIGHT = 1U << 11U;
65} // namespace device_feature
66
67/// @brief True when every bit of `bit` is set in `set`.
68/// @param set A feature word.
69/// @param bit One bit, or several that must all be set.
70constexpr bool has_feature(DeviceFeatures set, DeviceFeatures bit) { return (set & bit) == bit; }
71
72} // namespace home_io_control
73} // namespace esphome
Capability bits carried by a DeviceTypeInfo row and resolved onto a device record.
static constexpr DeviceFeatures PEDESTRIAN
Named position 0xD807, sent by the Pedestrian Position button.
static constexpr DeviceFeatures EXTENDED_POSITION_FRAME
Position and force-open EXECUTEs use the 8-byte form with functional parameter 1 set (the form valida...
static constexpr DeviceFeatures WATER_HEATER
Read and commanded as a domestic hot water heater: family-0x00 registers (proto_dhw....
static constexpr DeviceFeatures VENT
Named position 0xD803, the window opener's secured ventilation position (VELUX KLF 200 API specificat...
static constexpr DeviceFeatures NIGHT_LIGHT
A night light built into a heater with private registers: on/off in register 0x0144,...
static constexpr DeviceFeatures WINDOW_COMPANIONS
Heater window sensor and open-window-detection switch.
static constexpr DeviceFeatures TILT
Slat angle (functional parameter 3) through the extended status and the tilt EXECUTE.
static constexpr DeviceFeatures INVERTED
Direction inverted by default (horizontal awnings: IO 0 is closed).
static constexpr DeviceFeatures PARTIAL
Named position 0xD809, sent by the Partial Position button: a garage opener runs its stored partial p...
static constexpr DeviceFeatures FAVORITE
Named position 0xD800, the favourite ("my") position.
static constexpr DeviceFeatures LEVELS
Intermediate main-parameter values: a percent position, a brightness or a heat level.
static constexpr DeviceFeatures MAIN_PARAMETER_ONLY
EXECUTE carries no functional parameter at all (VELUX KLF 200 API specification, Appendix 2: "main pa...
constexpr bool has_feature(DeviceFeatures set, DeviceFeatures bit)
True when every bit of bit is set in set.
uint16_t DeviceFeatures
Capability bits of a device kind; see device_feature.