Skip to content

Constants and utilities

enocean.protocol.constants

Constants of the EnOcean Serial Protocol 3 (ESP3) and of the telegram types (RORG).

PACKET

Bases: IntEnum

ESP3 packet types: radio telegrams, responses to commands, events, commands to the module.

RORG

Bases: IntEnum

Radio telegram types, the first byte of a radio telegram (the RORG of an EEP, e.g. D2 in D2-01-12).

RETURN_CODE

Bases: IntEnum

Return code of a RESPONSE packet, the module's answer to a command.

EVENT_CODE

Bases: IntEnum

Code of an EVENT packet, sent by the module on its own (e.g. Smart Acknowledge events).

PARSE_RESULT

Bases: IntEnum

Outcome of Packet.parse_msg(): a packet, not enough bytes yet, or corrupted bytes that were skipped.

enocean.utils

Conversions between bytes, integers, bit arrays and hex strings.

get_bit

get_bit(byte: int, bit: int) -> int

Get bit value from byte.

combine_hex

combine_hex(data: Iterable[int]) -> int

Combine list of integer values to one big integer.

to_bitarray

to_bitarray(
    data: int | list[int] | bytearray, width: int = 8
) -> list[bool]

Convert data (list of integers, bytearray or integer) to bitarray.

from_bitarray

from_bitarray(data: Iterable[bool]) -> int

Convert bit array back to integer.

to_hex_string

to_hex_string(data: int | Iterable[int]) -> str

Convert list of integers to a hex string, separated by ":".

from_hex_string

from_hex_string(hex_string: str) -> int | list[int]

Parse a hex string: '05:99:77:AF' gives [0x05, 0x99, 0x77, 0xAF], a single byte ('A5') an int.