Overly long data attribute received as 0 #3561
-
Hello folks, I'm working on a custom quirk for a variant of a Tuya DIN power meter ("_TZE200_rhblgy0z", "TS0601"). However, where this variant differs is in the energy data, it still comes in the
The data block I'm not sure if it's because the data block is longer than the biggest unsigned int in zigpy/types/basic.py (which is 64 bits) Thanks for any pointer! I'm pulling my hair out! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Can you post a link to your full quirk? |
Beta Was this translation helpful? Give feedback.
-
Ok, so looking at the Z2M converter, it looks like that's actually a string? Maybe try |
Beta Was this translation helpful? Give feedback.
-
You're right, it appears to be a |
Beta Was this translation helpful? Give feedback.
-
Addendum: While poking around with types, I've stumbled upon the So, for anyone finding this on their quest for solutions, here is what differs in my quirk vs the stock from zhaquirks.tuya import TuyaManufClusterAttributes, TuyaData, TuyaOnOff, TuyaSwitch
"""Var01 Power Meter Attributes"""
TUYA_VAR01_TOTAL_ENERGY_ATTR = 0x0201
TUYA_VAR01_VOLTAGE_CURRENT_ATTR = 0x0006
class TuyaVar01ManufClusterDinPower(TuyaManufClusterAttributes):
"""Manufacturer Specific Cluster of the MatSee Power Meter device."""
attributes = {
TUYA_VAR01_TOTAL_ENERGY_ATTR: ("energy_delivered", TuyaData, True),
TUYA_VAR01_TOTAL_ENERGY_ATTR: ("energy_received", TuyaData, True),
TUYA_VAR01_VOLTAGE_CURRENT_ATTR: ("voltage_current", t.uint64_t, True),
}
def _update_attribute(self, attrid, value):
super()._update_attribute(attrid, value)
if attrid == TUYA_VAR01_TOTAL_ENERGY_ATTR:
energy_delivered = int.from_bytes(value.raw[1:5], byteorder='big', signed=False)
energy_received = int.from_bytes(value.raw[9:], byteorder='big', signed=False)
self.endpoint.smartenergy_metering.energy_deliver_reported(energy_delivered /100)
self.endpoint.smartenergy_metering.energy_receive_reported(energy_received /100)
elif attrid == TUYA_VAR01_VOLTAGE_CURRENT_ATTR:
power = value & 0x000000000000FFFF
current = (value & 0x000000FFFF000000) >> 24
tension = value >> 48
self.endpoint.electrical_measurement.power_reported(power)
self.endpoint.electrical_measurement.current_reported(current)
self.endpoint.electrical_measurement.voltage_reported(tension)
class TuyaVar01PowerMeter(TuyaSwitch):
"""WhiteLabel Power Meter Device - TAC2161C"""
def __init__(self, *args, **kwargs):
"""Init device."""
self.switch_bus = Bus()
super().__init__(*args, **kwargs)
signature = {
# "node_descriptor": "<NodeDescriptor byte1=1 byte2=64 mac_capability_flags=142 manufacturer_code=4098
# maximum_buffer_size=82 maximum_incoming_transfer_size=82 server_mask=11264
# maximum_outgoing_transfer_size=82 descriptor_capability_field=0>",
# device_version=1
# input_clusters=[0x0000, 0x0004, 0x0005, 0xef00]
# output_clusters=[0x000a, 0x0019]
MODELS_INFO: [("_TZE200_rhblgy0z", "TS0601")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=51
# device_version=1
# input_clusters=[0, 4, 5, 61184]
# output_clusters=[10, 25]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaManufClusterAttributes.cluster_id,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
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.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaVar01ManufClusterDinPower,
TuyaElectricalMeasurement,
TuyaPowerMeasurement,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
242: {
PROFILE_ID: zgp.PROFILE_ID,
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
INPUT_CLUSTERS: [],
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
}
} |
Beta Was this translation helpful? Give feedback.
Ok, so looking at the Z2M converter, it looks like that's actually a string?
See: https://github.com/Koenkk/zigbee-herdsman-converters/blob/8e3ed7c41eaa4d008d7c459ee98c8353b96423bc/src/devices/tuya.ts#L6222
Then: https://github.com/Koenkk/zigbee-herdsman-converters/blob/8e3ed7c41eaa4d008d7c459ee98c8353b96423bc/src/lib/tuya.ts#L622
Maybe try
t.CharacterString
similar to this?