Skip to content

Instantly share code, notes, and snippets.

@petrleocompel
Last active January 27, 2025 21:07
Show Gist options
  • Save petrleocompel/16075c99379e8fbef7014d36df9d5765 to your computer and use it in GitHub Desktop.
Save petrleocompel/16075c99379e8fbef7014d36df9d5765 to your computer and use it in GitHub Desktop.
Tesla Smart 1-Button ZHA quirk TS0041
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, PowerConfiguration, OnOff, Time
from zigpy.zcl.clusters.general import Ota
from zhaquirks.const import (
BUTTON_1,
COMMAND,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
)
from zhaquirks.tuya import (
TuyaNoBindPowerConfigurationCluster,
TuyaSmartRemoteOnOffCluster,
)
class TS0041(CustomDevice):
"""Custom device handler for TS0041."""
signature = {
# Match the device signature exactly
MODELS_INFO: [("_TZ3000_ajsypttg", "TS0041")],
ENDPOINTS: {
1: {
PROFILE_ID: 0x0104,
DEVICE_TYPE: 0x0401,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
OnOff.cluster_id,
Time.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
}
replacement = {
# Replace with the updated configuration
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
TuyaNoBindPowerConfigurationCluster,
TuyaSmartRemoteOnOffCluster,
Time.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
}
device_automation_triggers = {
(SHORT_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: SHORT_PRESS},
(LONG_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: LONG_PRESS},
(DOUBLE_PRESS, BUTTON_1): {ENDPOINT_ID: 1, COMMAND: DOUBLE_PRESS},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment