blaeck 1.0.0
Frames
B7 — Device List (0xB7)
The board and its sub-devices: library, command length, then per device its ID, parent, flags, state, names and signals.
| Element | Size | Type | Description |
|---|---|---|---|
| LibName | variable | string | Library name |
| LibVersion | variable | string | Library version (e.g., "1.0.0") |
| CommandPayloadMax | 2 bytes | uint16 | Longest command the device can receive: the characters between < and > as sent, the #id: prefix and percent-encoding included. 0 = not advertised |
| DeviceCount | 1 byte | uint8 | Number of device entries in the frame: 1–255, the board plus its sub-devices |
| DeviceID | 1 byte | uint8 | 0 = the board; 1–254 = a sub-device. 255 is reserved |
| ParentID | 1 byte | uint8 | DeviceID of the device it sits below. 0 for the board itself and for every sub-device (one level) |
| DeviceFlags | 2 bytes | uint16 | Which optional fields follow the versions, one bit each. All bits reserved and sent as 0 |
| DeviceState | 1 byte | uint8 | Bit 0 NotResponding (marked missing now); bit 1 Restarted (a restart not yet reported to a host). Bits 2–7 reserved, 0 |
| DeviceName | variable | string | Device name. Not empty, no control characters, and unique on the board: no two devices, the board included, share a name |
| HWVersion | variable | string | Hardware version |
| FWVersion | variable | string | Firmware version |
| OptionalFields | variable | string | One null-terminated string per bit set in DeviceFlags, in bit order. None are defined yet |
| SignalCount | 2 bytes | uint16 | Number of signals the device logs; that many SignalName, SignalUnit and DTYPE groups follow |
| SignalName | variable | string | Signal name. Not empty, unique among the signals of its device, no control characters |
| SignalUnit | variable | string | Unit of the signal's values, such as V, mA or °C. Empty for none. No control characters. Use the spelling Home Assistant uses, so a host can convert between units |
| DTYPE | 1 byte | uint8 | Datatype code (0x00–0x0B). See Datatypes |
| CRC32 | 4 bytes | uint32 | Integrity checksum over the unescaped bytes from the message key to the last field. Every frame ends with it. See CRC32 |
D3 — Data (0xD3)
Signal values with SchemaHash, 8-byte Timestamp, and CRC32.
| Element | Size | Type | Description |
|---|---|---|---|
| FrameFlags | 1 byte | uint8 | Bit 0 = first frame after restart. Bit 1 = answers BLAECK.WRITE_DATA. Bit 2 = includes a host-interval report, also when mixed with change reports. Bits 1 and 2 never both set; explicit writes and change reports leave both clear. Bits 3-7 reserved, sent clear. Test the bits; do not compare the byte |
| SchemaHash | 2 bytes | uint16 | CRC-16/XMODEM over the signal list of the Device List. See Schema Hash |
| TimestampMode | 1 byte | uint8 | 0 = none. 1 = micros: microseconds since the device started; it never wraps and never goes back, except at a restart, where it begins again near 0 and FrameFlags bit 0 is set. 2 = UNIX: microseconds since 1970-01-01 00:00:00 UTC, without leap seconds, as the device's clock tells it; it may jump when that clock is set |
| Timestamp64 | 8 bytes | uint64 | Conditional: only if TimestampMode > 0 |
| SignalIndex | 2 bytes | uint16 | Zero-based signal index, counted across all devices in Device List order |
| DATA | variable | raw bytes | Signal value, size per DTYPE. Fixed width except DTYPE 0x0A, which is length-prefixed |
| CRC32 | 4 bytes | uint32 | Integrity checksum over the unescaped bytes from the message key to the last field. Every frame ends with it. See CRC32 |
C1 — Device Notification (0xC1)
A device restarted, stopped responding, or responds again.
| Element | Size | Type | Description |
|---|---|---|---|
| DeviceID | 1 byte | uint8 | 0 = the board; 1–254 = a sub-device. 255 is reserved |
| DeviceEvent | 1 byte | uint8 | 0x01 restarted, 0x02 not responding, 0x03 responding again. 0x00 and 0x04–0xFF reserved |
| CRC32 | 4 bytes | uint32 | Integrity checksum over the unescaped bytes from the message key to the last field. Every frame ends with it. See CRC32 |
A5 — Command Ack (0xA5)
Outcome of a dispatched command. The header MessageID echoes the message id the command carried in its # prefix, or 0 when it carried none; the hashes then say whether the bytes arrived as written.
| Element | Size | Type | Description |
|---|---|---|---|
| CmdHash | 4 bytes | uint32 | FNV-1a 32 hash of the command after its message id, identifying which command is acknowledged |
| CmdNameHash | 4 bytes | uint32 | FNV-1a 32 hash of the command name alone (up to the first comma), or 0 if no name was parsed |
| AckStatus | 1 byte | uint8 | 0 = accepted, 1 = rejected |
| AckReason | 1 byte | uint8 | Reason code. See Ack Reasons |
| CRC32 | 4 bytes | uint32 | Integrity checksum over the unescaped bytes from the message key to the last field. Every frame ends with it. See CRC32 |
90 — Entity List (0x90)
What a host shows and controls: properties, events and buttons, each entry with its DeviceID, kind and length.
| Element | Size | Type | Description |
|---|---|---|---|
| DeviceID | 1 byte | uint8 | 0 = the board; 1–254 = a sub-device. 255 is reserved |
| EntryKind | 1 byte | uint8 | 0 property, 1 event, 2 button. 3–255 reserved: a host skips an entry of a kind it does not know |
| EntryLength | 2 bytes | uint16 | Number of bytes that follow in this entry, from its name to its last field, before escaping. DeviceID, EntryKind and EntryLength are not counted. The next entry starts right after them |
| EntryFields | variable | raw bytes | The fields of the entry's kind. See Entities |
| CRC32 | 4 bytes | uint32 | Integrity checksum over the unescaped bytes from the message key to the last field. Every frame ends with it. See CRC32 |
Property entry (EntryKind 0)
A value a host shows (a sensor) or shows and sets (an input). Kind-bound fields follow the value; optional fields follow in flag-bit order.
| Element | Size | Type | Description |
|---|---|---|---|
| Name | variable | string | Property name, as a host sends it in <Name,value>. ASCII letters, digits, _, - and . only. Unique on the board among properties, buttons and plain commands |
| ValueKind | 1 byte | uint8 | 0 number, 1 bool, 2 enum, 3 text. 4–255 reserved. With the access, it is what the sketch declared: a READ number is a sensor, a READWRITE one a number input, a READ bool an on/off indicator, a READWRITE one a switch, a READ enum an enum sensor, a READWRITE one a select, a READ text a text sensor, a READWRITE one a text input |
| Flags | 4 bytes | uint32 | Bits 0–1 = access: 01 READ, 11 READWRITE; 10 (write only) and 00 reserved. Bit 2 = hasRange, 3 = hasStep, 4 = hasUnit, 5 = hasDisplayName, 6 = hasIcon, 7 = hasDeviceClass, 8–10 = state class (0 none, 1 measurement, 2 total, 3 total\_increasing, 4 measurement\_angle), 11 = hasDisplayPrecision, 12–13 = entity category (0 none, 1 config, 2 diagnostic, 3 reserved), 14 = disabledByDefault, 15 = forceUpdate, 16–17 = input mode (number: 0 auto, 1 box, 2 slider; text: 0 plain, 1 password; 3 reserved). Bits 18–31 reserved, sent clear |
| DTYPE | 1 byte | uint8 | Datatype code (0x00–0x0B). See Datatypes |
| Value | variable | raw bytes | The property's value, size per DTYPE. Fixed width except 0x0A, which is a 1-byte length followed by that many UTF-8 bytes, at most 255, as in DATA. An enum's value is its index |
| Options | variable | string | Enum only, always present. Comma-separated options in index order; at least one, none blank, none with leading or trailing spaces. Each option is percent-encoded (%2C a comma, %25 a percent sign; %00 is not an escape): a host splits on the commas, then decodes, then drops outer spaces. An input accepts an index or a decoded option name, matched exactly with case |
| TextMaxLen | 1 byte | uint8 | Text only, always present. Longest value, in bytes after percent-decoding: 0–255 |
| RangeMin | variable | raw bytes | Conditional: only if Flags bit 2. Lowest value an input accepts, inclusive. In the property's own type and at its width, size per DTYPE, exactly as Value. A device declares no range rather than one its variable cannot hold, so both limits always fit the DTYPE. Without bit 2 both limits are absent; do not read them as 0 |
| RangeMax | variable | raw bytes | Conditional: only if Flags bit 2. Highest value an input accepts, inclusive, and above RangeMin. In the property's own type and at its width, size per DTYPE, exactly as Value |
| RangeStep | variable | raw bytes | Conditional: only if Flags bit 3. The step a number input stores on, counted from RangeMin. A value within a thousandth of a step of one is snapped to it; a value further off is kept as sent. In the property's own type and at its width, size per DTYPE, exactly as Value - not widened to a float64. Widening keeps the value and loses the decimal it was written as: a step of 0.01 on a board whose double is a float is held as 0.00999999977, and a float64 carrying that exactly reads as 0.009999999776482582, from which a host counting RangeMin + n * RangeStep cannot land on 0.05. At its own width the same step reads back as the shortest decimal that names it, which is the 0.01 the sketch declared |
| Unit | variable | string | Conditional: only if Flags bit 4 |
| DisplayName | variable | string | Conditional: only if the entry's display-name bit is set. Label a host shows in place of the name. Presentation only: the name stays what a host sends and what any identity it derives is built from |
| Icon | variable | string | Conditional: only if the entry's icon bit is set. Material Design Icons name (e.g. "mdi:tune") |
| DeviceClass | variable | string | Conditional: only if the entry's device-class bit is set. What the value, event or button is, in the host's vocabulary ("temperature", "door", "restart"). A name the host does not know costs that one entity, so a device declares nothing rather than guessing |
| DisplayPrecision | 1 byte | uint8 | Conditional: only if Flags bit 11. Decimal places to display |
Event entry (EntryKind 1)
A moment the device reports, with the closed list of its types.
| Element | Size | Type | Description |
|---|---|---|---|
| Name | variable | string | Event name. Not empty, unique among the events of its device, no control characters |
| Flags | 2 bytes | uint16 | Bit 0 = hasDisplayName, 1 = hasIcon, 2 = hasDeviceClass, 3–4 = entity category (0 none, 1 config, 2 diagnostic, 3 reserved), 5 = disabledByDefault. Bits 6–15 reserved |
| DisplayName | variable | string | Conditional: only if the entry's display-name bit is set. Label a host shows in place of the name. Presentation only: the name stays what a host sends and what any identity it derives is built from |
| Icon | variable | string | Conditional: only if the entry's icon bit is set. Material Design Icons name (e.g. "mdi:tune") |
| DeviceClass | variable | string | Conditional: only if the entry's device-class bit is set. What the value, event or button is, in the host's vocabulary ("temperature", "door", "restart"). A name the host does not know costs that one entity, so a device declares nothing rather than guessing |
| EventTypeCount | 2 bytes | uint16 | Number of EventType entries that follow; at least one |
| EventType | variable | string | Declared event type, plain text (not percent-encoded), not blank, no leading or trailing spaces. Position defines its index |
Button entry (EntryKind 2)
A moment a host triggers by sending the button's name.
| Element | Size | Type | Description |
|---|---|---|---|
| Name | variable | string | Button name, as a host sends it in <Name>. ASCII letters, digits, _, - and . only. Unique on the board among properties, buttons and plain commands |
| Flags | 2 bytes | uint16 | Bit 0 = hasDisplayName, 1 = hasIcon, 2 = hasDeviceClass, 3–4 = entity category (0 none, 1 config, 2 diagnostic, 3 reserved), 5 = disabledByDefault. Bits 6–15 reserved |
| DisplayName | variable | string | Conditional: only if the entry's display-name bit is set. Label a host shows in place of the name. Presentation only: the name stays what a host sends and what any identity it derives is built from |
| Icon | variable | string | Conditional: only if the entry's icon bit is set. Material Design Icons name (e.g. "mdi:tune") |
| DeviceClass | variable | string | Conditional: only if the entry's device-class bit is set. What the value, event or button is, in the host's vocabulary ("temperature", "door", "restart"). A name the host does not know costs that one entity, so a device declares nothing rather than guessing |
95 — Property (0x95)
Current value of a property, written when it changes and after a host sets it. Not logged.
| Element | Size | Type | Description |
|---|---|---|---|
| PropertyIndex | 2 bytes | uint16 | Zero-based position of the property among the properties of the Entity List |
| DTYPE | 1 byte | uint8 | Datatype code (0x00–0x0B). See Datatypes |
| Value | variable | raw bytes | The property's value, size per DTYPE. Fixed width except 0x0A, which is a 1-byte length followed by that many UTF-8 bytes, at most 255, as in DATA. An enum's value is its index |
| CRC32 | 4 bytes | uint32 | Integrity checksum over the unescaped bytes from the message key to the last field. Every frame ends with it. See CRC32 |
85 — Event (0x85)
One occurrence of an event, identified by its index among the events and the index of its type.
| Element | Size | Type | Description |
|---|---|---|---|
| EventIndex | 2 bytes | uint16 | Zero-based position of the event among the events of the Entity List |
| EventTypeIndex | 2 bytes | uint16 | Zero-based index into the event's EventType list |
| CRC32 | 4 bytes | uint32 | Integrity checksum over the unescaped bytes from the message key to the last field. Every frame ends with it. See CRC32 |