Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert (epid in signature) or (
"profile" in epdata and "device_type" in epdata
)
if "profile" in epdata:
profile = epdata["profile"]
assert isinstance(profile, int) and 0 <= profile <= 0xFFFF
if "device_type" in epdata:
device_type = epdata["device_type"]
assert isinstance(device_type, int) and 0 <= device_type <= 0xFFFF
all_clusters = epdata.get("input_clusters", []) + epdata.get(
"output_clusters", []
)
for cluster in all_clusters:
assert (
(isinstance(cluster, int) and cluster in Cluster._registry)
or (isinstance(cluster, int) and _check_range(cluster))
or issubclass(cluster, Cluster)
)
def _check_range(cluster):
for range in Cluster._registry_range.keys():
if range[0] <= cluster <= range[1]:
return True
return False
0x0A14: ("rms_extreme_over_voltage_period_ph_c", t.uint16_t),
0x0A15: ("rms_extreme_under_voltage_period_ph_c", t.uint16_t),
0x0A16: ("rms_voltage_sag_period_ph_c", t.uint16_t),
0x0A17: ("rms_voltage_swell_period_ph__c", t.uint16_t),
}
server_commands = {
0x0000: ("get_profile_info", (), False),
0x0001: ("get_measurement_profile", (), False),
}
client_commands = {
0x0000: ("get_profile_info_response", (), True),
0x0001: ("get_measurement_profile_response", (), True),
}
class Diagnostic(Cluster):
cluster_id = 0x0B05
ep_attribute = "diagnostic"
attributes = {
# Hardware Information
0x0000: ("number_of_resets", t.uint16_t),
0x0001: ("persistent_memory_writes", t.uint16_t),
# Stack/Network Information
0x0100: ("mac_rx_bcast", t.uint32_t),
0x0101: ("mac_tx_bcast", t.uint32_t),
0x0102: ("mac_rx_ucast", t.uint32_t),
0x0103: ("mac_tx_ucast", t.uint32_t),
0x0104: ("mac_tx_ucast_retry", t.uint16_t),
0x0105: ("mac_tx_ucast_fail", t.uint16_t),
0x0106: ("aps_rx_bcast", t.uint16_t),
0x0107: ("aps_tx_bcast", t.uint16_t),
0x0108: ("aps_rx_ucast", t.uint16_t),
attributes = {
0x0000: ("acked_transitions", t.bitmap8),
0x0006: ("alarm_value", t.Bool),
0x0011: ("notification_class", t.uint16_t),
0x0023: ("event_enable", t.bitmap8),
0x0024: ("event_state", t.enum8),
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 BinaryOutputRegular(Cluster):
cluster_id = 0x060A
ep_attribute = "bacnet_regular_binary_output"
attributes = {
0x000F: ("change_of_state_count", t.uint32_t),
0x0010: ("change_of_state_time", DateTime),
0x001F: ("device_type", t.CharacterString),
0x0021: ("elapsed_active_time", t.uint32_t),
0x0028: ("feed_back_value", t.enum8),
0x004B: ("object_id", t.fixed_list(4, t.uint8_t)),
0x004D: ("object_name", t.CharacterString),
0x004F: ("object_type", t.enum16),
0x0072: ("time_of_at_reset", DateTime),
0x0073: ("time_of_sc_reset", DateTime),
0x00A8: ("profile_name", t.CharacterString),
}
server_commands = {}
0x0010: ("change_of_state_time", DateTime),
0x001F: ("device_type", t.CharacterString),
0x0021: ("elapsed_active_time", t.uint32_t),
0x0028: ("feed_back_value", t.enum8),
0x004B: ("object_id", t.fixed_list(4, t.uint8_t)),
0x004D: ("object_name", t.CharacterString),
0x004F: ("object_type", t.enum16),
0x0072: ("time_of_at_reset", DateTime),
0x0073: ("time_of_sc_reset", DateTime),
0x00A8: ("profile_name", t.CharacterString),
}
server_commands = {}
client_commands = {}
class BinaryOutputExtended(Cluster):
cluster_id = 0x060B
ep_attribute = "bacnet_extended_binary_output"
attributes = {
0x0000: ("acked_transitions", t.bitmap8),
0x0011: ("notification_class", t.uint16_t),
0x0023: ("event_enable", t.bitmap8),
0x0024: ("event_state", t.enum8),
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 = {}
"""General Functional Domain"""
import collections
from datetime import datetime
from typing import Tuple
import zigpy.types as t
from zigpy.zcl import Cluster, foundation
class Basic(Cluster):
""" Attributes for determining basic information about a
device, setting user device information such as location,
and enabling a device.
"""
class PowerSource(t.enum8):
"""Power source enum."""
Unknown = 0x00
Mains_single_phase = 0x01
Mains_three_phase = 0x02
Battery = 0x03
DC_Source = 0x04
Emergency_Mains_Always_On = 0x05
Emergency_Mains_Transfer_Switch = 0x06
0x0000: ("restart_device_response", (t.uint8_t,), True),
0x0001: ("save_startup_params_response", (t.uint8_t,), True),
0x0002: ("restore_startup_params_response", (t.uint8_t,), True),
0x0003: ("reset_startup_params_response", (t.uint8_t,), True),
}
class Partition(Cluster):
cluster_id = 0x0016
ep_attribute = "partition"
attributes = {}
server_commands = {}
client_commands = {}
class Ota(Cluster):
cluster_id = 0x0019
ep_attribute = "ota"
attributes = {
0x0000: ("upgrade_server_id", t.EUI64),
0x0001: ("file_offset", t.uint32_t),
0x0002: ("current_file_version", t.uint32_t),
0x0003: ("current_zigbee_stack_version", t.uint16_t),
0x0004: ("downloaded_file_version", t.uint32_t),
0x0005: ("downloaded_zigbee_stack_version", t.uint16_t),
0x0006: ("image_upgrade_status", t.enum8),
0x0007: ("manufacturer_id", t.uint16_t),
0x0008: ("image_type_id", t.uint16_t),
0x0009: ("minimum_block_req_delay", t.uint16_t),
0x000A: ("image_stamp", t.uint32_t),
}
server_commands = {
cluster_id = 0x0400
name = "Illuminance Measurement"
ep_attribute = "illuminance"
attributes = {
# Illuminance Measurement Information
0x0000: ("measured_value", t.uint16_t),
0x0001: ("min_measured_value", t.uint16_t),
0x0002: ("max_measured_value", t.uint16_t),
0x0003: ("tolerance", t.uint16_t),
0x0004: ("light_sensor_type", t.enum8),
}
server_commands = {}
client_commands = {}
class IlluminanceLevelSensing(Cluster):
cluster_id = 0x0401
name = "Illuminance Level Sensing"
ep_attribute = "illuminance_level"
attributes = {
# Illuminance Level Sensing Information
0x0000: ("level_status", t.enum8),
0x0001: ("light_sensor_type", t.enum8),
# Illuminance Level Sensing Settings
0x0010: ("illuminance_target_level", t.uint16_t),
}
server_commands = {}
client_commands = {}
class TemperatureMeasurement(Cluster):
cluster_id = 0x0402
Heat_Stage_2 = 0x01
Heat_Stage_3 = 0x02
Reserved = 0x03
class HeatingSystemType(t.enum8):
Conventional = 0x00
Heat_Pump = 0x01
class HeatingFuelSource(t.enum8):
Electric = 0x00
Gas = 0x01
class Thermostat(Cluster):
"""An interface for configuring and controlling the
functionality of a thermostat."""
class ACCapacityFormat(t.enum8):
BTUh = 0x00
class ACCompressorType(t.enum8):
Reserved = 0x00
T1_max_working_43C = 0x01
T2_max_working_35C = 0x02
T3_max_working_52C = 0x03
class ACType(t.enum8):
Reserved = 0x00
Cooling_fixed_speed = 0x01
Heat_Pump_fixed_speed = 0x02