Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix battery reporting for _TZE200_yjjdcqsq, _TZE200_9yapgbuv #2626

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions zhaquirks/tuya/ts0601_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ class TemperatureHumidityManufCluster(TuyaMCUCluster):
}


class TemperatureHumidityBatteryStatesManufCluster(TuyaMCUCluster):
"""Tuya Manufacturer Cluster with Temperature and Humidity data points. Battery states 25, 50 and 100%."""

dp_to_attribute: Dict[int, DPToAttributeMapping] = {
1: TemperatureHumidityManufCluster.dp_to_attribute[1],
2: TemperatureHumidityManufCluster.dp_to_attribute[2],
3: DPToAttributeMapping(
TuyaPowerConfigurationCluster2AAA.ep_attribute,
"battery_percentage_remaining",
converter=lambda x: {0: 25, 1: 50, 2: 100}[x], # double reported percentage
),
}

data_point_handlers = {
1: "_dp_2_attr_update",
2: "_dp_2_attr_update",
3: "_dp_2_attr_update",
}


class TuyaTempHumiditySensor(CustomDevice):
"""Custom device representing tuya temp and humidity sensor with e-ink screen."""

Expand Down Expand Up @@ -181,8 +201,6 @@ class TuyaTempHumiditySensorVar03(CustomDevice):
# "in_clusters": ["0x0000","0x0004","0x0005","0xef00"],
# "out_clusters": ["0x000a","0x0019"]
MODELS_INFO: [
("_TZE200_yjjdcqsq", "TS0601"),
("_TZE200_9yapgbuv", "TS0601"),
("_TZE200_qyflbnbj", "TS0601"),
("_TZE200_utkemkbs", "TS0601"),
],
Expand Down Expand Up @@ -221,6 +239,53 @@ class TuyaTempHumiditySensorVar03(CustomDevice):
}


class TuyaTempHumiditySensorVar04(CustomDevice):
"""Tuya temp and humidity sensor (variation 04)."""

signature = {
# "profile_id": 260,
# "device_type": "0x0051",
# "in_clusters": ["0x0000","0x0004","0x0005","0xef00"],
# "out_clusters": ["0x000a","0x0019"]
MODELS_INFO: [
("_TZE200_yjjdcqsq", "TS0601"),
("_TZE200_9yapgbuv", "TS0601"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TemperatureHumidityManufCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
}
},
}

replacement = {
SKIP_CONFIGURATION: True,
ENDPOINTS: {
1: {
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TemperatureHumidityBatteryStatesManufCluster,
TuyaTemperatureMeasurement,
TuyaRelativeHumidity,
TuyaPowerConfigurationCluster2AAA,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
}
},
}


class SoilManufCluster(TuyaMCUCluster):
"""Tuya Manufacturer Cluster with Temperature and Humidity data points."""

Expand Down
Loading