"""Device handler for IKEA of Sweden TRADFRI shortcut button.""" from zigpy.profiles import zha from zigpy.quirks import CustomDevice from zigpy.zcl.clusters.closures import WindowCovering from zigpy.zcl.clusters.general import ( Alarms, Basic, Groups, Identify, LevelControl, OnOff, Ota, PollControl, PowerConfiguration, ) from zigpy.zcl.clusters.lightlink import LightLink from zhaquirks.const import ( CLUSTER_ID, COMMAND, COMMAND_MOVE_ON_OFF, COMMAND_OFF, COMMAND_ON, COMMAND_STOP_ON_OFF, DEVICE_TYPE, DIM_UP, DOUBLE_PRESS, ENDPOINT_ID, ENDPOINTS, INPUT_CLUSTERS, LONG_PRESS, LONG_RELEASE, MODELS_INFO, OUTPUT_CLUSTERS, PARAMS, PROFILE_ID, SHORT_PRESS, TURN_ON, ) from zhaquirks.ikea import IKEA, IKEA_CLUSTER_ID, DoublingPowerConfig1CRCluster class IkeaTradfriShortcutBtn(CustomDevice): """Custom device representing IKEA of Sweden TRADFRI shortcut button.""" signature = { # MODELS_INFO: [(IKEA, "TRADFRI SHORTCUT Button")], ENDPOINTS: { 1: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER, INPUT_CLUSTERS: [ Basic.cluster_id, PowerConfiguration.cluster_id, Identify.cluster_id, Alarms.cluster_id, PollControl.cluster_id, LightLink.cluster_id, ], OUTPUT_CLUSTERS: [ Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, LevelControl.cluster_id, Ota.cluster_id, WindowCovering.cluster_id, LightLink.cluster_id, ], } }, } replacement = { ENDPOINTS: { 1: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER, INPUT_CLUSTERS: [ Basic.cluster_id, DoublingPowerConfig1CRCluster, Identify.cluster_id, Alarms.cluster_id, PollControl.cluster_id, LightLink.cluster_id, ], OUTPUT_CLUSTERS: [ Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, LevelControl.cluster_id, Ota.cluster_id, WindowCovering.cluster_id, LightLink.cluster_id, ], } } } device_automation_triggers = { (SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1}, (DOUBLE_PRESS, TURN_ON): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1}, (LONG_PRESS, DIM_UP): { COMMAND: COMMAND_MOVE_ON_OFF, CLUSTER_ID: 8, ENDPOINT_ID: 1, PARAMS: {"move_mode": 0}, }, (LONG_RELEASE, DIM_UP): { COMMAND: COMMAND_STOP_ON_OFF, CLUSTER_ID: 8, ENDPOINT_ID: 1, }, } class IkeaTradfriShortcutBtn2(CustomDevice): """Custom device representing IKEA of Sweden TRADFRI shortcut button with IKEA cluster.""" signature = { # MODELS_INFO: [(IKEA, "TRADFRI SHORTCUT Button")], ENDPOINTS: { 1: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER, INPUT_CLUSTERS: [ Basic.cluster_id, PowerConfiguration.cluster_id, Identify.cluster_id, Alarms.cluster_id, PollControl.cluster_id, LightLink.cluster_id, IKEA_CLUSTER_ID, ], OUTPUT_CLUSTERS: [ Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, LevelControl.cluster_id, Ota.cluster_id, LightLink.cluster_id, ], } }, } replacement = { ENDPOINTS: { 1: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER, INPUT_CLUSTERS: [ Basic.cluster_id, DoublingPowerConfig1CRCluster, Identify.cluster_id, Alarms.cluster_id, PollControl.cluster_id, LightLink.cluster_id, ], OUTPUT_CLUSTERS: [ Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, LevelControl.cluster_id, Ota.cluster_id, LightLink.cluster_id, ], } } } device_automation_triggers = { (SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1}, (DOUBLE_PRESS, TURN_ON): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1}, (LONG_PRESS, DIM_UP): { COMMAND: COMMAND_MOVE_ON_OFF, CLUSTER_ID: 8, ENDPOINT_ID: 1, PARAMS: {"move_mode": 0}, }, (LONG_RELEASE, DIM_UP): { COMMAND: COMMAND_STOP_ON_OFF, CLUSTER_ID: 8, ENDPOINT_ID: 1, }, }