Common functions¶
cbus.common defines various common helper utilities used by the library, and constants required to communicate with the C-Bus network.
The majority of the functionality shouldn’t be needed by your own application, however it is used internally within the protocol encoders and decoders.
-
class
cbus.common.Application¶ Bases:
enum.IntEnumAn enumeration.
-
CLOCK= 223¶
-
ENABLE= 203¶
-
LIGHTING= 56¶
-
LIGHTING_30= 48¶
-
LIGHTING_31= 49¶
-
LIGHTING_32= 50¶
-
LIGHTING_33= 51¶
-
LIGHTING_34= 52¶
-
LIGHTING_35= 53¶
-
LIGHTING_36= 54¶
-
LIGHTING_37= 55¶
-
LIGHTING_38= 56¶
-
LIGHTING_39= 57¶
-
LIGHTING_3a= 58¶
-
LIGHTING_3b= 59¶
-
LIGHTING_3c= 60¶
-
LIGHTING_3d= 61¶
-
LIGHTING_3e= 62¶
-
LIGHTING_3f= 63¶
-
LIGHTING_40= 64¶
-
LIGHTING_41= 65¶
-
LIGHTING_42= 66¶
-
LIGHTING_43= 67¶
-
LIGHTING_44= 68¶
-
LIGHTING_45= 69¶
-
LIGHTING_46= 70¶
-
LIGHTING_47= 71¶
-
LIGHTING_48= 72¶
-
LIGHTING_49= 73¶
-
LIGHTING_4a= 74¶
-
LIGHTING_4b= 75¶
-
LIGHTING_4c= 76¶
-
LIGHTING_4d= 77¶
-
LIGHTING_4e= 78¶
-
LIGHTING_4f= 79¶
-
LIGHTING_50= 80¶
-
LIGHTING_51= 81¶
-
LIGHTING_52= 82¶
-
LIGHTING_53= 83¶
-
LIGHTING_54= 84¶
-
LIGHTING_55= 85¶
-
LIGHTING_56= 86¶
-
LIGHTING_57= 87¶
-
LIGHTING_58= 88¶
-
LIGHTING_59= 89¶
-
LIGHTING_5a= 90¶
-
LIGHTING_5b= 91¶
-
LIGHTING_5c= 92¶
-
LIGHTING_5d= 93¶
-
LIGHTING_5e= 94¶
-
LIGHTING_5f= 95¶
-
LIGHTING_FIRST= 48¶
-
LIGHTING_LAST= 95¶
-
MASTER_APPLICATION= 255¶
-
STATUS_REQUEST= 255¶
-
TEMPERATURE= 25¶
-
-
class
cbus.common.CAL¶ Bases:
enum.IntEnumAn enumeration.
-
ACKNOWLEDGE= 50¶
-
EXTENDED_STATUS= 224¶
-
GET_STATUS= 42¶
-
IDENTIFY= 33¶
-
RECALL= 26¶
-
REPLY= 128¶
-
RESET= 8¶
-
STANDARD_STATUS= 192¶
-
-
class
cbus.common.ClockCommand¶ Bases:
enum.IntEnumAn enumeration.
-
REQUEST_REFRESH= 17¶
-
UPDATE_NETWORK_VARIABLE= 8¶
-
-
class
cbus.common.DestinationAddressType¶ Bases:
enum.IntEnumDestination Address Type (DAT).
Ref: Serial Interface Guide, s3.4. Other values reserved.
-
POINT_TO_MULTIPOINT= 5¶
-
POINT_TO_POINT= 6¶
-
POINT_TO_POINT_TO_MULTIPOINT= 3¶
-
UNSET= 0¶
-
-
class
cbus.common.GroupState¶ Bases:
enum.IntEnumAn enumeration.
-
ERROR= 3¶
-
MISSING= 0¶
-
OFF= 2¶
-
ON= 1¶
-
-
class
cbus.common.IdentifyAttribute¶ Bases:
enum.IntEnumIDENTIFY attributes.
See Serial Interface Guide, s7.2.
-
CUR_LVL= 15¶
-
DELAYS= 12¶
-
DSI_STATUS= 17¶
-
EXTENDED= 4¶
-
FIRMWARE_VER= 2¶
-
GAV_CURRENT= 8¶
-
GAV_PHY_ADDR= 10¶
-
GAV_STORED= 9¶
-
LOGIC_ASSIGN= 11¶
-
MANUFACTURER= 0¶
-
MAX_LVL= 14¶
-
MIN_LVL= 13¶
-
NET_TERM_LVL= 5¶
-
NET_VOLTAGE= 7¶
-
OUT_SUMMARY= 16¶
-
SUMMARY= 3¶
-
TERM_LVL= 6¶
-
TYPE= 1¶
-
-
class
cbus.common.LightCommand¶ Bases:
enum.IntEnumAn enumeration.
-
LIGHT_LABEL= 160¶
-
OFF= 1¶
-
ON= 121¶
-
RAMP_00_04= 10¶
-
RAMP_00_08= 18¶
-
RAMP_00_12= 26¶
-
RAMP_00_20= 34¶
-
RAMP_00_30= 42¶
-
RAMP_00_40= 50¶
-
RAMP_01_00= 58¶
-
RAMP_01_30= 66¶
-
RAMP_02_00= 74¶
-
RAMP_03_00= 82¶
-
RAMP_05_00= 90¶
-
RAMP_07_00= 98¶
-
RAMP_10_00= 106¶
-
RAMP_15_00= 114¶
-
RAMP_17_00= 122¶
-
RAMP_FASTEST= 2¶
-
RAMP_INSTANT= 2¶
-
RAMP_SLOWEST= 122¶
-
TERMINATE_RAMP= 9¶
-
-
class
cbus.common.PriorityClass¶ Bases:
enum.IntEnumAn enumeration.
-
CLASS_1= 3¶
-
CLASS_2= 2¶
-
CLASS_3= 1¶
-
CLASS_4= 0¶
-
-
cbus.common.add_cbus_checksum(i: bytes) → bytes¶ Appends a C-Bus checksum to a given message.
Parameters: i (bytes) – The C-Bus message to append a checksum to. Must not be in base16 format. Returns: The C-Bus message with the checksum appended to it. Return type: bytes
-
cbus.common.cbus_checksum(i: bytes) → int¶ Calculates the checksum of a C-Bus command string.
Fun fact: C-Bus toolkit and C-Gate do not use commands with checksums.
Parameters: i (bytes) – The C-Bus data to calculate the checksum of. Must not be in base16 format. Returns: The checksum value of the given input
-
cbus.common.check_ga(group_addr: int) → None¶ Validates a given group address, throwing ValueError if not.
Parameters: group_addr – Input group address to validate. Raises: ValueError – If group address is invalid
-
cbus.common.duration_to_ramp_rate(seconds: int) → cbus.common.LightCommand¶ Converts a given duration into a ramp rate code.
Parameters: seconds (int) – The number of seconds that the ramp is over. Returns: The ramp rate code for the duration given. Return type: int
-
cbus.common.get_real_cbus_checksum(i: bytes) → int¶ Calculates the current C-Bus checksum for a given message which already has a checksum appended to it.
Parameters: i – The C-Bus message to generate an actual checksum for, in raw format.
-
cbus.common.ramp_rate_to_duration(rate: int) → int¶ Converts a given ramp rate code into a duration in seconds.
Parameters: rate (int) – The ramp rate code to convert. Returns: The number of seconds the ramp runs over. Return type: int Raises: KeyError – If the given ramp rate code is invalid.
-
cbus.common.validate_cbus_checksum(i: bytes) → bool¶ Verifies a C-Bus checksum from a given message.
Parameters: i – The C-Bus message to verify the checksum of, in raw format. Returns: True if the checksum is correct, False otherwise.
-
cbus.common.validate_ga(group_addr: int) → bool¶ Validates a given group address.
Parameters: group_addr – Input group address to validate. Returns: True if the given group address is valid, False otherwise.