16constexpr size_t DEVICE_TYPE_HEX_STRING_BUFFER_SIZE = 8;
19std::string format_device_type_hex(
DeviceType type) {
20 char buf[DEVICE_TYPE_HEX_STRING_BUFFER_SIZE];
21 snprintf(buf,
sizeof(buf),
"0x%02X",
static_cast<uint8_t
>(type));
22 return std::string(buf);
28 switch (capability_class) {
57 return "UNKNOWN_COVER_CMD";
69 const auto raw =
static_cast<uint8_t
>(type);
82 }
else if (is_stopped && current_valid) {
86 target = decoded_current;
92 position = decoded_current;
93 }
else if (is_stopped && target_valid) {
104 return std::fabs(target - position) <= tolerance;
118 return "venetian_blind";
120 return "roller_shutter";
126 return "window_opener";
128 return "garage_opener";
132 return "gate_opener";
134 return "rolling_door_opener";
138 return "dual_shutter";
140 return "on_off_switch";
142 return "horizontal_awning";
144 return "external_venetian_blind";
146 return "louvre_blind";
148 return "curtain_track";
150 return "swinging_shutter";
156 return "heating_temperature_interface";
158 return "ventilation_point";
160 return "exterior_heating";
164 return "intrusion_alarm";
175 return "venetian_blind";
177 return "roller_shutter";
181 return "window_opener";
183 return "garage_opener";
187 return "gate_opener";
189 return "rolling_door_opener";
197 return "dual_shutter";
199 return "heating_temperature_interface";
201 return "on_off_switch";
203 return "horizontal_awning";
205 return "external_venetian_blind";
207 return "louvre_blind";
209 return "curtain_track";
211 return "intrusion_alarm";
213 return "swinging_shutter";
330 return "binary_on_off";
349 std::string raw = format_device_type_hex(type);
350 if (name !=
nullptr && strcmp(name,
"unknown") != 0) {
351 return std::string(name) +
" (" + raw +
")";
358 if (name !=
nullptr) {
359 return std::string(
"\"") + name +
"\"";
361 return format_device_type_hex(type);
365 bool metadata_complete,
bool inverted) {
366 if (!metadata_complete) {
367 return " <cover|light|switch|lock>:\n"
368 " - platform: home_io_control\n"
369 " name: \"My Device\"\n"
370 " io_device_id: \"" +
373 " # io_device_type: left unset — this device didn't report its type during\n"
374 " # discovery, so the controller learns it automatically from the next status\n"
375 " # reply. Add it explicitly once you see it logged, to skip re-learning on\n"
376 " # every future boot.\n";
380 const char *platform = pairing_platform_name(capability_class);
381 if (platform ==
nullptr)
384 std::string extra_lines;
386 extra_lines +=
" invert_position: true\n";
388 const std::string subtype_line =
" io_subtype: " + std::to_string(subtype) +
"\n";
390 return " " + std::string(platform) +
392 " - platform: home_io_control\n"
393 " name: \"My Device\"\n"
394 " io_device_id: \"" +
const char * device_operation_profile_name(DeviceType type)
Human‑readable operation profile name for a device type.
void encode_packed_device_type(DeviceType type, uint8_t subtype, uint8_t &type_msb, uint8_t &type_subtype)
Encode a DeviceType/subtype pair into the two-byte packed metadata format used by discovery responses...
static constexpr float UNKNOWN_POSITION
Sentinel value meaning "position is not known yet".
static constexpr uint16_t STATUS_POS_MAX
In status responses, position is encoded as a 16-bit value where 0x0000 = fully open (0%) and 0xC800 ...
std::string format_device_type_for_yaml(DeviceType type)
Build the YAML value for a device's io_device_type key.
static constexpr uint8_t DEVICE_TYPE_HIGH_BITS_SHIFT
DeviceType
Device type identifiers reported by IO‑Homecontrol products.
@ LOUVRE_BLIND
Louvre blind.
@ GATE_OPENER
Gate opener.
@ DUAL_SHUTTER
Dual-section shutter.
@ HEATING_TEMPERATURE_INTERFACE
Heating temperature interface.
@ BEACON
Beacon (unpaired/announcement).
@ EXTERNAL_VENETIAN_BLIND
External venetian blind.
@ UNKNOWN
Unknown/unspecified device.
@ INTRUSION_ALARM
Intrusion alarm.
@ WINDOW_OPENER
Window opening actuator.
@ SWINGING_SHUTTER
Swinging shutter.
@ HORIZONTAL_AWNING
Horizontal awning (open/close inverted).
@ ROLLING_DOOR_OPENER
Rolling door opener.
@ ON_OFF_SWITCH
Generic on/off switch.
@ SCREEN
Insect/privacy screen.
@ EXTERIOR_HEATING
Exterior heating.
@ VENTILATION_POINT
Ventilation point.
@ VENETIAN_BLIND
Venetian blind.
@ ROLLER_SHUTTER
Roller shutter.
@ CURTAIN_TRACK
Curtain track.
@ GARAGE_OPENER
Garage door opener.
static constexpr uint16_t STATUS_POS_TOLERANCE_RAW
Target-reached tolerance expressed in raw IO-homecontrol position units.
std::string build_device_yaml_snippet(DeviceType type, uint8_t subtype, const std::string &device_id, bool metadata_complete, bool inverted)
Build the ready-to-paste YAML block describing a device, for both a fully-decoded device and one whos...
DeviceCapabilityClass device_capability_class(DeviceType type)
Map a raw IO‑Homecontrol type to the closest ESPHome/Home Assistant entity family.
bool default_inverted_for_type(DeviceType type)
Determine whether a device type has inverted position mapping by default.
CoverCommand
Named device commands for cover-type actuators.
@ FAVORITE
Move to stored favorite/"My" position.
@ STOP
Stop movement immediately.
@ VENT
Move to ventilation position (window-type devices).
@ FORCE_OPEN
Move to fully open at elevated priority; intended to bypass soft locks and environmental limits (conf...
bool device_supports_position_control(DeviceType type)
Does this device type support precise position control (0–100)?
bool device_supports_vent(DeviceType type)
Does this device type support the ventilation position command?
const char * device_type_name(DeviceType type)
Convert a DeviceType to a lowercase string identifier.
bool device_supports_binary_control(DeviceType type)
Does this device type support binary on/off control?
float decode_tilt_report(uint16_t tilt_raw)
Decode tilt angle from raw 16‑bit value.
bool device_supports_lock_control(DeviceType type)
Does this device type support binary lock/unlock control via execute commands?
DeviceType decode_packed_device_type(uint8_t type_msb, uint8_t type_subtype)
Decode a protocol-packed device type from two metadata bytes.
const char * cover_command_name(CoverCommand cmd)
Get a human-readable name for a CoverCommand.
const char * device_capability_class_name(DeviceType type)
Get a human‑readable name for a capability class.
uint8_t decode_packed_device_subtype(uint8_t type_subtype)
Decode a protocol-packed device subtype from the second metadata byte.
bool device_supports_status_requests(DeviceType type)
Does this device type support status request commands (0x03)?
static constexpr uint8_t DEVICE_SUBTYPE_MASK
bool has_reached_target_position(float target, float position)
Has the device reached its target within tolerance?
const char * yaml_device_type_name(DeviceType type)
Return the YAML-friendly device-type name for types exposed in the Python schema.
DeviceCapabilityClass
High‑level capability class derived from DeviceType.
@ CLIMATE
Climate device (heating/cooling).
@ SWITCH
Binary on/off switch.
@ UNKNOWN
Unknown capability.
@ COVER
Position‑controlled cover (shutter/blind/awning).
@ LIGHT
Binary on/off light.
static constexpr uint8_t DEVICE_TYPE_LOW_BITS_SHIFT
std::string format_device_type_diagnostic(DeviceType type)
Human-readable device type string for diagnostics, including the raw numeric value.
void decode_position_report(uint16_t target_raw, uint16_t current_raw, bool is_stopped, float &target, float &position)
Decode target/current position values from a status frame.
bool device_supports_tilt(DeviceType type)
Does this device type support tilt (slat angle) control?
IO-Homecontrol device-type model, capabilities and runtime device state.