Beispiel #1
0
class ApplianceEventAlerts(Cluster):
    cluster_id = 0x0B02
    name = "Appliance Event Alerts"
    ep_attribute = "appliance_event"
    attributes: dict[int, ZCLAttributeDef] = {}
    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("get_alerts", {}, False)
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("get_alerts_response", {}, True),
        0x01: ZCLCommandDef("alerts_notification", {}, False),
        0x02: ZCLCommandDef("event_notification", {}, False),
    }
Beispiel #2
0
class GenericTunnel(Cluster):
    cluster_id = 0x0600
    ep_attribute = "generic_tunnel"
    attributes: dict[int, ZCLAttributeDef] = {
        0x0001: ("max_income_trans_size", t.uint16_t),
        0x0002: ("max_outgo_trans_size", t.uint16_t),
        0x0003: ("protocol_addr", t.LVBytes),
    }
    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("match_protocol_addr", {}, False)
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("match_protocol_addr_response", {}, True),
        0x01: ZCLCommandDef("advertise_protocol_address", {}, False),
    }
Beispiel #3
0
class BacnetProtocolTunnel(Cluster):
    cluster_id = 0x0601
    ep_attribute = "bacnet_tunnel"
    attributes: dict[int, ZCLAttributeDef] = {}
    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("transfer_npdu", {"npdu": t.LVBytes}, False)
    }
    client_commands: dict[int, ZCLCommandDef] = {}
Beispiel #4
0
class OsramLightCluster(CustomCluster):
    """OsramLightCluster."""

    cluster_id = 0xFC0F
    ep_attribute = "osram_light"
    name = "OsramLight"
    server_commands = {
        0x0001:
        ZCLCommandDef("save_defaults", {},
                      False,
                      is_manufacturer_specific=True),
    }
Beispiel #5
0
class AnalogInputExtended(Cluster):
    cluster_id = 0x0603
    ep_attribute = "bacnet_extended_analog_input"
    attributes: dict[int, ZCLAttributeDef] = {
        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: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("transfer_apdu", {}, False),
        0x01: ZCLCommandDef("connect_req", {}, False),
        0x02: ZCLCommandDef("disconnect_req", {}, False),
        0x03: ZCLCommandDef("connect_status_noti", {}, False),
    }
    client_commands: dict[int, ZCLCommandDef] = {}
Beispiel #6
0
class WindowCovering(Cluster):
    cluster_id = 0x0102
    name = "Window Covering"
    ep_attribute = "window_covering"
    attributes: dict[int, ZCLAttributeDef] = {
        # Window Covering Information
        0x0000: ("window_covering_type", t.enum8),
        0x0001: ("physical_closed_limit_lift", t.uint16_t),
        0x0002: ("physical_closed_limit_tilt", t.uint16_t),
        0x0003: ("current_position_lift", t.uint16_t),
        0x0004: ("current_position_tilt", t.uint16_t),
        0x0005: ("number_of_actuations_lift", t.uint16_t),
        0x0006: ("number_of_actuations_tilt", t.uint16_t),
        0x0007: ("config_status", t.bitmap8),
        0x0008: ("current_position_lift_percentage", t.uint8_t),
        0x0009: ("current_position_tilt_percentage", t.uint8_t),
        # Window Covering Settings
        0x0010: ("installed_open_limit_lift", t.uint16_t),
        0x0011: ("installed_closed_limit_lift", t.uint16_t),
        0x0012: ("installed_open_limit_tilt", t.uint16_t),
        0x0013: ("installed_closed_limit_tilt", t.uint16_t),
        0x0014: ("velocity_lift", t.uint16_t),
        0x0015: ("acceleration_time_lift", t.uint16_t),
        0x0016: ("deceleration_time_lift", t.uint16_t),
        0x0017: ("window_covering_mode", t.bitmap8),
        0x0018: ("intermediate_setpoints_lift", t.LVBytes),
        0x0019: ("intermediate_setpoints_tilt", t.LVBytes),
    }
    server_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef("up_open", {}, False),
        0x01:
        ZCLCommandDef("down_close", {}, False),
        0x02:
        ZCLCommandDef("stop", {}, False),
        0x04:
        ZCLCommandDef("go_to_lift_value", {"lift_value": t.uint16_t}, False),
        0x05:
        ZCLCommandDef("go_to_lift_percentage",
                      {"percentage_lift_value": t.uint8_t}, False),
        0x07:
        ZCLCommandDef("go_to_tilt_value", {"tilt_value": t.uint16_t}, False),
        0x08:
        ZCLCommandDef("go_to_tilt_percentage",
                      {"percentage_tilt_value": t.uint8_t}, False),
    }
    client_commands: dict[int, ZCLCommandDef] = {}
Beispiel #7
0
class ApplianceStatistics(Cluster):
    cluster_id = 0x0B03
    name = "Appliance Statistics"
    ep_attribute = "appliance_stats"
    attributes: dict[int, ZCLAttributeDef] = {
        0x0000: ("log_max_size", t.uint32_t),
        0x0001: ("log_queue_max_size", t.uint8_t),
    }
    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("log", {}, False),
        0x01: ZCLCommandDef("log_queue", {}, False),
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("log_notification", {}, False),
        0x01: ZCLCommandDef("log_response", {}, True),
        0x02: ZCLCommandDef("log_queue_response", {}, True),
        0x03: ZCLCommandDef("statistics_available", {}, False),
    }
Beispiel #8
0
class ElectricalMeasurement(Cluster):
    cluster_id = 0x0B04
    name = "Electrical Measurement"
    ep_attribute = "electrical_measurement"
    attributes: dict[int, ZCLAttributeDef] = {
        # Basic Information
        0x0000: ("measurement_type", t.bitmap32),
        # DC Measurement
        0x0100: ("dc_voltage", t.int16s),
        0x0101: ("dc_voltage_min", t.int16s),
        0x0102: ("dc_voltage_max", t.int16s),
        0x0103: ("dc_current", t.int16s),
        0x0104: ("dc_current_min", t.int16s),
        0x0105: ("dc_current_max", t.int16s),
        0x0106: ("dc_power", t.int16s),
        0x0107: ("dc_power_min", t.int16s),
        0x0108: ("dc_power_max", t.int16s),
        # DC Formatting
        0x0200: ("dc_voltage_multiplier", t.uint16_t),
        0x0201: ("dc_voltage_divisor", t.uint16_t),
        0x0202: ("dc_current_multiplier", t.uint16_t),
        0x0203: ("dc_current_divisor", t.uint16_t),
        0x0204: ("dc_power_multiplier", t.uint16_t),
        0x0205: ("dc_power_divisor", t.uint16_t),
        # AC (Non-phase Specific) Measurements
        0x0300: ("ac_frequency", t.uint16_t),
        0x0301: ("ac_frequency_min", t.uint16_t),
        0x0302: ("ac_frequency_max", t.uint16_t),
        0x0303: ("neutral_current", t.uint16_t),
        0x0304: ("total_active_power", t.int32s),
        0x0305: ("total_reactive_power", t.int32s),
        0x0306: ("total_apparent_power", t.uint32_t),
        0x0307: ("meas1st_harmonic_current", t.int16s),
        0x0308: ("meas3rd_harmonic_current", t.int16s),
        0x0309: ("meas5th_harmonic_current", t.int16s),
        0x030A: ("meas7th_harmonic_current", t.int16s),
        0x030B: ("meas9th_harmonic_current", t.int16s),
        0x030C: ("meas11th_harmonic_current", t.int16s),
        0x030D: ("meas_phase1st_harmonic_current", t.int16s),
        0x030E: ("meas_phase3rd_harmonic_current", t.int16s),
        0x030F: ("meas_phase5th_harmonic_current", t.int16s),
        0x0310: ("meas_phase7th_harmonic_current", t.int16s),
        0x0311: ("meas_phase9th_harmonic_current", t.int16s),
        0x0312: ("meas_phase11th_harmonic_current", t.int16s),
        # AC (Non-phase specific) Formatting
        0x0400: ("ac_frequency_multiplier", t.uint16_t),
        0x0401: ("ac_frequency_divisor", t.uint16_t),
        0x0402: ("power_multiplier", t.uint32_t),
        0x0403: ("power_divisor", t.uint32_t),
        0x0404: ("harmonic_current_multiplier", t.int8s),
        0x0405: ("phase_harmonic_current_multiplier", t.int8s),
        # AC (Single Phase or Phase A) Measurements
        0x0500: ("instantaneous_voltage", t.int16s),
        0x0501: ("instantaneous_line_current", t.uint16_t),
        0x0502: ("instantaneous_active_current", t.int16s),
        0x0503: ("instantaneous_reactive_current", t.int16s),
        0x0504: ("instantaneous_power", t.int16s),
        0x0505: ("rms_voltage", t.uint16_t),
        0x0506: ("rms_voltage_min", t.uint16_t),
        0x0507: ("rms_voltage_max", t.uint16_t),
        0x0508: ("rms_current", t.uint16_t),
        0x0509: ("rms_current_min", t.uint16_t),
        0x050A: ("rms_current_max", t.uint16_t),
        0x050B: ("active_power", t.int16s),
        0x050C: ("active_power_min", t.int16s),
        0x050D: ("active_power_max", t.int16s),
        0x050E: ("reactive_power", t.int16s),
        0x050F: ("apparent_power", t.uint16_t),
        0x0510: ("power_factor", t.int8s),
        0x0511: ("average_rms_voltage_meas_period", t.uint16_t),
        0x0512: ("average_rms_over_voltage_counter", t.uint16_t),
        0x0513: ("average_rms_under_voltage_counter", t.uint16_t),
        0x0514: ("rms_extreme_over_voltage_period", t.uint16_t),
        0x0515: ("rms_extreme_under_voltage_period", t.uint16_t),
        0x0516: ("rms_voltage_sag_period", t.uint16_t),
        0x0517: ("rms_voltage_swell_period", t.uint16_t),
        # AC Formatting
        0x0600: ("ac_voltage_multiplier", t.uint16_t),
        0x0601: ("ac_voltage_divisor", t.uint16_t),
        0x0602: ("ac_current_multiplier", t.uint16_t),
        0x0603: ("ac_current_divisor", t.uint16_t),
        0x0604: ("ac_power_multiplier", t.uint16_t),
        0x0605: ("ac_power_divisor", t.uint16_t),
        # DC Manufacturer Threshold Alarms
        0x0700: ("dc_overload_alarms_mask", t.bitmap8),
        0x0701: ("dc_voltage_overload", t.int16s),
        0x0702: ("dc_current_overload", t.int16s),
        # AC Manufacturer Threshold Alarms
        0x0800: ("ac_alarms_mask", t.bitmap16),
        0x0801: ("ac_voltage_overload", t.int16s),
        0x0802: ("ac_current_overload", t.int16s),
        0x0803: ("ac_active_power_overload", t.int16s),
        0x0804: ("ac_reactive_power_overload", t.int16s),
        0x0805: ("average_rms_over_voltage", t.int16s),
        0x0806: ("average_rms_under_voltage", t.int16s),
        0x0807: ("rms_extreme_over_voltage", t.int16s),
        0x0808: ("rms_extreme_under_voltage", t.int16s),
        0x0809: ("rms_voltage_sag", t.int16s),
        0x080A: ("rms_voltage_swell", t.int16s),
        # AC Phase B Measurements
        0x0901: ("line_current_ph_b", t.uint16_t),
        0x0902: ("active_current_ph_b", t.int16s),
        0x0903: ("reactive_current_ph_b", t.int16s),
        0x0905: ("rms_voltage_ph_b", t.uint16_t),
        0x0906: ("rms_voltage_min_ph_b", t.uint16_t),
        0x0907: ("rms_voltage_max_ph_b", t.uint16_t),
        0x0908: ("rms_current_ph_b", t.uint16_t),
        0x0909: ("rms_current_min_ph_b", t.uint16_t),
        0x090A: ("rms_current_max_ph_b", t.uint16_t),
        0x090B: ("active_power_ph_b", t.int16s),
        0x090C: ("active_power_min_ph_b", t.int16s),
        0x090D: ("active_power_max_ph_b", t.int16s),
        0x090E: ("reactive_power_ph_b", t.int16s),
        0x090F: ("apparent_power_ph_b", t.uint16_t),
        0x0910: ("power_factor_ph_b", t.int8s),
        0x0911: ("average_rms_voltage_measure_period_ph_b", t.uint16_t),
        0x0912: ("average_rms_over_voltage_counter_ph_b", t.uint16_t),
        0x0913: ("average_under_voltage_counter_ph_b", t.uint16_t),
        0x0914: ("rms_extreme_over_voltage_period_ph_b", t.uint16_t),
        0x0915: ("rms_extreme_under_voltage_period_ph_b", t.uint16_t),
        0x0916: ("rms_voltage_sag_period_ph_b", t.uint16_t),
        0x0917: ("rms_voltage_swell_period_ph_b", t.uint16_t),
        # AC Phase C Measurements
        0x0A01: ("line_current_ph_c", t.uint16_t),
        0x0A02: ("active_current_ph_c", t.int16s),
        0x0A03: ("reactive_current_ph_c", t.int16s),
        0x0A05: ("rms_voltage_ph_c", t.uint16_t),
        0x0A06: ("rms_voltage_min_ph_c", t.uint16_t),
        0x0A07: ("rms_voltage_max_ph_c", t.uint16_t),
        0x0A08: ("rms_current_ph_c", t.uint16_t),
        0x0A09: ("rms_current_min_ph_c", t.uint16_t),
        0x0A0A: ("rms_current_max_ph_c", t.uint16_t),
        0x0A0B: ("active_power_ph_c", t.int16s),
        0x0A0C: ("active_power_min_ph_c", t.int16s),
        0x0A0D: ("active_power_max_ph_c", t.int16s),
        0x0A0E: ("reactive_power_ph_c", t.int16s),
        0x0A0F: ("apparent_power_ph_c", t.uint16_t),
        0x0A10: ("power_factor_ph_c", t.int8s),
        0x0A11: ("average_rms_voltage_meas_period_ph_c", t.uint16_t),
        0x0A12: ("average_rms_over_voltage_counter_ph_c", t.uint16_t),
        0x0A13: ("average_under_voltage_counter_ph_c", t.uint16_t),
        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: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("get_profile_info", {}, False),
        0x01: ZCLCommandDef("get_measurement_profile", {}, False),
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("get_profile_info_response", {}, True),
        0x01: ZCLCommandDef("get_measurement_profile_response", {}, True),
    }
Beispiel #9
0
class Metering(Cluster):
    cluster_id = 0x0702
    ep_attribute = "smartenergy_metering"
    attributes: dict[int, ZCLAttributeDef] = {
        0x0000: ("current_summ_delivered", t.uint48_t),
        0x0001: ("current_summ_received", t.uint48_t),
        0x0002: ("current_max_demand_delivered", t.uint48_t),
        0x0003: ("current_max_demand_received", t.uint48_t),
        0x0004: ("dft_summ", t.uint48_t),
        0x0005: ("daily_freeze_time", t.uint16_t),
        0x0006: ("power_factor", t.int8s),
        0x0007: ("reading_snapshot_time", t.UTCTime),
        0x0008: ("current_max_demand_delivered_time", t.UTCTime),
        0x0009: ("current_max_demand_received_time", t.UTCTime),
        0x000A: ("default_update_period", t.uint8_t),
        0x000B: ("fast_poll_update_period", t.uint8_t),
        0x000C: ("current_block_period_consump_delivered", t.uint48_t),
        0x000D: ("daily_consump_target", t.uint24_t),
        0x000E: ("current_block", t.enum8),
        0x000F: ("profile_interval_period", t.enum8),
        # 0x0010: ('interval_read_reporting_period', UNKNOWN),  # Deprecated
        0x0011: ("preset_reading_time", t.uint16_t),
        0x0012: ("volume_per_report", t.uint16_t),
        0x0013: ("flow_restriction", t.uint8_t),
        0x0014: ("supply_status", t.enum8),
        0x0015: ("current_in_energy_carrier_summ", t.uint48_t),
        0x0016: ("current_out_energy_carrier_summ", t.uint48_t),
        0x0017: ("inlet_temperature", t.int24s),
        0x0018: ("outlet_temperature", t.int24s),
        0x0019: ("control_temperature", t.int24s),
        0x001A: ("current_in_energy_carrier_demand", t.int24s),
        0x001B: ("current_out_energy_carrier_demand", t.int24s),
        0x001D: ("current_block_period_consump_received", t.uint48_t),
        0x001E: ("current_block_received", t.uint48_t),
        0x001F: ("dft_summation_received", t.uint48_t),
        0x0020: ("active_register_tier_delivered", t.enum8),
        0x0021: ("active_register_tier_received", t.enum8),
        0x0022: ("last_block_switch_time", t.UTCTime),
        # 0x0100: ('change_reporting_profile', UNKNOWN),
        0x0100: ("current_tier1_summ_delivered", t.uint48_t),
        0x0101: ("current_tier1_summ_received", t.uint48_t),
        0x0102: ("current_tier2_summ_delivered", t.uint48_t),
        0x0103: ("current_tier2_summ_received", t.uint48_t),
        0x0104: ("current_tier3_summ_delivered", t.uint48_t),
        0x0105: ("current_tier3_summ_received", t.uint48_t),
        0x0106: ("current_tier4_summ_delivered", t.uint48_t),
        0x0107: ("current_tier4_summ_received", t.uint48_t),
        0x0108: ("current_tier5_summ_delivered", t.uint48_t),
        0x0109: ("current_tier5_summ_received", t.uint48_t),
        0x010A: ("current_tier6_summ_delivered", t.uint48_t),
        0x010B: ("current_tier6_summ_received", t.uint48_t),
        0x010C: ("current_tier7_summ_delivered", t.uint48_t),
        0x010D: ("current_tier7_summ_received", t.uint48_t),
        0x010E: ("current_tier8_summ_delivered", t.uint48_t),
        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_battery_life", t.uint8_t),
        0x0202: ("hours_in_operation", t.uint24_t),
        0x0203: ("hours_in_fault", t.uint24_t),
        0x0204: ("extended_status", t.bitmap64),
        0x0205: ("remaining_battery_life_days", t.uint16_t),
        0x0206: ("current_meter_id", t.LVBytes),
        0x0207: ("iambient_consumption_indicator", t.enum8),
        0x0300: ("unit_of_measure", t.enum8),
        0x0301: ("multiplier", t.uint24_t),
        0x0302: ("divisor", t.uint24_t),
        0x0303: ("summation_formatting", t.bitmap8),
        0x0304: ("demand_formatting", t.bitmap8),
        0x0305: ("historical_consump_formatting", t.bitmap8),
        0x0306: ("metering_device_type", t.bitmap8),
        0x0307: ("site_id", t.LimitedLVBytes(32)),
        0x0308: ("meter_serial_number", t.LimitedLVBytes(24)),
        0x0309: ("energy_carrier_unit_of_meas", t.enum8),
        0x030A: ("energy_carrier_summ_formatting", t.bitmap8),
        0x030B: ("energy_carrier_demand_formatting", t.bitmap8),
        0x030C: ("temperature_unit_of_measure", t.enum8),
        0x030D: ("temperature_formatting", t.bitmap8),
        0x030E: ("module_serial_number", t.LimitedLVBytes(24)),
        0x030F: ("operating_tariff_label_delivered", t.LimitedLVBytes(24)),
        0x0310: ("operating_tariff_label_received", t.LimitedLVBytes(24)),
        0x0311: ("customer_id_number", t.LimitedLVBytes(24)),
        0x0312: ("alternative_unit_of_measure", t.enum8),
        0x0313: ("alternative_demand_formatting", t.bitmap8),
        0x0314: ("alternative_consumption_formatting", t.bitmap8),
        0x0400: ("instantaneous_demand", t.int24s),
        0x0401: ("currentday_consump_delivered", t.uint24_t),
        0x0402: ("currentday_consump_received", t.uint24_t),
        0x0403: ("previousday_consump_delivered", t.uint24_t),
        0x0404: ("previousday_consump_received", t.uint24_t),
        0x0405: ("cur_part_profile_int_start_time_delivered", t.uint32_t),
        0x0406: ("cur_part_profile_int_start_time_received", t.uint32_t),
        0x0407: ("cur_part_profile_int_value_delivered", t.uint24_t),
        0x0408: ("cur_part_profile_int_value_received", t.uint24_t),
        0x0409: ("current_day_max_pressure", t.uint48_t),
        0x040A: ("current_day_min_pressure", t.uint48_t),
        0x040B: ("previous_day_max_pressure", t.uint48_t),
        0x040C: ("previous_day_min_pressure", t.uint48_t),
        0x040D: ("current_day_max_demand", t.int24s),
        0x040E: ("previous_day_max_demand", t.int24s),
        0x040F: ("current_month_max_demand", t.int24s),
        0x0410: ("current_year_max_demand", t.int24s),
        0x0411: ("currentday_max_energy_carr_demand", t.int24s),
        0x0412: ("previousday_max_energy_carr_demand", t.int24s),
        0x0413: ("cur_month_max_energy_carr_demand", t.int24s),
        0x0414: ("cur_month_min_energy_carr_demand", t.int24s),
        0x0415: ("cur_year_max_energy_carr_demand", t.int24s),
        0x0416: ("cur_year_min_energy_carr_demand", t.int24s),
        0x0500: ("max_number_of_periods_delivered", t.uint8_t),
        0x0600: ("current_demand_delivered", t.uint24_t),
        0x0601: ("demand_limit", t.uint24_t),
        0x0602: ("demand_integration_period", t.uint8_t),
        0x0603: ("number_of_demand_subintervals", t.uint8_t),
        0x0604: ("demand_limit_arm_duration", t.uint16_t),
        0x0800: ("generic_alarm_mask", t.bitmap16),
        0x0801: ("electricity_alarm_mask", t.bitmap32),
        0x0802: ("gen_flow_pressure_alarm_mask", t.bitmap16),
        0x0803: ("water_specific_alarm_mask", t.bitmap16),
        0x0804: ("heat_cool_specific_alarm_mask", t.bitmap16),
        0x0805: ("gas_specific_alarm_mask", t.bitmap16),
        0x0806: ("extended_generic_alarm_mask", t.bitmap48),
        0x0807: ("manufacture_alarm_mask", t.bitmap16),
        0x0A00: ("bill_to_date", t.uint32_t),
        0x0A01: ("bill_to_date_time_stamp", t.uint32_t),
        0x0A02: ("projected_bill", t.uint32_t),
        0x0A03: ("projected_bill_time_stamp", t.uint32_t),
    }
    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("get_profile", {}, False),
        0x01: ZCLCommandDef("req_mirror", {}, False),
        0x02: ZCLCommandDef("mirror_rem", {}, False),
        0x03: ZCLCommandDef("req_fast_poll_mode", {}, False),
        0x04: ZCLCommandDef("get_snapshot", {}, False),
        0x05: ZCLCommandDef("take_snapshot", {}, False),
        0x06: ZCLCommandDef("mirror_report_attr_response", {}, True),
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef("get_profile_response", {}, True),
        0x01: ZCLCommandDef("req_mirror_response", {}, True),
        0x02: ZCLCommandDef("mirror_rem_response", {}, True),
        0x03: ZCLCommandDef("req_fast_poll_mode_response", {}, True),
        0x04: ZCLCommandDef("get_snapshot_response", {}, True),
    }
Beispiel #10
0
class IasWd(Cluster):
    """The IAS WD cluster provides an interface to the functionality of any Warning
    Device equipment of the IAS system. Using this cluster, a ZigBee enabled CIE device
    can access a ZigBee enabled IAS WD device and issue alarm warning indications
    (siren, strobe lighting, etc.) when a system alarm condition is detected
    """
    class StrobeLevel(t.enum8):
        Low_level_strobe = 0x00
        Medium_level_strobe = 0x01
        High_level_strobe = 0x02
        Very_high_level_strobe = 0x03

    class Warning(_SquawkOrWarningCommand):
        Strobe = Strobe

        class SirenLevel(t.enum8):
            Low_level_sound = 0x00
            Medium_level_sound = 0x01
            High_level_sound = 0x02
            Very_high_level_sound = 0x03

        class WarningMode(t.enum8):
            Stop = 0x00
            Burglar = 0x01
            Fire = 0x02
            Emergency = 0x03
            Police_Panic = 0x04
            Fire_Panic = 0x05
            Emergency_Panic = 0x06

        @property
        def mode(self) -> WarningMode:
            return self.WarningMode((self.value >> 4) & 0x0F)

        @mode.setter
        def mode(self, mode: WarningMode) -> None:
            self.value = (self.value & 0xF) | (mode << 4)

        @property
        def strobe(self) -> Strobe:
            return self.Strobe((self.value >> 2) & 0x01)

        @strobe.setter
        def strobe(self, strobe: Strobe) -> None:
            self.value = (self.value & 0xF7) | (
                (strobe & 0x01) << 2  # type:ignore[operator]
            )

        @property
        def level(self) -> SirenLevel:
            return self.SirenLevel(self.value & 0x03)

        @level.setter
        def level(self, level: SirenLevel) -> None:
            self.value = (self.value & 0xFC) | (level & 0x03)

    class Squawk(_SquawkOrWarningCommand):
        Strobe = Strobe

        class SquawkLevel(t.enum8):
            Low_level_sound = 0x00
            Medium_level_sound = 0x01
            High_level_sound = 0x02
            Very_high_level_sound = 0x03

        class SquawkMode(t.enum8):
            Armed = 0x00
            Disarmed = 0x01

        @property
        def mode(self) -> SquawkMode:
            return self.SquawkMode((self.value >> 4) & 0x0F)

        @mode.setter
        def mode(self, mode: SquawkMode) -> None:
            self.value = (self.value & 0xF) | ((mode & 0x0F) << 4)

        @property
        def strobe(self) -> Strobe:
            return self.Strobe((self.value >> 3) & 0x01)

        @strobe.setter
        def strobe(self, strobe: Strobe) -> None:
            self.value = (self.value & 0xF7) | (strobe << 3
                                                )  # type:ignore[operator]

        @property
        def level(self) -> SquawkLevel:
            return self.SquawkLevel(self.value & 0x03)

        @level.setter
        def level(self, level: SquawkLevel) -> None:
            self.value = (self.value & 0xFC) | (level & 0x03)

    cluster_id = 0x0502
    name = "IAS Warning Device"
    ep_attribute = "ias_wd"
    attributes: dict[int, ZCLAttributeDef] = {
        0x0000: ("max_duration", t.uint16_t)
    }
    server_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef(
            "start_warning",
            {
                "warning": Warning,
                "warning_duration": t.uint16_t,
                "strobe_duty_cycle": t.uint8_t,
                "stobe_level": StrobeLevel,
            },
            False,
        ),
        0x01:
        ZCLCommandDef("squawk", {"squawk": Squawk}, False),
    }
    client_commands: dict[int, ZCLCommandDef] = {}
Beispiel #11
0
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
        Emergency_Panic = 0x06

    class ArmMode(t.enum8):
        """IAS ACE arm mode enum."""

        Disarm = 0x00
        Arm_Day_Home_Only = 0x01
        Arm_Night_Sleep_Only = 0x02
        Arm_All_Zones = 0x03

    class ArmNotification(t.enum8):
        """IAS ACE arm notification enum."""

        All_Zones_Disarmed = 0x00
        Only_Day_Home_Zones_Armed = 0x01
        Only_Night_Sleep_Zones_Armed = 0x02
        All_Zones_Armed = 0x03
        Invalid_Arm_Disarm_Code = 0x04
        Not_Ready_To_Arm = 0x05
        Already_Disarmed = 0x06

    class AudibleNotification(
            t.enum_factory(t.uint8_t, "manufacturer_specific")):
        """IAS ACE audible notification enum."""

        Mute = 0x00
        Default_Sound = 0x01

    class BypassResponse(t.enum8):
        """Bypass result."""

        Zone_bypassed = 0x00
        Zone_not_bypassed = 0x01
        Not_allowed = 0x02
        Invalid_Zone_ID = 0x03
        Unknown_Zone_ID = 0x04
        Invalid_Code = 0x05

    class PanelStatus(t.enum8):
        """IAS ACE panel status enum."""

        Panel_Disarmed = 0x00
        Armed_Stay = 0x01
        Armed_Night = 0x02
        Armed_Away = 0x03
        Exit_Delay = 0x04
        Entry_Delay = 0x05
        Not_Ready_To_Arm = 0x06
        In_Alarm = 0x07
        Arming_Stay = 0x08
        Arming_Night = 0x09
        Arming_Away = 0x0A

    ZoneType = IasZone.ZoneType
    ZoneStatus = IasZone.ZoneStatus

    class ZoneStatusRsp(t.Struct):
        """Zone status response."""

        zone_id: t.uint8_t
        zone_status: IasZone.ZoneStatus

    cluster_id = 0x0501
    name = "IAS Ancillary Control Equipment"
    ep_attribute = "ias_ace"
    attributes: dict[int, ZCLAttributeDef] = {}
    server_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef(
            "arm",
            {
                "arm_mode": ArmMode,
                "arm_disarm_code": t.CharacterString,
                "zone_id": t.uint8_t,
            },
            False,
        ),
        0x01:
        ZCLCommandDef(
            "bypass",
            {
                "zones_ids": t.LVList[t.uint8_t],
                "arm_disarm_code": t.CharacterString
            },
            False,
        ),
        0x02:
        ZCLCommandDef("emergency", {}, False),
        0x03:
        ZCLCommandDef("fire", {}, False),
        0x04:
        ZCLCommandDef("panic", {}, False),
        0x05:
        ZCLCommandDef("get_zone_id_map", {}, False),
        0x06:
        ZCLCommandDef("get_zone_info", {"zone_id": t.uint8_t}, False),
        0x07:
        ZCLCommandDef("get_panel_status", {}, False),
        0x08:
        ZCLCommandDef("get_bypassed_zone_list", {}, False),
        0x09:
        ZCLCommandDef(
            "get_zone_status",
            {
                "starting_zone_id": t.uint8_t,
                "max_num_zone_ids": t.uint8_t,
                "zone_status_mask_flag": t.Bool,
                "zone_status_mask": ZoneStatus,
            },
            False,
        ),
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef("arm_response", {"arm_notification": ArmNotification},
                      True),
        0x01:
        ZCLCommandDef(
            "get_zone_id_map_response",
            {"zone_id_map_sections": t.List[t.bitmap16]},
            True,
        ),
        0x02:
        ZCLCommandDef(
            "get_zone_info_response",
            {
                "zone_id": t.uint8_t,
                "zone_type": ZoneType,
                "ieee": t.EUI64,
                "zone_label": t.CharacterString,
            },
            True,
        ),
        0x03:
        ZCLCommandDef(
            "zone_status_changed",
            {
                "zone_id": t.uint8_t,
                "zone_status": ZoneStatus,
                "audible_notification": AudibleNotification,
                "zone_label": t.CharacterString,
            },
            False,
        ),
        0x04:
        ZCLCommandDef(
            "panel_status_changed",
            {
                "panel_status": PanelStatus,
                "seconds_remaining": t.uint8_t,
                "audible_notification": AudibleNotification,
                "alarm_status": AlarmStatus,
            },
            False,
        ),
        0x05:
        ZCLCommandDef(
            "panel_status_response",
            {
                "panel_status": PanelStatus,
                "seconds_remaining": t.uint8_t,
                "audible_notification": AudibleNotification,
                "alarm_status": AlarmStatus,
            },
            True,
        ),
        0x06:
        ZCLCommandDef("set_bypassed_zone_list",
                      {"zone_ids": t.LVList[t.uint8_t]}, False),
        0x07:
        ZCLCommandDef("bypass_response",
                      {"bypass_results": t.LVList[BypassResponse]}, True),
        0x08:
        ZCLCommandDef(
            "get_zone_status_response",
            {
                "zone_status_complete": t.Bool,
                "zone_statuses": t.LVList[ZoneStatusRsp]
            },
            True,
        ),
    }
Beispiel #12
0
class IasZone(Cluster):
    """The IAS Zone cluster defines an interface to the functionality of an IAS
    security zone device. IAS Zone supports up to two alarm types per zone, low battery
    reports and supervision of the IAS network."""
    class ZoneState(t.enum8):
        Not_enrolled = 0x00
        Enrolled = 0x01

    class ZoneType(t.enum_factory(t.uint16_t, "manufacturer_specific")):
        """Zone type enum."""

        Standard_CIE = 0x0000
        Motion_Sensor = 0x000D
        Contact_Switch = 0x0015
        Fire_Sensor = 0x0028
        Water_Sensor = 0x002A
        Carbon_Monoxide_Sensor = 0x002B
        Personal_Emergency_Device = 0x002C
        Vibration_Movement_Sensor = 0x002D
        Remote_Control = 0x010F
        Key_Fob = 0x0115
        Key_Pad = 0x021D
        Standard_Warning_Device = 0x0225
        Glass_Break_Sensor = 0x0226
        Security_Repeater = 0x0229
        Invalid_Zone_Type = 0xFFFF

    class ZoneStatus(t.bitmap16):
        """ZoneStatus attribute."""

        Alarm_1 = 0x0001
        Alarm_2 = 0x0002
        Tamper = 0x0004
        Battery = 0x0008
        Supervision_reports = 0x0010
        Restore_reports = 0x0020
        Trouble = 0x0040
        AC_mains = 0x0080
        Test = 0x0100
        Battery_Defect = 0x0200

    class EnrollResponse(t.enum8):
        """Enroll response code."""

        Success = 0x00
        Not_supported = 0x01
        No_enroll_permit = 0x02
        Too_many_zones = 0x03

    cluster_id = 0x0500
    name = "IAS Zone"
    ep_attribute = "ias_zone"
    attributes: dict[int, ZCLAttributeDef] = {
        # Zone Information
        0x0000: ("zone_state", ZoneState),
        0x0001: ("zone_type", ZoneType),
        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: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef(
            "enroll_response",
            {
                "enroll_response_code": EnrollResponse,
                "zone_id": t.uint8_t
            },
            True,
        ),
        0x01:
        ZCLCommandDef("init_normal_op_mode", {}, False),
        0x02:
        ZCLCommandDef(
            "init_test_mode",
            {
                "test_mode_duration": t.uint8_t,
                "current_zone_sensitivity_level": t.uint8_t,
            },
            False,
        ),
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef(
            "status_change_notification",
            {
                "zone_status": ZoneStatus,
                "extended_status": t.bitmap8,
                "zone_id": t.uint8_t,
                "delay": t.uint16_t,
            },
            False,
        ),
        0x01:
        ZCLCommandDef("enroll", {
            "zone_type": ZoneType,
            "manufacturer_code": t.uint16_t
        }, False),
    }

    def handle_cluster_request(
        self,
        hdr: zigpy.zcl.foundation.ZCLHeader,
        args: list[Any],
        *,
        dst_addressing: t.Addressing.Group
        | t.Addressing.IEEE
        | t.Addressing.NWK
        | None = None,
    ):
        if (hdr.command_id == 0 and self.is_server
                and not hdr.frame_control.disable_default_response):
            hdr.frame_control.is_reply = False  # this is a client -> server cmd
            self.send_default_rsp(hdr, zigpy.zcl.foundation.Status.SUCCESS)
Beispiel #13
0
class LightLink(Cluster):
    cluster_id = 0x1000
    ep_attribute = "lightlink"
    attributes: dict[int, ZCLAttributeDef] = {}
    server_commands: dict[int, ZCLCommandDef] = {
        # Touchlink
        0x00:
        ZCLCommandDef(
            "scan",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "zigbee_information": ZigbeeInformation,
                "touchlink_information": ScanRequestInformation,
            },
            False,
        ),
        0x02:
        ZCLCommandDef(
            "device_info",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "start_index": t.uint8_t
            },
            False,
        ),
        0x06:
        ZCLCommandDef(
            "identify",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "identify_duration": t.uint16_t
            },
            False,
        ),
        0x07:
        ZCLCommandDef(
            "reset_to_factory_new",
            {"inter_pan_transaction_id": t.uint32_t},
            False,
        ),
        0x10:
        ZCLCommandDef(
            "network_start",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "epid": t.EUI64,
                "key_index": t.uint8_t,
                "encrypted_network_key": t.KeyData,
                "logical_channel": t.uint8_t,
                "pan_id": t.PanId,
                "nwk_addr": t.NWK,
                "group_identifiers_begin": t.Group,
                "group_identifiers_end": t.Group,
                "free_network_addr_range_begin": t.NWK,
                "free_network_addr_range_end": t.NWK,
                "free_group_id_range_begin": t.Group,
                "free_group_id_range_end": t.Group,
                "initiator_ieee": t.EUI64,
                "initiator_nwk": t.NWK,
            },
            False,
        ),
        0x12:
        ZCLCommandDef(
            "network_join_router",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "epid": t.EUI64,
                "key_index": t.uint8_t,
                "encrypted_network_key": t.KeyData,
                "nwk_update_id": t.uint8_t,
                "logical_channel": t.uint8_t,
                "pan_id": t.PanId,
                "nwk_addr": t.NWK,
                "group_identifiers_begin": t.Group,
                "group_identifiers_end": t.Group,
                "free_network_addr_range_begin": t.NWK,
                "free_network_addr_range_end": t.NWK,
                "free_group_id_range_begin": t.Group,
                "free_group_id_range_end": t.Group,
            },
            False,
        ),
        0x14:
        ZCLCommandDef(
            "network_join_end_device",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "epid": t.EUI64,
                "key_index": t.uint8_t,
                "encrypted_network_key": t.KeyData,
                "nwk_update_id": t.uint8_t,
                "logical_channel": t.uint8_t,
                "pan_id": t.PanId,
                "nwk_addr": t.NWK,
                "group_identifiers_begin": t.Group,
                "group_identifiers_end": t.Group,
                "free_network_addr_range_begin": t.NWK,
                "free_network_addr_range_end": t.NWK,
                "free_group_id_range_begin": t.Group,
                "free_group_id_range_end": t.Group,
            },
            False,
        ),
        0x16:
        ZCLCommandDef(
            "network_update",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "epid": t.EUI64,
                "nwk_update_id": t.uint8_t,
                "logical_channel": t.uint8_t,
                "pan_id": t.PanId,
                "nwk_addr": t.NWK,
            },
            False,
        ),
        # Utility
        0x41:
        ZCLCommandDef(
            "get_group_identifiers",
            {
                "start_index": t.uint8_t,
            },
            False,
        ),
        0x42:
        ZCLCommandDef(
            "get_endpoint_list",
            {
                "start_index": t.uint8_t,
            },
            False,
        ),
    }
    client_commands: dict[int, ZCLCommandDef] = {
        # Touchlink
        0x01:
        ZCLCommandDef(
            "scan_rsp",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "rssi_correction": t.uint8_t,
                "zigbee_info": ZigbeeInformation,
                "touchlink_info": ScanResponseInformation,
                "key_bitmask": t.uint16_t,
                "response_id": t.uint32_t,
                "epid": t.EUI64,
                "nwk_update_id": t.uint8_t,
                "logical_channel": t.uint8_t,
                "pan_id": t.PanId,
                "nwk_addr": t.NWK,
                "num_sub_devices": t.uint8_t,
                "total_group_ids": t.uint8_t,
                "endpoint_id?": t.uint8_t,
                "profile_id?": t.uint16_t,
                "device_id?": t.uint16_t,
                "version?": t.uint8_t,
                "group_id_count?": t.uint8_t,
            },
            True,
        ),
        0x03:
        ZCLCommandDef(
            "device_info_rsp",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "num_sub_devices": t.uint8_t,
                "start_index": t.uint8_t,
                "device_info_records": t.LVList[DeviceInfoRecord],
            },
            True,
        ),
        0x11:
        ZCLCommandDef(
            "network_start_rsp",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "status": Status,
                "epid": t.EUI64,
                "nwk_update_id": t.uint8_t,
                "logical_channel": t.uint8_t,
                "pan_id": t.PanId,
            },
            True,
        ),
        0x13:
        ZCLCommandDef(
            "network_join_router_rsp",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "status": Status,
            },
            True,
        ),
        0x15:
        ZCLCommandDef(
            "network_join_end_device_rsp",
            {
                "inter_pan_transaction_id": t.uint32_t,
                "status": Status,
            },
            True,
        ),
        # Utility
        0x40:
        ZCLCommandDef(
            "endpoint_info",
            {
                "ieee_addr": t.EUI64,
                "nwk_addr": t.NWK,
                "endpoint_id": t.uint8_t,
                "profile_id": t.uint16_t,
                "device_id": t.uint16_t,
                "version": t.uint8_t,
            },
            True,
        ),
        0x41:
        ZCLCommandDef(
            "get_group_identifiers_rsp",
            {
                "total": t.uint8_t,
                "start_index": t.uint8_t,
                "group_info_records": t.LVList[GroupInfoRecord],
            },
            True,
        ),
        0x42:
        ZCLCommandDef(
            "get_endpoint_list_rsp",
            {
                "total": t.uint8_t,
                "start_index": t.uint8_t,
                "endpoint_info_records": t.LVList[EndpointInfoRecord],
            },
            True,
        ),
    }
Beispiel #14
0
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
        Cooling_Inverter = 0x03
        Heat_Pump_Inverter = 0x04

    class ACRefrigerantType(t.enum8):
        Reserved = 0x00
        R22 = 0x01
        R410a = 0x02
        R407c = 0x03

    class ACErrorCode(t.bitmap32):
        No_Errors = 0x00000000
        Commpressor_Failure = 0x00000001
        Room_Temperature_Sensor_Failure = 0x00000002
        Outdoor_Temperature_Sensor_Failure = 0x00000004
        Indoor_Coil_Temperature_Sensor_Failure = 0x00000008
        Fan_Failure = 0x00000010

    class ACLouverPosition(t.enum8):
        Closed = 0x01
        Open = 0x02
        Qurter_Open = 0x03
        Half_Open = 0x04
        Three_Quarters_Open = 0x05

    class AlarmMask(t.bitmap8):
        No_Alarms = 0x00
        Initialization_failure = 0x01
        Hardware_failure = 0x02
        Self_calibration_failure = 0x04

    class ControlSequenceOfOperation(t.enum8):
        Cooling_Only = 0x00
        Cooling_With_Reheat = 0x01
        Heating_Only = 0x02
        Heating_With_Reheat = 0x03
        Cooling_and_Heating = 0x04
        Cooling_and_Heating_with_Reheat = 0x05

    class SeqDayOfWeek(t.bitmap8):
        Sunday = 0x01
        Monday = 0x02
        Tuesday = 0x04
        Wednesday = 0x08
        Thursday = 0x10
        Friday = 0x20
        Saturday = 0x40
        Away = 0x80

    class SeqMode(t.bitmap8):
        Heat = 0x01
        Cool = 0x02

    class Occupancy(t.bitmap8):
        Unoccupied = 0x00
        Occupied = 0x01

    class ProgrammingOperationMode(t.bitmap8):
        Simple = 0x00
        Schedule_programming_mode = 0x01
        Auto_recovery_mode = 0x02
        Economy_mode = 0x04

    class RemoteSensing(t.bitmap8):
        all_local = 0x00
        local_temperature_sensed_remotely = 0x01
        outdoor_temperature_sensed_remotely = 0x02
        occupancy_sensed_remotely = 0x04

    class SetpointChangeSource(t.enum8):
        Manual = 0x00
        Schedule = 0x01
        External = 0x02

    class SetpointMode(t.enum8):
        Heat = 0x00
        Cool = 0x01
        Both = 0x02

    class StartOfWeek(t.enum8):
        Sunday = 0x00
        Monday = 0x01
        Tuesday = 0x02
        Wednesday = 0x03
        Thursday = 0x04
        Friday = 0x05
        Saturday = 0x06

    class SystemMode(t.enum8):
        Off = 0x00
        Auto = 0x01
        Cool = 0x03
        Heat = 0x04
        Emergency_Heating = 0x05
        Pre_cooling = 0x06
        Fan_only = 0x07
        Dry = 0x08
        Sleep = 0x09

    class SystemType(t.bitmap8):
        Heat_and_or_Cool_Stage_1 = 0x00
        Cool_Stage_1 = 0x01
        Cool_Stage_2 = 0x02
        Heat_Stage_1 = 0x04
        Heat_Stage_2 = 0x08
        Heat_Pump = 0x10
        Gas = 0x20

        @property
        def cooling_system_stage(self) -> CoolingSystemStage:
            return CoolingSystemStage(self & 0x03)

        @property
        def heating_system_stage(self) -> HeatingSystemStage:
            return HeatingSystemStage((self >> 2) & 0x03)

        @property
        def heating_system_type(self) -> HeatingSystemType:
            return HeatingSystemType((self >> 4) & 0x01)

        @property
        def heating_fuel_source(self) -> HeatingFuelSource:
            return HeatingFuelSource((self >> 5) & 0x01)

    class TemperatureSetpointHold(t.enum8):
        Setpoint_Hold_Off = 0x00
        Setpoint_Hold_On = 0x01

    class RunningMode(t.enum8):
        Off = 0x00
        Cool = 0x03
        Heat = 0x04

    class RunningState(t.bitmap16):
        Idle = 0x0000
        Heat_State_On = 0x0001
        Cool_State_On = 0x0002
        Fan_State_On = 0x0004
        Heat_2nd_Stage_On = 0x0008
        Cool_2nd_Stage_On = 0x0010
        Fan_2nd_Stage_On = 0x0020
        Fan_3rd_Stage_On = 0x0040

    cluster_id = 0x0201
    ep_attribute = "thermostat"
    attributes: dict[int, ZCLAttributeDef] = {
        # Thermostat Information
        0x0000: ("local_temperature", t.int16s),
        0x0001: ("outdoor_temperature", t.int16s),
        0x0002: ("occupancy", Occupancy),
        0x0003: ("abs_min_heat_setpoint_limit", t.int16s),
        0x0004: ("abs_max_heat_setpoint_limit", t.int16s),
        0x0005: ("abs_min_cool_setpoint_limit", t.int16s),
        0x0006: ("abs_max_cool_setpoint_limit", t.int16s),
        0x0007: ("pi_cooling_demand", t.uint8_t),
        0x0008: ("pi_heating_demand", t.uint8_t),
        0x0009: ("system_type_config", SystemType),
        # Thermostat Settings
        0x0010: ("local_temperature_calibration", t.int8s),
        0x0011: ("occupied_cooling_setpoint", t.int16s),
        0x0012: ("occupied_heating_setpoint", t.int16s),
        0x0013: ("unoccupied_cooling_setpoint", t.int16s),
        0x0014: ("unoccupied_heating_setpoint", t.int16s),
        0x0015: ("min_heat_setpoint_limit", t.int16s),
        0x0016: ("max_heat_setpoint_limit", t.int16s),
        0x0017: ("min_cool_setpoint_limit", t.int16s),
        0x0018: ("max_cool_setpoint_limit", t.int16s),
        0x0019: ("min_setpoint_dead_band", t.int8s),
        0x001A: ("remote_sensing", RemoteSensing),
        0x001B: ("ctrl_sequence_of_oper", ControlSequenceOfOperation),
        0x001C: ("system_mode", SystemMode),
        0x001D: ("alarm_mask", AlarmMask),
        0x001E: ("running_mode", RunningMode),
        # ...
        0x0020: ("start_of_week", StartOfWeek),
        0x0021: ("number_of_weekly_transitions", t.uint8_t),
        0x0022: ("number_of_daily_transitions", t.uint8_t),
        0x0023: ("temp_setpoint_hold", TemperatureSetpointHold),
        0x0024: ("temp_setpoint_hold_duration", t.uint16_t),
        0x0025: ("programing_oper_mode", ProgrammingOperationMode),
        0x0029: ("running_state", RunningState),
        0x0030: ("setpoint_change_source", SetpointChangeSource),
        0x0031: ("setpoint_change_amount", t.int16s),
        0x0032: ("setpoint_change_source_timestamp", t.UTCTime),
        0x0034: ("occupied_setback", t.uint8_t),
        0x0035: ("occupied_setback_min", t.uint8_t),
        0x0036: ("occupied_setback_max", t.uint8_t),
        0x0037: ("unoccupied_setback", t.uint8_t),
        0x0038: ("unoccupied_setback_min", t.uint8_t),
        0x0039: ("unoccupied_setback_max", t.uint8_t),
        0x003A: ("emergency_heat_delta", t.uint8_t),
        0x0040: ("ac_type", ACType),
        0x0041: ("ac_capacity", t.uint16_t),
        0x0042: ("ac_refrigerant_type", ACRefrigerantType),
        0x0043: ("ac_compressor_type", ACCompressorType),
        0x0044: ("ac_error_code", ACErrorCode),
        0x0045: ("ac_louver_position", ACLouverPosition),
        0x0046: ("ac_coil_temperature", t.int16s),
        0x0047: ("ac_capacity_format", ACCapacityFormat),
    }
    server_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef("setpoint_raise_lower", {
            "mode": SetpointMode,
            "amount": t.int8s
        }, False),
        0x01:
        ZCLCommandDef(
            "set_weekly_schedule",
            {
                "num_transitions_for_sequence": t.enum8,
                "day_of_week_for_sequence": SeqDayOfWeek,
                "mode_for_sequence": SeqMode,
                "values": t.List[t.int16s],
            },  # TODO: properly parse values
            False,
        ),
        0x02:
        ZCLCommandDef(
            "get_weekly_schedule",
            {
                "days_to_return": SeqDayOfWeek,
                "mode_to_return": SeqMode
            },
            False,
        ),
        0x03:
        ZCLCommandDef("clear_weekly_schedule", {}, False),
        0x04:
        ZCLCommandDef("get_relay_status_log", {}, False),
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef(
            "get_weekly_schedule_response",
            {
                "num_transitions_for_sequence": t.enum8,
                "day_of_week_for_sequence": SeqDayOfWeek,
                "mode_for_sequence": SeqMode,
                "values": t.List[t.int16s],
            },  # TODO: properly parse values
            True,
        ),
        0x01:
        ZCLCommandDef(
            "get_relay_status_log_response",
            {
                "time_of_day": t.uint16_t,
                "relay_status": t.bitmap8,
                "local_temperature": t.int16s,
                "humidity_in_percentage": t.uint8_t,
                "set_point": t.int16s,
                "unread_entries": t.uint16_t,
            },
            True,
        ),
    }
Beispiel #15
0
class DoorLock(Cluster):
    """The door lock cluster provides an interface to a generic way to secure a door."""
    class LockState(t.enum8):
        Not_fully_locked = 0x00
        Locked = 0x01
        Unlocked = 0x02
        Undefined = 0xFF

    class LockType(t.enum8):
        Dead_bolt = 0x00
        Magnetic = 0x01
        Other = 0x02
        Mortise = 0x03
        Rim = 0x04
        Latch_bolt = 0x05
        Cylindrical_lock = 0x06
        Tubular_lock = 0x07
        Interconnected_lock = 0x08
        Dead_latch = 0x09
        Door_furniture = 0x0A

    class DoorState(t.enum8):
        Open = 0x00
        Closed = 0x01
        Error_jammed = 0x02
        Error_forced_open = 0x03
        Error_unspecified = 0x04
        Undefined = 0xFF

    class OperatingMode(t.enum8):
        Normal = 0x00
        Vacation = 0x01
        Privacy = 0x02
        No_RF_Lock_Unlock = 0x03
        Passage = 0x04

    class SupportedOperatingModes(t.bitmap16):
        Normal = 0x0001
        Vacation = 0x0002
        Privacy = 0x0004
        No_RF = 0x0008
        Passage = 0x0010

    class DefaultConfigurationRegister(t.bitmap16):
        Enable_Local_Programming = 0x0001
        Keypad_Interface_default_access = 0x0002
        RF_Interface_default_access = 0x0004
        Sound_Volume_non_zero = 0x0020
        Auto_Relock_time_non_zero = 0x0040
        Led_settings_non_zero = 0x0080

    class ZigbeeSecurityLevel(t.enum8):
        Network_Security = 0x00
        APS_Security = 0x01

    class AlarmMask(t.bitmap16):
        Deadbolt_Jammed = 0x0001
        Lock_Reset_to_Factory_Defaults = 0x0002
        Reserved = 0x0004
        RF_Module_Power_Cycled = 0x0008
        Tamper_Alarm_wrong_code_entry_limit = 0x0010
        Tamper_Alarm_front_escutcheon_removed = 0x0020
        Forced_Door_Open_under_Door_Lockec_Condition = 0x0040

    class KeypadOperationEventMask(t.bitmap16):
        Manufacturer_specific = 0x0001
        Lock_source_keypad = 0x0002
        Unlock_source_keypad = 0x0004
        Lock_source_keypad_error_invalid_code = 0x0008
        Lock_source_keypad_error_invalid_schedule = 0x0010
        Unlock_source_keypad_error_invalid_code = 0x0020
        Unlock_source_keypad_error_invalid_schedule = 0x0040
        Non_Access_User_Operation = 0x0080

    class RFOperationEventMask(t.bitmap16):
        Manufacturer_specific = 0x0001
        Lock_source_RF = 0x0002
        Unlock_source_RF = 0x0004
        Lock_source_RF_error_invalid_code = 0x0008
        Lock_source_RF_error_invalid_schedule = 0x0010
        Unlock_source_RF_error_invalid_code = 0x0020
        Unlock_source_RF_error_invalid_schedule = 0x0040

    class ManualOperatitonEventMask(t.bitmap16):
        Manufacturer_specific = 0x0001
        Thumbturn_Lock = 0x0002
        Thumbturn_Unlock = 0x0004
        One_touch_lock = 0x0008
        Key_Lock = 0x0010
        Key_Unlock = 0x0020
        Auto_lock = 0x0040
        Schedule_Lock = 0x0080
        Schedule_Unlock = 0x0100
        Manual_Lock_key_or_thumbturn = 0x0200
        Manual_Unlock_key_or_thumbturn = 0x0400

    class RFIDOperationEventMask(t.bitmap16):
        Manufacturer_specific = 0x0001
        Lock_source_RFID = 0x0002
        Unlock_source_RFID = 0x0004
        Lock_source_RFID_error_invalid_RFID_ID = 0x0008
        Lock_source_RFID_error_invalid_schedule = 0x0010
        Unlock_source_RFID_error_invalid_RFID_ID = 0x0020
        Unlock_source_RFID_error_invalid_schedule = 0x0040

    class KeypadProgrammingEventMask(t.bitmap16):
        Manufacturer_Specific = 0x0001
        Master_code_changed = 0x0002
        PIN_added = 0x0004
        PIN_deleted = 0x0008
        PIN_changed = 0x0010

    class RFProgrammingEventMask(t.bitmap16):
        Manufacturer_Specific = 0x0001
        PIN_added = 0x0004
        PIN_deleted = 0x0008
        PIN_changed = 0x0010
        RFID_code_added = 0x0020
        RFID_code_deleted = 0x0040

    class RFIDProgrammingEventMask(t.bitmap16):
        Manufacturer_Specific = 0x0001
        RFID_code_added = 0x0020
        RFID_code_deleted = 0x0040

    class OperationEventSource(t.enum8):
        Keypad = 0x00
        RF = 0x01
        Manual = 0x02
        RFID = 0x03
        Indeterminate = 0xFF

    class OperationEvent(t.enum8):
        UnknownOrMfgSpecific = 0x00
        Lock = 0x01
        Unlock = 0x02
        LockFailureInvalidPINorID = 0x03
        LockFailureInvalidSchedule = 0x04
        UnlockFailureInvalidPINorID = 0x05
        UnlockFailureInvalidSchedule = 0x06
        OnTouchLock = 0x07
        KeyLock = 0x08
        KeyUnlock = 0x09
        AutoLock = 0x0A
        ScheduleLock = 0x0B
        ScheduleUnlock = 0x0C
        Manual_Lock = 0x0D
        Manual_Unlock = 0x0E
        Non_Access_User_Operational_Event = 0x0F

    class ProgrammingEvent(t.enum8):
        UnknownOrMfgSpecific = 0x00
        MasterCodeChanged = 0x01
        PINCodeAdded = 0x02
        PINCodeDeleted = 0x03
        PINCodeChanges = 0x04
        RFIDCodeAdded = 0x05
        RFIDCodeDeleted = 0x06

    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"
    attributes: dict[int, ZCLAttributeDef] = {
        0x0000: ("lock_state", LockState),
        0x0001: ("lock_type", LockType),
        0x0002: ("actuator_enabled", t.Bool),
        0x0003: ("door_state", DoorState),
        0x0004: ("door_open_events", t.uint32_t),
        0x0005: ("door_closed_events", t.uint32_t),
        0x0006: ("open_period", t.uint16_t),
        0x0010: ("num_of_lock_records_supported", t.uint16_t),
        0x0011: ("num_of_total_users_supported", t.uint16_t),
        0x0012: ("num_of_pin_users_supported", t.uint16_t),
        0x0013: ("num_of_rfid_users_supported", t.uint16_t),
        0x0014: ("num_of_week_day_schedules_supported_per_user", t.uint8_t),
        0x0015: ("num_of_year_day_schedules_supported_per_user", t.uint8_t),
        0x0016: ("num_of_holiday_scheduleds_supported", t.uint8_t),
        0x0017: ("max_pin_len", t.uint8_t),
        0x0018: ("min_pin_len", t.uint8_t),
        0x0019: ("max_rfid_len", t.uint8_t),
        0x001A: ("min_rfid_len", t.uint8_t),
        0x0020: ("enable_logging", t.Bool),
        0x0021: ("language", t.LimitedCharString(3)),
        0x0022: ("led_settings", t.uint8_t),
        0x0023: ("auto_relock_time", t.uint32_t),
        0x0024: ("sound_volume", t.uint8_t),
        0x0025: ("operating_mode", OperatingMode),
        0x0026: ("supported_operating_modes", SupportedOperatingModes),
        0x0027:
        ("default_configuration_register", DefaultConfigurationRegister),
        0x0028: ("enable_local_programming", t.Bool),
        0x0029: ("enable_one_touch_locking", t.Bool),
        0x002A: ("enable_inside_status_led", t.Bool),
        0x002B: ("enable_privacy_mode_button", t.Bool),
        0x0030: ("wrong_code_entry_limit", t.uint8_t),
        0x0031: ("user_code_temporary_disable_time", t.uint8_t),
        0x0032: ("send_pin_ota", t.Bool),
        0x0033: ("require_pin_for_rf_operation", t.Bool),
        0x0034: ("zigbee_security_level", ZigbeeSecurityLevel),
        0x0040: ("alarm_mask", AlarmMask),
        0x0041: ("keypad_operation_event_mask", KeypadOperationEventMask),
        0x0042: ("rf_operation_event_mask", RFOperationEventMask),
        0x0043: ("manual_operation_event_mask", ManualOperatitonEventMask),
        0x0044: ("rfid_operation_event_mask", RFIDOperationEventMask),
        0x0045: ("keypad_programming_event_mask", KeypadProgrammingEventMask),
        0x0046: ("rf_programming_event_mask", RFProgrammingEventMask),
        0x0047: ("rfid_programming_event_mask", RFIDProgrammingEventMask),
    }
    server_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef("lock_door", {"pin_code?": t.CharacterString}, False),
        0x01:
        ZCLCommandDef("unlock_door", {"pin_code?": t.CharacterString}, False),
        0x02:
        ZCLCommandDef("toggle_door", {"pin_code?": t.CharacterString}, False),
        0x03:
        ZCLCommandDef(
            "unlock_with_timeout",
            {
                "timeout": t.uint16_t,
                "pin_code?": t.CharacterString
            },
            False,
        ),
        0x04:
        ZCLCommandDef("get_log_record", {"log_index": t.uint16_t}, False),
        0x05:
        ZCLCommandDef(
            "set_pin_code",
            {
                "user_id": t.uint16_t,
                "user_status": UserStatus,
                "user_type": UserType,
                "pin_code": t.CharacterString,
            },
            False,
        ),
        0x06:
        ZCLCommandDef("get_pin_code", {"user_id": t.uint16_t}, False),
        0x07:
        ZCLCommandDef("clear_pin_code", {"user_id": t.uint16_t}, False),
        0x08:
        ZCLCommandDef("clear_all_pin_codes", {}, False),
        0x09:
        ZCLCommandDef("set_user_status", {
            "user_id": t.uint16_t,
            "user_status": UserStatus
        }, False),
        0x0A:
        ZCLCommandDef("get_user_status", {"user_id": t.uint16_t}, False),
        0x0B:
        ZCLCommandDef(
            "set_week_day_schedule",
            {
                "schedule_id": t.uint8_t,
                "user_id": t.uint16_t,
                "days_mask": DayMask,
                "start_hour": t.uint8_t,
                "start_minute": t.uint8_t,
                "end_hour": t.uint8_t,
                "end_minute": t.uint8_t,
            },
            False,
        ),
        0x0C:
        ZCLCommandDef(
            "get_week_day_schedule",
            {
                "schedule_id": t.uint8_t,
                "user_id": t.uint16_t
            },
            False,
        ),
        0x0D:
        ZCLCommandDef(
            "clear_week_day_schedule",
            {
                "schedule_id": t.uint8_t,
                "user_id": t.uint16_t
            },
            False,
        ),
        0x0E:
        ZCLCommandDef(
            "set_year_day_schedule",
            {
                "schedule_id": t.uint8_t,
                "user_id": t.uint16_t,
                "local_start_time": t.LocalTime,
                "local_end_time": t.LocalTime,
            },
            False,
        ),
        0x0F:
        ZCLCommandDef(
            "get_year_day_schedule",
            {
                "schedule_id": t.uint8_t,
                "user_id": t.uint16_t
            },
            False,
        ),
        0x10:
        ZCLCommandDef(
            "clear_year_day_schedule",
            {
                "schedule_id": t.uint8_t,
                "user_id": t.uint16_t
            },
            False,
        ),
        0x11:
        ZCLCommandDef(
            "set_holiday_schedule",
            {
                "holiday_schedule_id": t.uint8_t,
                "local_start_time": t.LocalTime,
                "local_end_time": t.LocalTime,
                "operating_mode_during_holiday": OperatingMode,
            },
            False,
        ),
        0x12:
        ZCLCommandDef("get_holiday_schedule",
                      {"holiday_schedule_id": t.uint8_t}, False),
        0x13:
        ZCLCommandDef("clear_holiday_schedule",
                      {"holiday_schedule_id": t.uint8_t}, False),
        0x14:
        ZCLCommandDef("set_user_type", {
            "user_id": t.uint16_t,
            "user_type": UserType
        }, False),
        0x15:
        ZCLCommandDef("get_user_type", {"user_id": t.uint16_t}, False),
        0x16:
        ZCLCommandDef(
            "set_rfid_code",
            {
                "user_id": t.uint16_t,
                "user_status": UserStatus,
                "user_type": UserType,
                "rfid_code": t.CharacterString,
            },
            False,
        ),
        0x17:
        ZCLCommandDef("get_rfid_code", {"user_id": t.uint16_t}, False),
        0x18:
        ZCLCommandDef("clear_rfid_code", {"user_id": t.uint16_t}, False),
        0x19:
        ZCLCommandDef("clear_all_rfid_codes", {}, False),
    }
    client_commands: dict[int, ZCLCommandDef] = {
        0x00:
        ZCLCommandDef("lock_door_response", {"status": foundation.Status},
                      True),
        0x01:
        ZCLCommandDef("unlock_door_response", {"status": foundation.Status},
                      True),
        0x02:
        ZCLCommandDef("toggle_door_response", {"status": foundation.Status},
                      True),
        0x03:
        ZCLCommandDef("unlock_with_timeout_response",
                      {"status": foundation.Status}, True),
        0x04:
        ZCLCommandDef(
            "get_log_record_response",
            {
                "log_entry_id": t.uint16_t,
                "timestamp": t.uint32_t,
                "event_type": EventType,
                "source": OperationEventSource,
                "event_id_or_alarm_code": t.uint8_t,
                "user_id": t.uint16_t,
                "pin?": t.CharacterString,
            },
            True,
        ),
        0x05:
        ZCLCommandDef("set_pin_code_response", {"status": foundation.Status},
                      True),
        0x06:
        ZCLCommandDef(
            "get_pin_code_response",
            {
                "user_id": t.uint16_t,
                "user_status": UserStatus,
                "user_type": UserType,
                "code": t.CharacterString,
            },
            True,
        ),
        0x07:
        ZCLCommandDef("clear_pin_code_response", {"status": foundation.Status},
                      True),
        0x08:
        ZCLCommandDef("clear_all_pin_codes_response",
                      {"status": foundation.Status}, True),
        0x09:
        ZCLCommandDef("set_user_status_response",
                      {"status": foundation.Status}, True),
        0x0A:
        ZCLCommandDef(
            "get_user_status_response",
            {
                "user_id": t.uint16_t,
                "user_status": UserStatus
            },
            True,
        ),
        0x0B:
        ZCLCommandDef("set_week_day_schedule_response",
                      {"status": foundation.Status}, True),
        0x0C:
        ZCLCommandDef(
            "get_week_day_schedule_response",
            {
                "schedule_id": t.uint8_t,
                "user_id": t.uint16_t,
                "status": foundation.Status,
                "days_mask?": t.uint8_t,
                "start_hour?": t.uint8_t,
                "start_minute?": t.uint8_t,
                "end_hour?": t.uint8_t,
                "end_minute?": t.uint8_t,
            },
            True,
        ),
        0x0D:
        ZCLCommandDef("clear_week_day_schedule_response",
                      {"status": foundation.Status}, True),
        0x0E:
        ZCLCommandDef("set_year_day_schedule_response",
                      {"status": foundation.Status}, True),
        0x0F:
        ZCLCommandDef(
            "get_year_day_schedule_response",
            {
                "schedule_id": t.uint8_t,
                "user_id": t.uint16_t,
                "status": foundation.Status,
                "local_start_time?": t.LocalTime,
                "local_end_time?": t.LocalTime,
            },
            True,
        ),
        0x10:
        ZCLCommandDef("clear_year_day_schedule_response",
                      {"status": foundation.Status}, True),
        0x11:
        ZCLCommandDef("set_holiday_schedule_response",
                      {"status": foundation.Status}, True),
        0x12:
        ZCLCommandDef(
            "get_holiday_schedule_response",
            {
                "holiday_schedule_id": t.uint8_t,
                "status": foundation.Status,
                "local_start_time?": t.LocalTime,
                "local_end_time?": t.LocalTime,
                "operating_mode_during_holiday?": t.uint8_t,
            },
            True,
        ),
        0x13:
        ZCLCommandDef("clear_holiday_schedule_response",
                      {"status": foundation.Status}, True),
        0x14:
        ZCLCommandDef("set_user_type_response", {"status": foundation.Status},
                      True),
        0x15:
        ZCLCommandDef(
            "get_user_type_response",
            {
                "user_id": t.uint16_t,
                "user_type": UserType
            },
            True,
        ),
        0x16:
        ZCLCommandDef("set_rfid_code_response", {"status": foundation.Status},
                      True),
        0x17:
        ZCLCommandDef(
            "get_rfid_code_response",
            {
                "user_id": t.uint16_t,
                "user_status": UserStatus,
                "user_type": UserType,
                "rfid_code": t.CharacterString,
            },
            True,
        ),
        0x18:
        ZCLCommandDef("clear_rfid_code_response",
                      {"status": foundation.Status}, True),
        0x19:
        ZCLCommandDef("clear_all_rfid_codes_response",
                      {"status": foundation.Status}, True),
        0x20:
        ZCLCommandDef(
            "operation_event_notification",
            {
                "operation_event_source": OperationEventSource,
                "operation_event_code": OperationEvent,
                "user_id": t.uint16_t,
                "pin": t.CharacterString,
                "local_time": t.LocalTime,
                "data?": t.CharacterString,
            },
            False,
        ),
        0x21:
        ZCLCommandDef(
            "programming_event_notification",
            {
                "program_event_source": OperationEventSource,
                "program_event_code": ProgrammingEvent,
                "user_id": t.uint16_t,
                "pin": t.CharacterString,
                "user_type": UserType,
                "user_status": UserStatus,
                "local_time": t.LocalTime,
                "data?": t.CharacterString,
            },
            False,
        ),
    }
Beispiel #16
0
class Color(Cluster):
    """Attributes and commands for controlling the color
    properties of a color-capable light"""

    class ColorMode(t.enum8):
        Hue_and_saturation = 0x00
        X_and_Y = 0x01
        Color_temperature = 0x02

    class EnhancedColorMode(t.enum8):
        Hue_and_saturation = 0x00
        X_and_Y = 0x01
        Color_temperature = 0x02
        Enhanced_hue_and_saturation = 0x03

    class ColorCapabilities(t.bitmap16):
        Hue_and_saturation = 0b00000000_00000001
        Enhanced_hue = 0b00000000_00000010
        Color_loop = 0b00000000_00000100
        XY_attributes: dict[int, ZCLAttributeDef] = 0b00000000_00001000
        Color_temperature = 0b00000000_00010000

    class Direction(t.enum8):
        Shortest_distance = 0x00
        Longest_distance = 0x01
        Up = 0x02
        Down = 0x03

    class MoveMode(t.enum8):
        Stop = 0x00
        Up = 0x01
        Down = 0x03

    class StepMode(t.enum8):
        Up = 0x01
        Down = 0x03

    class ColorLoopUpdateFlags(t.bitmap8):
        Action = 0b0000_0001
        Direction = 0b0000_0010
        Time = 0b0000_0100
        Start_Hue = 0b0000_1000

    class ColorLoopAction(t.enum8):
        Deactivate = 0x00
        Activate_from_color_loop_hue = 0x01
        Activate_from_current_hue = 0x02

    class ColorLoopDirection(t.enum8):
        Decrement = 0x00
        Increment = 0x01

    cluster_id = 0x0300
    name = "Color Control"
    ep_attribute = "light_color"
    attributes: dict[int, ZCLAttributeDef] = {
        # Color Information
        0x0000: ("current_hue", t.uint8_t),
        0x0001: ("current_saturation", t.uint8_t),
        0x0002: ("remaining_time", t.uint16_t),
        0x0003: ("current_x", t.uint16_t),
        0x0004: ("current_y", t.uint16_t),
        0x0005: ("drift_compensation", t.enum8),
        0x0006: ("compensation_text", t.CharacterString),
        0x0007: ("color_temperature", t.uint16_t),
        0x0008: ("color_mode", t.enum8),
        0x000F: ("options", t.bitmap8),
        # Defined Primaries Information
        0x0010: ("num_primaries", t.uint8_t),
        0x0011: ("primary1_x", t.uint16_t),
        0x0012: ("primary1_y", t.uint16_t),
        0x0013: ("primary1_intensity", t.uint8_t),
        0x0015: ("primary2_x", t.uint16_t),
        0x0016: ("primary2_y", t.uint16_t),
        0x0017: ("primary2_intensity", t.uint8_t),
        0x0019: ("primary3_x", t.uint16_t),
        0x001A: ("primary3_y", t.uint16_t),
        0x001B: ("primary3_intensity", t.uint8_t),
        # Additional Defined Primaries Information
        0x0020: ("primary4_x", t.uint16_t),
        0x0021: ("primary4_y", t.uint16_t),
        0x0022: ("primary4_intensity", t.uint8_t),
        0x0024: ("primary5_x", t.uint16_t),
        0x0025: ("primary5_y", t.uint16_t),
        0x0026: ("primary5_intensity", t.uint8_t),
        0x0028: ("primary6_x", t.uint16_t),
        0x0029: ("primary6_y", t.uint16_t),
        0x002A: ("primary6_intensity", t.uint8_t),
        # Defined Color Point Settings
        0x0030: ("white_point_x", t.uint16_t),
        0x0031: ("white_point_y", t.uint16_t),
        0x0032: ("color_point_r_x", t.uint16_t),
        0x0033: ("color_point_r_y", t.uint16_t),
        0x0034: ("color_point_r_intensity", t.uint8_t),
        0x0036: ("color_point_g_x", t.uint16_t),
        0x0037: ("color_point_g_y", t.uint16_t),
        0x0038: ("color_point_g_intensity", t.uint8_t),
        0x003A: ("color_point_b_x", t.uint16_t),
        0x003B: ("color_point_b_y", t.uint16_t),
        0x003C: ("color_point_b_intensity", t.uint8_t),
        # ...
        0x4000: ("enhanced_current_hue", t.uint16_t),
        0x4001: ("enhanced_color_mode", EnhancedColorMode),
        0x4002: ("color_loop_active", t.uint8_t),
        0x4003: ("color_loop_direction", t.uint8_t),
        0x4004: ("color_loop_time", t.uint16_t),
        0x4005: ("color_loop_start_enhanced_hue", t.uint16_t),
        0x4006: ("color_loop_stored_enhanced_hue", t.uint16_t),
        0x400A: ("color_capabilities", ColorCapabilities),
        0x400B: ("color_temp_physical_min", t.uint16_t),
        0x400C: ("color_temp_physical_max", t.uint16_t),
        0x400D: ("couple_color_temp_to_level_min", t.uint16_t),
        0x4010: ("start_up_color_temperature", t.uint16_t),
        0xFFFD: ("cluster_revision", t.uint16_t),
        0xFFFE: ("attr_reporting_status", foundation.AttributeReportingStatus),
    }
    server_commands: dict[int, ZCLCommandDef] = {
        0x00: ZCLCommandDef(
            "move_to_hue",
            {
                "hue": t.uint8_t,
                "direction": Direction,
                "transition_time": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x01: ZCLCommandDef(
            "move_hue",
            {
                "move_mode": MoveMode,
                "rate": t.uint8_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x02: ZCLCommandDef(
            "step_hue",
            {
                "step_mode": StepMode,
                "step_size": t.uint8_t,
                "transition_time": t.uint8_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x03: ZCLCommandDef(
            "move_to_saturation",
            {
                "saturation": t.uint8_t,
                "transition_time": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x04: ZCLCommandDef(
            "move_saturation",
            {
                "move_mode": MoveMode,
                "rate": t.uint8_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x05: ZCLCommandDef(
            "step_saturation",
            {
                "step_mode": StepMode,
                "step_size": t.uint8_t,
                "transition_time": t.uint8_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x06: ZCLCommandDef(
            "move_to_hue_and_saturation",
            {
                "hue": t.uint8_t,
                "saturation": t.uint8_t,
                "transition_time": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x07: ZCLCommandDef(
            "move_to_color",
            {
                "color_x": t.uint16_t,
                "color_y": t.uint16_t,
                "transition_time": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x08: ZCLCommandDef(
            "move_color",
            {
                "rate_x": t.uint16_t,
                "rate_y": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x09: ZCLCommandDef(
            "step_color",
            {
                "step_x": t.uint16_t,
                "step_y": t.uint16_t,
                "duration": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x0A: ZCLCommandDef(
            "move_to_color_temp",
            {
                "color_temp_mireds": t.uint16_t,
                "transition_time": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x40: ZCLCommandDef(
            "enhanced_move_to_hue",
            {
                "enhanced_hue": t.uint16_t,
                "direction": Direction,
                "transition_time": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x41: ZCLCommandDef(
            "enhanced_move_hue",
            {
                "move_mode": MoveMode,
                "rate": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x42: ZCLCommandDef(
            "enhanced_step_hue",
            {
                "step_mode": StepMode,
                "step_size": t.uint16_t,
                "transition_time": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x43: ZCLCommandDef(
            "enhanced_move_to_hue_and_saturation",
            {
                "enhanced_hue": t.uint16_t,
                "saturation": t.uint8_t,
                "transition_time": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x44: ZCLCommandDef(
            "color_loop_set",
            {
                "update_flags": ColorLoopUpdateFlags,
                "action": ColorLoopAction,
                "direction": ColorLoopDirection,
                "time": t.uint16_t,
                "start_hue": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x47: ZCLCommandDef(
            "stop_move_step",
            {
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x4B: ZCLCommandDef(
            "move_color_temp",
            {
                "move_mode": MoveMode,
                "rate": t.uint16_t,
                "color_temp_min_mireds": t.uint16_t,
                "color_temp_max_mireds": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
        0x4C: ZCLCommandDef(
            "step_color_temp",
            {
                "step_mode": StepMode,
                "step_size": t.uint16_t,
                "transition_time": t.uint16_t,
                "color_temp_min_mireds": t.uint16_t,
                "color_temp_max_mireds": t.uint16_t,
                "options_mask?": t.bitmap8,
                "options_override?": t.bitmap8,
            },
            False,
        ),
    }
    client_commands: dict[int, ZCLCommandDef] = {}