Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_pytype_to_datatype_derived_bitmaps():
"""Test pytype_to_datatype_id lookup for derived enums."""
class b_1(t.bitmap8):
pass
class b_2(t.bitmap8):
pass
class b_3(t.bitmap16):
pass
bitmap8_id = foundation.DATA_TYPES.pytype_to_datatype_id(t.bitmap8)
bitmap16_id = foundation.DATA_TYPES.pytype_to_datatype_id(t.bitmap16)
assert foundation.DATA_TYPES.pytype_to_datatype_id(b_1) == bitmap8_id
assert foundation.DATA_TYPES.pytype_to_datatype_id(b_2) == bitmap8_id
assert foundation.DATA_TYPES.pytype_to_datatype_id(b_3) == bitmap16_id
assert foundation.DATA_TYPES.pytype_to_datatype_id(b_2) == bitmap8_id
assert foundation.DATA_TYPES.pytype_to_datatype_id(b_3) == bitmap16_id
0x0B05,
SmartthingsRelativeHumidityCluster,
]
}
}
}
class SmartThingsAccelCluster(CustomCluster):
cluster_id = 0xFC02
name = "Smartthings Accelerometer"
ep_attribute = "accelerometer"
attributes = {
0x0000: ("motion_threshold_multiplier", t.uint8_t),
0x0002: ("motion_threshold", t.uint16_t),
0x0010: ("acceleration", t.bitmap8), # acceleration detected
0x0012: ("x_axis", t.int16s),
0x0013: ("y_axis", t.int16s),
0x0014: ("z_axis", t.int16s),
}
client_commands = {}
server_commands = {}
class SmartthingsMultiPurposeSensor(CustomDevice):
signature = {
"endpoints": {
#
1: {
profile_id: t.uint16_t
device_id: t.uint16_t
version: t.uint8_t
class GroupInfoRecord(t.Struct):
group_id: t.Group
group_type: t.uint8_t
class LightLink(Cluster):
cluster_id = 0x1000
ep_attribute = "lightlink"
attributes = {}
server_commands = {
0x0000: ("scan", (t.uint32_t, t.bitmap8, t.bitmap8), False),
0x0002: ("device_information", (t.uint32_t, t.uint8_t), False),
0x0006: ("identify", (t.uint32_t, t.uint16_t), False),
0x0007: ("reset_to_factory_new", (t.uint32_t,), False),
0x0010: ("network_start", NET_START, False),
0x0012: ("network_join_router", NET_JOIN, False),
0x0014: ("network_join_end_device", NET_JOIN, False),
0x0016: (
"network_update",
(t.uint32_t, t.EUI64, t.uint8_t, t.uint8_t, t.NWK, t.NWK),
False,
),
0x0041: ("get_group_identifiers", (t.uint8_t,), False),
0x0042: ("get_endpoint_list", (t.uint8_t,), False),
}
client_commands = {
0x0001: (
("SrcEndpoint", t.uint8_t),
("ClusterID", t.uint16_t),
("DstAddress", MultiAddress),
),
ZDOCmd.Unbind_req: (
("SrcAddress", t.EUI64),
("SrcEndpoint", t.uint8_t),
("ClusterID", t.uint16_t),
("DstAddress", MultiAddress),
),
# Network Management Server Services Requests
# ... TODO optional stuff ...
ZDOCmd.Mgmt_Lqi_req: (("StartIndex", t.uint8_t),),
ZDOCmd.Mgmt_Rtg_req: (("StartIndex", t.uint8_t),),
# ... TODO optional stuff ...
ZDOCmd.Mgmt_Leave_req: (("DeviceAddress", t.EUI64), ("Options", t.bitmap8)),
ZDOCmd.Mgmt_Permit_Joining_req: (
("PermitDuration", t.uint8_t),
("TC_Significant", t.Bool),
),
ZDOCmd.Mgmt_NWK_Update_req: (("NwkUpdate", NwkUpdate),),
# ... TODO optional stuff ...
# Responses
# Device and Service Discovery Server Responses
ZDOCmd.NWK_addr_rsp: (
STATUS,
IEEE,
NWK,
("NumAssocDev", t.Optional(t.uint8_t)),
("StartIndex", t.Optional(t.uint8_t)),
("NWKAddressAssocDevList", t.Optional(t.List(t.NWK))),
),
class UserStatus(t.enum8):
Available = 0x00
Enabled = 0x01
Disabled = 0x03
Not_Supported = 0xFF
class UserType(t.enum8):
Unrestricted = 0x00
Year_Day_Schedule_User = 0x01
Week_Day_Schedule_User = 0x02
Master_User = 0x03
Non_Access_User = 0x04
Not_Supported = 0xFF
class DayMask(t.bitmap8):
Sun = 0x01
Mon = 0x02
Tue = 0x04
Wed = 0x08
Thu = 0x10
Fri = 0x20
Sat = 0x40
class EventType(t.enum8):
Operation = 0x00
Programming = 0x01
Alarm = 0x02
cluster_id = 0x0101
name = "Door Lock"
ep_attribute = "door_lock"
0x0002: ("zone_status", ZoneStatus),
# Zone Settings
0x0010: ("cie_addr", t.EUI64),
0x0011: ("zone_id", t.uint8_t),
0x0012: ("num_zone_sensitivity_levels_supported", t.uint8_t),
0x0013: ("current_zone_sensitivity_level", t.uint8_t),
}
server_commands = {
0x0000: ("enroll_response", (EnrollResponse, t.uint8_t), True),
0x0001: ("init_normal_op_mode", (), False),
0x0002: ("init_test_mode", (t.uint8_t, t.uint8_t), False),
}
client_commands = {
0x0000: (
"status_change_notification",
(ZoneStatus, t.bitmap8, t.uint8_t, t.uint16_t),
False,
),
0x0001: ("enroll", (ZoneType, t.uint16_t), False),
}
class IasAce(Cluster):
class AlarmStatus(t.enum8):
"""IAS ACE alarm status enum."""
No_Alarm = 0x00
Burglar = 0x01
Fire = 0x02
Emergency = 0x03
Police_Panic = 0x04
Fire_Panic = 0x05
[ConfigureReportingResponseRecord(i).serialize() for i in failed]
)
return Status.SUCCESS.serialize()
class ReadReportingConfigRecord(t.Struct):
direction: t.uint8_t
attrid: t.uint16_t
class DiscoverAttributesResponseRecord(t.Struct):
attrid: t.uint16_t
datatype: t.uint8_t
class AttributeAccessControl(t.bitmap8):
READ = 0x01
WRITE = 0x02
REPORT = 0x04
class DiscoverAttributesExtendedResponseRecord(t.Struct):
attrid: t.uint16_t
datatype: t.uint8_t
acl: AttributeAccessControl
class Command(t.enum8):
"""ZCL Foundation Global Command IDs."""
Read_Attributes = 0x00
Read_Attributes_rsp = 0x01
0x004F: ("object_type", t.enum16),
0x0076: ("update_interval", t.uint8_t),
0x00A8: ("profile_name", t.CharacterString),
}
server_commands = {}
client_commands = {}
class AnalogOutputExtended(Cluster):
cluster_id = 0x0605
ep_attribute = "bacnet_extended_analog_output"
attributes = {
0x0000: ("acked_transitions", t.bitmap8),
0x0011: ("notification_class", t.uint16_t),
0x0019: ("deadband", t.Single),
0x0023: ("event_enable", t.bitmap8),
0x0024: ("event_state", t.enum8),
0x002D: ("high_limit", t.Single),
0x0034: ("limit_enable", t.bitmap8),
0x003B: ("low_limit", t.Single),
0x0048: ("notify_type", t.enum8),
0x0071: ("time_delay", t.uint8_t),
# 0x0082: ('event_time_stamps', TODO.array)# Array[3] of (16-bit unsigned
# integer, time of day, or structure of (date, time of day))
}
server_commands = {}
client_commands = {}
class AnalogValueRegular(Cluster):
cluster_id = 0x0606
ep_attribute = "bacnet_regular_analog_value"
0x010F: ("current_tier8_summ_received", t.uint48_t),
0x0110: ("current_tier9_summ_delivered", t.uint48_t),
0x0111: ("current_tier9_summ_received", t.uint48_t),
0x0112: ("current_tier10_summ_delivered", t.uint48_t),
0x0113: ("current_tier10_summ_received", t.uint48_t),
0x0114: ("current_tier11_summ_delivered", t.uint48_t),
0x0115: ("current_tier11_summ_received", t.uint48_t),
0x0116: ("current_tier12_summ_delivered", t.uint48_t),
0x0117: ("current_tier12_summ_received", t.uint48_t),
0x0118: ("current_tier13_summ_delivered", t.uint48_t),
0x0119: ("current_tier13_summ_received", t.uint48_t),
0x011A: ("current_tier14_summ_delivered", t.uint48_t),
0x011B: ("current_tier14_summ_received", t.uint48_t),
0x011C: ("current_tier15_summ_delivered", t.uint48_t),
0x011D: ("current_tier15_summ_received", t.uint48_t),
0x0200: ("status", t.bitmap8),
0x0201: ("remaining_batt_life", t.uint8_t),
0x0202: ("hours_in_operation", t.uint24_t),
0x0203: ("hours_in_fault", t.uint24_t),
0x0204: ("extended_status", t.bitmap64),
0x0300: ("unit_of_measure", t.enum8),
0x0301: ("multiplier", t.uint24_t),
0x0302: ("divisor", t.uint24_t),
0x0303: ("summa_formatting", t.bitmap8),
0x0304: ("demand_formatting", t.bitmap8),
0x0305: ("historical_consump_formatting", t.bitmap8),
0x0306: ("metering_device_type", t.bitmap8),
0x0307: ("site_id", t.LimitedCharString(32)),
0x0308: ("meter_serial_number", t.LimitedCharString(24)),
0x0309: ("energy_carrier_unit_of_meas", t.enum8),
0x030A: ("energy_carrier_summ_formatting", t.bitmap8),
0x030B: ("energy_carrier_demand_formatting", t.bitmap8),
cluster_id = 0x0010
ep_attribute = "binary_output"
attributes = {
0x0004: ("active_text", t.CharacterString),
0x001C: ("description", t.CharacterString),
0x002E: ("inactive_text", t.CharacterString),
0x0042: ("minimum_off_time", t.uint32_t),
0x0043: ("minimum_on_time", t.uint32_t),
0x0051: ("out_of_service", t.Bool),
0x0054: ("polarity", t.enum8),
0x0055: ("present_value", t.Bool),
# 0x0057: ('priority_array', TODO.array), # Array of 16 structures of (boolean,
# single precision)
0x0067: ("reliability", t.enum8),
0x0068: ("relinquish_default", t.Bool),
0x006F: ("status_flags", t.bitmap8),
0x0100: ("application_type", t.uint32_t),
}
server_commands = {}
client_commands = {}
class BinaryValue(Cluster):
cluster_id = 0x0011
ep_attribute = "binary_value"
attributes = {
0x0004: ("active_text", t.CharacterString),
0x001C: ("description", t.CharacterString),
0x002E: ("inactive_text", t.CharacterString),
0x0042: ("minimum_off_time", t.uint32_t),
0x0043: ("minimum_on_time", t.uint32_t),
0x0051: ("out_of_service", t.Bool),