zha-device-handlers
zha-device-handlers copied to clipboard
[Device Support Request] _TZ3000_x3ewpzyr doesn't show instant electrical measurement
Is your feature request related to a problem? Please describe. I've purchased and installed a Tuya Zibgee switch with power measurement support.
I can switch it on and off correctly, and I get correct reading for Electricalmeasurementrmsvoltage and Smartenergysummation attributes. However, Electricalmeasurement attribute is always read as 0, and I get inconsistent and out-of-bounds values (like values about 40 A) for the Electricalmeasurementrmscurrent attribute.
Describe the solution you'd like Both Electricalmeasurement and Electricalmeasurementrmscurrent attributes should return correct values.
Device signature
{
"node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
"endpoints": {
"1": {
"profile_id": 260,
"device_type": "0x0100",
"in_clusters": [
"0x0000",
"0x0003",
"0x0004",
"0x0005",
"0x0006",
"0x0702",
"0x0b04",
"0xe000",
"0xe001"
],
"out_clusters": [
"0x000a",
"0x0019"
]
},
"242": {
"profile_id": 41440,
"device_type": "0x0061",
"in_clusters": [],
"out_clusters": [
"0x0021"
]
}
},
"manufacturer": "_TZ3000_x3ewpzyr",
"model": "TS0001",
"class": "zigpy.device.Device"
}
Diagnostic information
{
"home_assistant": {
"installation_type": "Home Assistant OS",
"version": "2022.9.5",
"dev": false,
"hassio": true,
"virtualenv": false,
"python_version": "3.10.5",
"docker": true,
"arch": "aarch64",
"timezone": "Europe/Madrid",
"os_name": "Linux",
"os_version": "5.15.32-v8",
"supervisor": "2022.09.1",
"host_os": "Home Assistant OS 8.2",
"docker_version": "20.10.14",
"chassis": "embedded",
"run_as_root": true
},
"custom_components": {
"google_keep": {
"version": "v1.1.4",
"requirements": [
"gkeepapi==0.11.16"
]
},
"scheduler": {
"version": "v0.0.0",
"requirements": []
},
"bodymiscale": {
"version": "3.0.3",
"requirements": [
"cachetools==5.1.0"
]
},
"ideenergy": {
"version": "0.2.3",
"requirements": [
"ideenergy==1.0.0a3"
]
},
"browser_mod": {
"version": "2.1.2",
"requirements": []
},
"pvpc_hourly_pricing": {
"version": "2.3.0",
"requirements": [
"aiopvpc==2.3.0"
]
},
"hacs": {
"version": "1.27.1",
"requirements": [
"aiogithubapi>=22.2.4"
]
},
"localtuya": {
"version": "4.1.0",
"requirements": []
},
"smartthinq_sensors": {
"version": "0.24.2",
"requirements": [
"pycountry>=20.7.3",
"xmltodict>=0.12.0",
"cchardet>=2.1.7"
]
},
"meross_lan": {
"version": "2.6.1",
"requirements": []
},
"shinobi": {
"version": "1.3.1",
"requirements": []
},
"reversotts": {
"version": "1.0.2",
"requirements": [
"pyttsreverso==0.4"
]
},
"edge_tts": {
"version": "0.0.1",
"requirements": [
"edge-tts==5.0.1"
]
},
"sonoff": {
"version": "3.2.0",
"requirements": [
"pycryptodome>=3.6.6"
]
},
"google_home": {
"version": "1.9.15",
"requirements": [
"glocaltokens==0.6.8"
]
},
"ble_monitor": {
"version": "10.0.0",
"requirements": [
"pycryptodomex>=3.14.1",
"janus>=1.0.0",
"aioblescan>=0.2.13",
"btsocket>=0.2.0",
"pyric>=0.1.6.3"
]
},
"presence_simulation": {
"version": "2.2",
"requirements": []
},
"watchman": {
"version": "0.5.1",
"requirements": [
"prettytable==3.0.0"
]
},
"zha_toolkit": {
"version": "v0.8.14",
"requirements": []
},
"powercalc": {
"version": "v0.25.4",
"requirements": [
"numpy>=1.21.1"
]
}
},
"integration_manifest": {
"domain": "zha",
"name": "Zigbee Home Automation",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/zha",
"requirements": [
"bellows==0.33.1",
"pyserial==3.5",
"pyserial-asyncio==0.6",
"zha-quirks==0.0.79",
"zigpy-deconz==0.18.1",
"zigpy==0.50.3",
"zigpy-xbee==0.15.0",
"zigpy-zigate==0.9.2",
"zigpy-znp==0.8.2"
],
"usb": [
{
"vid": "10C4",
"pid": "EA60",
"description": "*2652*",
"known_devices": [
"slae.sh cc2652rb stick"
]
},
{
"vid": "1A86",
"pid": "55D4",
"description": "*sonoff*plus*",
"known_devices": [
"sonoff zigbee dongle plus v2"
]
},
{
"vid": "10C4",
"pid": "EA60",
"description": "*sonoff*plus*",
"known_devices": [
"sonoff zigbee dongle plus"
]
},
{
"vid": "10C4",
"pid": "EA60",
"description": "*tubeszb*",
"known_devices": [
"TubesZB Coordinator"
]
},
{
"vid": "1A86",
"pid": "7523",
"description": "*tubeszb*",
"known_devices": [
"TubesZB Coordinator"
]
},
{
"vid": "1A86",
"pid": "7523",
"description": "*zigstar*",
"known_devices": [
"ZigStar Coordinators"
]
},
{
"vid": "1CF1",
"pid": "0030",
"description": "*conbee*",
"known_devices": [
"Conbee II"
]
},
{
"vid": "10C4",
"pid": "8A2A",
"description": "*zigbee*",
"known_devices": [
"Nortek HUSBZB-1"
]
},
{
"vid": "0403",
"pid": "6015",
"description": "*zigate*",
"known_devices": [
"ZiGate+"
]
},
{
"vid": "10C4",
"pid": "EA60",
"description": "*zigate*",
"known_devices": [
"ZiGate"
]
},
{
"vid": "10C4",
"pid": "8B34",
"description": "*bv 2010/10*",
"known_devices": [
"Bitron Video AV2010/10"
]
}
],
"codeowners": [
"@dmulcahey",
"@adminiuga",
"@puddly"
],
"zeroconf": [
{
"type": "_esphomelib._tcp.local.",
"name": "tube*"
},
{
"type": "_zigate-zigbee-gateway._tcp.local.",
"name": "*zigate*"
}
],
"dependencies": [
"file_upload"
],
"after_dependencies": [
"onboarding",
"usb",
"zeroconf"
],
"iot_class": "local_polling",
"loggers": [
"aiosqlite",
"bellows",
"crccheck",
"pure_pcapy3",
"zhaquirks",
"zigpy",
"zigpy_deconz",
"zigpy_xbee",
"zigpy_zigate",
"zigpy_znp"
],
"is_built_in": true
},
"data": {
"ieee": "**REDACTED**",
"nwk": 11417,
"manufacturer": "_TZ3000_x3ewpzyr",
"model": "TS0001",
"name": "_TZ3000_x3ewpzyr TS0001",
"quirk_applied": false,
"quirk_class": "zigpy.device.Device",
"manufacturer_code": 4417,
"power_source": "Mains",
"lqi": 255,
"rssi": -55,
"last_seen": "2022-09-22T11:52:03",
"available": true,
"device_type": "Router",
"signature": {
"node_descriptor": "NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress|RxOnWhenIdle|MainsPowered|FullFunctionDevice: 142>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=True, *is_security_capable=False)",
"endpoints": {
"1": {
"profile_id": 260,
"device_type": "0x0100",
"in_clusters": [
"0x0000",
"0x0003",
"0x0004",
"0x0005",
"0x0006",
"0x0702",
"0x0b04",
"0xe000",
"0xe001"
],
"out_clusters": [
"0x000a",
"0x0019"
]
},
"242": {
"profile_id": 41440,
"device_type": "0x0061",
"in_clusters": [],
"out_clusters": [
"0x0021"
]
}
}
},
"active_coordinator": false,
"entities": [
{
"entity_id": "button.controlador_fuente_entrada_identifybutton",
"name": "_TZ3000_x3ewpzyr TS0001"
},
{
"entity_id": "light.fuente_entrada",
"name": "_TZ3000_x3ewpzyr TS0001"
},
{
"entity_id": "sensor.controlador_fuente_entrada_electricalmeasurement",
"name": "_TZ3000_x3ewpzyr TS0001"
},
{
"entity_id": "sensor.controlador_fuente_entrada_electricalmeasurementrmscurrent",
"name": "_TZ3000_x3ewpzyr TS0001"
},
{
"entity_id": "sensor.controlador_fuente_entrada_electricalmeasurementrmsvoltage",
"name": "_TZ3000_x3ewpzyr TS0001"
},
{
"entity_id": "sensor.controlador_fuente_entrada_smartenergysummation",
"name": "_TZ3000_x3ewpzyr TS0001"
}
],
"neighbors": [
{
"device_type": "Router",
"rx_on_when_idle": "On",
"relationship": "Parent",
"extended_pan_id": "**REDACTED**",
"ieee": "**REDACTED**",
"nwk": "0x64BE",
"permit_joining": "Unknown",
"depth": "1",
"lqi": "0"
},
{
"device_type": "Router",
"rx_on_when_idle": "On",
"relationship": "Sibling",
"extended_pan_id": "**REDACTED**",
"ieee": "**REDACTED**",
"nwk": "0x7D16",
"permit_joining": "Unknown",
"depth": "2",
"lqi": "0"
},
{
"device_type": "Router",
"rx_on_when_idle": "On",
"relationship": "Sibling",
"extended_pan_id": "**REDACTED**",
"ieee": "**REDACTED**",
"nwk": "0x1BCA",
"permit_joining": "Unknown",
"depth": "1",
"lqi": "30"
}
],
"endpoint_names": [
{
"name": "ON_OFF_LIGHT"
},
{
"name": "unknown 97 device_type of 0xa1e0 profile id"
}
],
"user_given_name": "Controlador fuente entrada",
"device_reg_id": "f01191ef534c547dc65c35ad42f23fe6",
"area_id": "jardin_delantero",
"cluster_details": {
"1": {
"device_type": {
"name": "ON_OFF_LIGHT",
"id": 256
},
"profile_id": 260,
"in_clusters": {
"0x0003": {
"endpoint_attribute": "identify",
"attributes": {},
"unsupported_attributes": {}
},
"0x0004": {
"endpoint_attribute": "groups",
"attributes": {},
"unsupported_attributes": {}
},
"0x0005": {
"endpoint_attribute": "scenes",
"attributes": {},
"unsupported_attributes": {}
},
"0x0006": {
"endpoint_attribute": "on_off",
"attributes": {
"0x0000": {
"attribute_name": "on_off",
"value": 1
},
"0x4001": {
"attribute_name": "on_time",
"value": 0
},
"0x4002": {
"attribute_name": "off_wait_time",
"value": 0
}
},
"unsupported_attributes": {
"0x4003": {
"attribute_name": "start_up_on_off"
}
}
},
"0x0702": {
"endpoint_attribute": "smartenergy_metering",
"attributes": {
"0x0000": {
"attribute_name": "current_summ_delivered",
"value": 6
},
"0x0200": {
"attribute_name": "status",
"value": 0
},
"0x0300": {
"attribute_name": "unit_of_measure",
"value": 0
},
"0x0303": {
"attribute_name": "summation_formatting",
"value": 0
},
"0x0306": {
"attribute_name": "metering_device_type",
"value": 0
}
},
"unsupported_attributes": {
"0x0400": {
"attribute_name": "instantaneous_demand"
},
"0x0302": {
"attribute_name": "divisor"
},
"0x0304": {
"attribute_name": "demand_formatting"
},
"0x0301": {
"attribute_name": "multiplier"
},
"0x0600": {
"attribute_name": "current_demand_delivered"
},
"0x0312": {
"attribute_name": "alternative_unit_of_measure"
}
}
},
"0x0b04": {
"endpoint_attribute": "electrical_measurement",
"attributes": {
"0x0505": {
"attribute_name": "rms_voltage",
"value": 234
},
"0x0508": {
"attribute_name": "rms_current",
"value": 0
},
"0x050b": {
"attribute_name": "active_power",
"value": 0
}
},
"unsupported_attributes": {
"0x050d": {
"attribute_name": "active_power_max"
},
"0x0300": {
"attribute_name": "ac_frequency"
},
"0x050f": {
"attribute_name": "apparent_power"
},
"0x0302": {
"attribute_name": "ac_frequency_max"
},
"0x0603": {
"attribute_name": "ac_current_divisor"
},
"0x0602": {
"attribute_name": "ac_current_multiplier"
},
"0x0605": {
"attribute_name": "ac_power_divisor"
},
"0x0507": {
"attribute_name": "rms_voltage_max"
},
"0x0604": {
"attribute_name": "ac_power_multiplier"
},
"0x0601": {
"attribute_name": "ac_voltage_divisor"
},
"0x050a": {
"attribute_name": "rms_current_max"
},
"0x0000": {
"attribute_name": "measurement_type"
},
"0x0403": {
"attribute_name": "power_divisor"
},
"0x0402": {
"attribute_name": "power_multiplier"
},
"0x0510": {
"attribute_name": "power_factor"
},
"0x050c": {
"attribute_name": "active_power_min"
},
"0x0600": {
"attribute_name": "ac_voltage_multiplier"
},
"0x0400": {
"attribute_name": "ac_frequency_multiplier"
},
"0x0401": {
"attribute_name": "ac_frequency_divisor"
},
"0x0500": {
"attribute_name": "instantaneous_voltage"
},
"0x0304": {
"attribute_name": "total_active_power"
},
"0x0305": {
"attribute_name": "total_reactive_power"
},
"0x0804": {
"attribute_name": "ac_reactive_power_overload"
},
"0x0502": {
"attribute_name": "instantaneous_active_current"
},
"0x0306": {
"attribute_name": "total_apparent_power"
},
"0x0800": {
"attribute_name": "ac_alarms_mask"
},
"0x0504": {
"attribute_name": "instantaneous_power"
},
"0x0803": {
"attribute_name": "ac_active_power_overload"
}
}
},
"0xe000": {
"endpoint_attribute": null,
"attributes": {},
"unsupported_attributes": {}
},
"0xe001": {
"endpoint_attribute": null,
"attributes": {},
"unsupported_attributes": {}
},
"0x0000": {
"endpoint_attribute": "basic",
"attributes": {
"0x0004": {
"attribute_name": "manufacturer",
"value": "_TZ3000_x3ewpzyr"
},
"0x0005": {
"attribute_name": "model",
"value": "TS0001"
}
},
"unsupported_attributes": {}
}
},
"out_clusters": {
"0x0019": {
"endpoint_attribute": "ota",
"attributes": {},
"unsupported_attributes": {}
},
"0x000a": {
"endpoint_attribute": "time",
"attributes": {},
"unsupported_attributes": {
"0x0000": {
"attribute_name": "time"
}
}
}
}
},
"242": {
"device_type": {
"name": "unknown",
"id": 97
},
"profile_id": 41440,
"in_clusters": {},
"out_clusters": {
"0x0021": {
"endpoint_attribute": "green_power",
"attributes": {},
"unsupported_attributes": {}
}
}
}
}
}
}
Additional logs
Additional context
And here comes the new TS0001
flavor...
Can you try with that quirk?
class Switch_1G_Metering(EnchantedDevice, CustomDevice):
"""Tuya 1 gang switch module with power metering."""
signature = {
MODEL: "TS0001",
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 0x0702, 0x0b04, 57344, 57345]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
TuyaZBE000Cluster.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# device_version=0
# input_clusters=[]
# output_clusters=[33]>
242: {
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
TuyaZBE000Cluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
242: {
PROFILE_ID: 41440,
DEVICE_TYPE: 97,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}
You will need to add the new imports:
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.smartenergy import Metering
Once the quirk is available, you have to remove the device from HA and pair it again.
Related to: #1775
is there a link to the device?
how do i add the imports?
Copy in your local quirk folder the current file:
- https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts000x.py
Add the imports statements at the beginning of the file. And add the new quirk at the bottom of file.
Save changes, restart HA and repair the device.
thanks i got it working but its not the right quirk for my device.. :( i opend an https://github.com/zigpy/zha-device-handlers/issues/1968
Copy in your local quirk folder the current file:
- https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts000x.py
Add the imports statements at the beginning of the file. And add the new quirk at the bottom of file.
Save changes, restart HA and repair the device.
Hi,
thank you for the answer. I have the same problem like redQs.
I created a folder in config/custom_zha_quirks/
In there is a file named "ts000x.py" where I copied all the content from the provided link.
Since I'm doing this the first time, I have a few questions:
Add the imports statements at the beginning of the file:
- what do I have to enter here? I simply don't have any idea? In which lines which information?
And add the new quirk at the bottom of file.
- I think, this will get clear, when I now which information where to enter.
-> Is there a kind of howto available somewhere?
Thank you, c
All the info is in my previous comment:
- https://github.com/zigpy/zha-device-handlers/issues/1780#issuecomment-1254814541
Yes, thank you....but I'm really sorry. I still don't get it. My last programming was BASIC in school and 8088 Assembler, which is also some time ago.
Would be really nice, if you can explain, what to enter where and where I can find this information in HA. I'm using the Zigbee integration from HA.
From my understanding, I have to enter "cluster_id" or everything which is in black colour? And, after I found, entered the information, copy everything and put it at the end of the script????
Thank you, I really appreciate if you can help me...
thx c
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.