Open MnM001 opened 3 months ago
This is just a tweaked quirk reusing similar definition for _TZ3000_qeuvnohg, and my comment here.
Current and Summation seem to work correctly. The temperature does not work and other circuit breaker functions have not been added. It's definitely not perfect and I'd appreciate any advice.
"""TS011F Circuit Breaker - Tongou TO-Q-SY2-JZT."""
from typing import Any, Dict
from zigpy.profiles import zgp, zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
OnOff,
Ota,
Scenes,
Time,
)
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.lightlink import LightLink
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.smartenergy import Metering
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODEL,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.quirk_ids import TUYA_PLUG_ONOFF
from zhaquirks.tuya import (
EnchantedDevice,
TuyaLocalCluster,
TuyaManufCluster,
TuyaNewManufCluster,
TuyaZB1888Cluster,
TuyaZBE000Cluster,
TuyaZBElectricalMeasurement,
TuyaZBExternalSwitchTypeCluster,
TuyaZBMeteringCluster,
TuyaZBMeteringClusterWithUnit,
TuyaZBOnOffAttributeCluster,
)
from zhaquirks.tuya.mcu import (
DPToAttributeMapping,
EnchantedDevice,
TuyaMCUCluster,
TuyaPowerConfigurationCluster,
)
from zhaquirks.tuya import TuyaDPType
class TuyaTemperatureMeasurement(TemperatureMeasurement, TuyaLocalCluster):
"""Tuya local TemperatureMeasurement cluster."""
class TemperatureHumidityManufCluster(TuyaMCUCluster):
"""Tuya Manufacturer Cluster with Temperature data point."""
dp_to_attribute: Dict[int, DPToAttributeMapping] = {
1: DPToAttributeMapping(
TuyaTemperatureMeasurement.ep_attribute,
"measured_value",
converter=lambda x: x * 10, # decidegree to centidegree
),
}
data_point_handlers = {
1: "_dp_2_attr_update",
}
class Plug_CB_Metering_v2(EnchantedDevice):
"""Circuit breaker with monitoring, e.g. Tongou TO-Q-SY2-JZT. First one using this definition was _TZ3000_cayepv1a"""
quirk_id = TUYA_PLUG_ONOFF
signature = {
MODEL: "TS011F",
MODELS_INFO: [("_TZ3000_cayepv1a", "TS011F")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=266
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 1794, 2820, 1026, 57344, 57345]
# output_clusters=[25, 10]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_PLUG_IN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
TemperatureMeasurement.cluster_id,
TuyaZBE000Cluster.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=1
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_PLUG_IN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaZBMeteringCluster,
TuyaZBElectricalMeasurement,
TuyaTemperatureMeasurement,
TuyaZBE000Cluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
Sorry to hijack a thread, I have a TO-Q-SY2-163JZT in the post and I plan to use with ZHA, can I assume the default is off for the 'breaker' protection variables and the max amp is 64? My primary use case is on/off (passing up-to 32A), anything else is a bonus! Hopefully the parameters will the exposed in ZHA soon to configure and monitor :-)
Problem description
When adding TO-Q-SY2-163JZT to ZHA is coming up as TS011F by _TZ3000_cayepv1a - however this seems to be another product - TO-Q-SY1. TO-Q-SY1 can only do monitoring.
TO-Q-SY2-163JZT can do monitoring and more: MCB Smart Circuit Breaker Over Current Under Voltage Protection Power Metering 1-63A Remote Control Switch.
However none of the circuit breakers are exposed to ZHA.
It will be good if this can be fixed.
Solution description
TO-Q-SY2-163JZT needs to have the following in ZHA:
temperature protection over current protection over voltage protection under voltage protection high power protection timing and adjustable Functions for the above
as well functional real-time energy consumption monitoring (I say functional as current monitoring is showing wrong values - see https://github.com/zigpy/zha-device-handlers/issues/2652 )
This unit is fully functional in zigbee2mqtt (https://www.zigbee2mqtt.io/devices/TO-Q-SY2-163JZT.html)
Screenshots/Video
Screenshots from zigbee2mqtt
![image](https://github.com/zigpy/zha-device-handlers/assets/15014858/91dc67b3-9725-4fa1-807a-45ac33ebedba)Screenshots from ZHA
![image](https://github.com/zigpy/zha-device-handlers/assets/15014858/efa107bc-06f4-4bd6-acfe-6784d6783ce3) ### Device signatureDevice signature
```json { "node_descriptor": "NodeDescriptor(logical_type=Diagnostic information
```json [Paste the diagnostic information here] ```Logs
```python [Paste the logs here] ```Custom quirk
```python [Paste your custom quirk here] ```