zha-device-handlers icon indicating copy to clipboard operation
zha-device-handlers copied to clipboard

[Device Support Request] Neo Tuya Temperature, Humidity and Illumination Sensor TS0201 _TZ3000_qaaysllp

Open blakadder opened this issue 4 years ago • 103 comments
trafficstars

https://zigbee.blakadder.com/Neo_NAS-TH02B.html device in question

Is your feature request related to a problem? Please describe. ZHA recognises the illumination sensor and battery. Temperature and Humidity don't have an obvious endpoint.

Describe the solution you'd like Add a quirk for temperature and humidity sensors.

Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line.

[0x0000:zdo] ZDO request ZDOCmd.Mgmt_Permit_Joining_req: [60, <Bool.false: 0>]
Device 0x8c8d (84:2e:14:ff:fe:e5:4b:50) left the network
[0x2d91:2:0x0702] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=159 command_id=Command.Report_Attributes>
[0x2d91:2:0x0702] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=uint48_t, value=1>), Attribute(attrid=1024, value=<TypeValue type=int24s, value=0>), Attribute(attrid=512, value=<TypeValue type=bitmap8, value=bitmap8.0>), Attribute(attrid=256, value=<TypeValue type=uint48_t, value=281474976710655>), Attribute(attrid=258, value=<TypeValue type=uint48_t, value=281474976710655>)]]
[0x2d91:2:0x0702] Attribute report received: current_summ_delivered=1, instantaneous_demand=0, status=0, current_tier1_summ_delivered=281474976710655, current_tier2_summ_delivered=281474976710655
Device 0x8c8d (84:2e:14:ff:fe:e5:4b:50) joined the network
[0x8c8d] Requesting 'Node Descriptor'
Tries remaining: 2
[0x8c8d] Extending timeout for 0x0f request
Device 0x8c8d (84:2e:14:ff:fe:e5:4b:50) joined the network
Skip initialization for existing device 84:2e:14:ff:fe:e5:4b:50
[0x8c8d:zdo] ZDO request ZDOCmd.Device_annce: [0x8C8D, 84:2e:14:ff:fe:e5:4b:50, 128]
[0x8c8d] Node Descriptor: NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)
[0x8c8d] Discovering endpoints
Tries remaining: 3
[0x8c8d] Extending timeout for 0x11 request
[0x8c8d] Discovered endpoints: [1]
[0x8c8d:1] Discovering endpoint information
Tries remaining: 3
[0x8c8d] Extending timeout for 0x13 request
Received frame on uninitialized device 84:2e:14:ff:fe:e5:4b:50 endpoint 1 for cluster: 1024
[0x8c8d:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=262, device_version=1, input_clusters=[0, 1, 1024, 57346], output_clusters=[25, 10])
Unknown cluster 57346
[0x8c8d] Extending timeout for 0x15 request
[0x8c8d:zdo] ZDO request ZDOCmd.Node_Desc_req: [0x0000]
[0x8c8d:zdo] Unsupported ZDO request:ZDOCmd.Node_Desc_req
Received frame on uninitialized device 84:2e:14:ff:fe:e5:4b:50 endpoint 1 for cluster: 1024
[0x8c8d:1:0x0000] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=21 command_id=Command.Read_Attributes_rsp>
[0x8c8d:1] Manufacturer: _TZ3000_qaaysllp
[0x8c8d:1] Model: TS0201
Checking quirks for _TZ3000_qaaysllp TS0201 (84:2e:14:ff:fe:e5:4b:50)
Considering <class 'zhaquirks.xbee.xbee_io.XBeeSensor'>
Fail because endpoint list mismatch: {232, 230} {1}
Considering <class 'zhaquirks.xbee.xbee3_io.XBee3Sensor'>
Fail because endpoint list mismatch: {232, 230} {1}
Considering <class 'zhaquirks.smartthings.tag_v4.SmartThingsTagV4'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.smartthings.multi.SmartthingsMultiPurposeSensor'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.netvox.z308e3ed.Z308E3ED'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.gledopto.soposhgu10.SoposhGU10'>
Fail because endpoint list mismatch: {11, 13} {1}
Considering <class 'bellows.zigbee.application.EZSPCoordinator'>
Fail because device_type mismatch on at least one endpoint
device - 0x8C8D:84:2e:14:ff:fe:e5:4b:50 entering async_device_initialized - is_new_join: True
device - 0x8C8D:84:2e:14:ff:fe:e5:4b:50 has joined the ZHA zigbee network
[0x8C8D](TS0201): started configuration
[0x8C8D:ZDO](TS0201): 'async_configure' stage succeeded
[0x8c8d] Extending timeout for 0x17 request
[0x8c8d] Extending timeout for 0x19 request
[0x8c8d] Extending timeout for 0x1b request
[0x8c8d:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=55 command_id=Command.Report_Attributes>
[0x8c8d:1:0x0400] ZCL request 0x000a: [[Attribute(attrid=61441, value=<TypeValue type=uint16_t, value=50>)]]
[0x8c8d:1:0x0400] Attribute report received: 61441=50
[0x8C8D:1:0x0400]: bound 'illuminance' cluster: Status.SUCCESS
[0x8c8d] Extending timeout for 0x1e request
[0x8C8D:1:0x0001]: bound 'power' cluster: Status.SUCCESS
[0x8c8d] Extending timeout for 0x20 request
[0x8C8D:1:0x0000]: bound 'basic' cluster: Status.SUCCESS
[0x8C8D:1:0x0000]: finished channel configuration
[0x8c8d] Extending timeout for 0x22 request
[0x8c8d:1:0xe002] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=56 command_id=Command.Report_Attributes>
[0x8c8d:1:0xe002] ZCL request 0x000a: [[Attribute(attrid=53258, value=<TypeValue type=int16s, value=40>)]]
[0x8c8d:1:0xe002] Attribute report received: 53258=40
[0x8c8d:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=30 command_id=Command.Default_Response>
[0x8C8D:1:0x0400]: reporting 'measured_value' attr on 'illuminance' cluster: 30/900/1: Result: '[6, <Status.UNSUP_GENERAL_COMMAND: 130>]'
[0x8C8D:1:0x0400]: finished channel configuration
[0x8c8d:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=32 command_id=Command.Default_Response>
[0x8C8D:1:0x0001]: reporting 'battery_voltage' attr on 'power' cluster: 3600/10800/1: Result: '[6, <Status.UNSUP_GENERAL_COMMAND: 130>]'
[0x8c8d] Extending timeout for 0x25 request
[0x8C8D:1:0x0019]: bound 'ota' cluster: Status.SUCCESS
[0x8C8D:1:0x0019]: finished channel configuration
[0x8c8d:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=37 command_id=Command.Default_Response>
[0x8C8D:1:0x0001]: reporting 'battery_percentage_remaining' attr on 'power' cluster: 3600/10800/1: Result: '[6, <Status.UNSUP_GENERAL_COMMAND: 130>]'
[0x8C8D:1:0x0001]: finished channel configuration
[0x8C8D:1:0x0400]: 'async_configure' stage succeeded
[0x8C8D:1:0x0001]: 'async_configure' stage succeeded
[0x8C8D:1:0x0000]: 'async_configure' stage succeeded
[0x8C8D:1:0x0019]: 'async_configure' stage succeeded
[0x8C8D](TS0201): completed configuration
[0x8C8D](TS0201): stored in registry: ZhaDeviceEntry(name='_TZ3000_qaaysllp TS0201', ieee='84:2e:14:ff:fe:e5:4b:50', last_seen=1619038751.5431523)
[0x8C8D](TS0201): started initialization
[0x8C8D:ZDO](TS0201): 'async_initialize' stage succeeded
[0x8C8D:1:0x0400]: initializing channel: from_cache: False
[0x8c8d] Extending timeout for 0x27 request
[0x8C8D:1:0x0001]: initializing channel: from_cache: False
[0x8c8d] Extending timeout for 0x29 request
[0x8C8D:1:0x0000]: initializing channel: from_cache: False
[0x8C8D:1:0x0000]: finished channel configuration
[0x8C8D:1:0x0019]: initializing channel: from_cache: False
[0x8C8D:1:0x0019]: finished channel configuration
[0x8c8d:1:0xe002] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=57 command_id=Command.Report_Attributes>
[0x8c8d:1:0xe002] ZCL request 0x000a: [[Attribute(attrid=53259, value=<TypeValue type=int16s, value=10>)]]
[0x8c8d:1:0xe002] Attribute report received: 53259=10
[0x8c8d:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=39 command_id=Command.Read_Attributes_rsp>
[0x8c8d:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=41 command_id=Command.Read_Attributes_rsp>
[0x8C8D:1:0x0400]: finished channel configuration
[0x8c8d] Extending timeout for 0x2c request
[0x8c8d:1:0xe002] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=58 command_id=Command.Report_Attributes>
[0x8c8d:1:0xe002] ZCL request 0x000a: [[Attribute(attrid=53261, value=<TypeValue type=int16s, value=90>)]]
[0x8c8d:1:0xe002] Attribute report received: 53261=90
[0x8c8d:1:0x0001] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=44 command_id=Command.Read_Attributes_rsp>
[0x8C8D:1:0x0001]: finished channel configuration
[0x8C8D:1:0x0400]: 'async_initialize' stage succeeded
[0x8C8D:1:0x0001]: 'async_initialize' stage succeeded
[0x8C8D:1:0x0000]: 'async_initialize' stage succeeded
[0x8C8D:1:0x0019]: 'async_initialize' stage succeeded
[0x8C8D](TS0201): power source: Battery or Unknown
[0x8C8D](TS0201): completed initialization
[0x8c8d:1:0xe002] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=59 command_id=Command.Report_Attributes>
[0x8c8d:1:0xe002] ZCL request 0x000a: [[Attribute(attrid=53262, value=<TypeValue type=int16s, value=20>)]]
[0x8c8d:1:0xe002] Attribute report received: 53262=20
[0x8c8d:1:0xe002] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=60 command_id=Command.Report_Attributes>
[0x8c8d:1:0xe002] ZCL request 0x000a: [[Attribute(attrid=53254, value=<TypeValue type=enum8, value=enum8.undefined_0x02>)]]
[0x8c8d:1:0xe002] Attribute report received: 53254=2
[0x8c8d:1:0xe002] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=61 command_id=Command.Report_Attributes>
[0x8c8d:1:0xe002] ZCL request 0x000a: [[Attribute(attrid=53263, value=<TypeValue type=enum8, value=enum8.undefined_0x02>)]]
[0x8c8d:1:0xe002] Attribute report received: 53263=2
[0x8c8d:1:0xe002] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=62 command_id=Command.Report_Attributes>
[0x8c8d:1:0xe002] ZCL request 0x000a: [[Attribute(attrid=53264, value=<TypeValue type=uint8_t, value=0>)]]
[0x8c8d:1:0xe002] Attribute report received: 53264=0
[0x2fa3:39:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=110 command_id=Command.Report_Attributes>
[0x2fa3:39:0x0400] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=uint16_t, value=5657>)]]
[0x2fa3:39:0x0400] Attribute report received: measured_value=5657
[0x8c8d:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=65 command_id=Command.Report_Attributes>
[0x8c8d:1:0x0400] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=uint16_t, value=15799>)]]
[0x8c8d:1:0x0400] Attribute report received: measured_value=15799
[0x8c8d:1:0x000a] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=False disable_default_response=False> manufacturer=None tsn=66 command_id=Command.Read_Attributes>
[0x8c8d:1:0x000a] ZCL request 0x0000: [[7]]
[0x8c8d:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=67 command_id=Command.Report_Attributes>
[0x8c8d:1:0x0400] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=uint16_t, value=15799>)]]
[0x8c8d:1:0x0400] Attribute report received: measured_value=15799
[0x8c8d:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=69 command_id=Command.Report_Attributes>
[0x8c8d:1:0x0400] ZCL request 0x000a: [[Attribute(attrid=0, value=<TypeValue type=uint16_t, value=15799>)]]
[0x8c8d:1:0x0400] Attribute report received: measured_value=15799

Additional context Add any other context or screenshots about the feature request here.

blakadder avatar Apr 21 '21 21:04 blakadder

Same here, according to https://github.com/zigpy/zha-device-handlers/blob/dev/README.md, quirk is based on a Node Descriptor and a Simple Descriptor :

[0x8c8d:1] Discovered endpoint information: SizePrefixedSimpleDescriptor(endpoint=1, profile=260, device_type=262, device_version=1, input_clusters=[0, 1, 1024, 57346], output_clusters=[25, 10])

Each clusters must be associated, at Home Assistant startup, values from identified clusters are displayed :

2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0x0000] Attribute id: 4 value: _TZ3000_qaaysllp
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0x0000] Attribute id: 5 value: TS0201
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0x0000] Attribute id: 4 value: _TZ3000_qaaysllp
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0x0000] Attribute id: 5 value: TS0201
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0x0001] Attribute id: 32 value: 30
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53258 value: 40
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53259 value: 10
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53261 value: 90
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53262 value: 20
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53254 value: 2
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53264 value: 0
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0x0001] Attribute id: 33 value: 120
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53263 value: 2
2021-05-18 23:06:23 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0x0400] Attribute id: 0 value: 11762

0x0400 is input_cluster 1024 11762 = 15 lux (no idea how value is converted)

1024 -> IlluminanceMeasurement.cluster_id

I think 57346 cluster include both temperature and humidity values. Quirk readme contains a lot of other usefull infos.

NB : Sensor is on blakadder list : https://zigbee.blakadder.com/Neo_NAS-TH02B.html

Vebryn avatar May 18 '21 21:05 Vebryn

According to https://zigbeealliance.org/wp-content/uploads/2019/12/07-5123-06-zigbee-cluster-library-specification.pdf

Cluster 0x0000 Basic (p102) :

0x0004 ManufacturerName
0x0005 ModelIdentifier

Cluster 0x0001 Power Configuration (p110) :

0x0020 BatteryVoltage
0x0021 BatteryPercentageRemaining

Cluster 0x400 Illuminance Measurement (p281) :

0x0000 MeasuredValue = 10,000 x log10Illuminance + 1

Clusters related to temp and humidity (p278) :

0x0402 Temperature Measurement 
0x0405 Relative Humidity Measurement

These clusters are not used by device. Instead we have 0xe002 cluster with 7 attributes :

attribute dec value hex value bin value
d006 2 2 0010
d00a 40 28 0010 1000
d00b 10 a 1010
d00d 90 5a 0101 1010
d00e 20 14 0001 0100
d00f 2 2 0010
d010 0 0 0

How to correlate theses values with temp and humidity ?

Vebryn avatar May 19 '21 07:05 Vebryn

Device seems based on CHT8305 sensor

uint CHT8305_get_temp_humi(float *t, float *h)
{
	CHT8305_read_reg(CHT8305_REG_TEMP, 4);
	unsigned int th, tl, hh, hl;

	th = buf[0];
	tl = buf[1];

	hh = buf[2];
	hl = buf[3];

	(*t) = (th << 8 | tl) * 165.0 / 65535.0 - 40.0;
	(*h) = (hh << 8 | hl) * 100.0 / 65535.0;
	return 1;
}

Vebryn avatar May 19 '21 12:05 Vebryn

21.3°C and 56.3%, 20.2°C and 43.6%, using C°/°F switch, debug remains the same :

2021-05-19 21:06:00 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53258 value: 40
2021-05-19 21:06:00 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53259 value: 10
2021-05-19 21:06:00 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53261 value: 90
2021-05-19 21:06:00 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53262 value: 20
2021-05-19 21:06:00 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53254 value: 2
2021-05-19 21:06:00 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53264 value: 0
2021-05-19 21:06:00 DEBUG (MainThread) [zigpy.appdb] [0x920d:1:0xe002] Attribute id: 53263 value: 2

According to zigbee2mqtt new devices and new tuya devices pages, I got raw data.

Zigbee2MQTT:debug 2021-05-20 21:17:03: Received Zigbee message from '0x847127fffefe7e2a', type 'raw', cluster '57346', data '{"data":[8,42,10,10,208,41,40,0],"type":"Buffer"}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2021-05-20 21:17:03: No converter available for 'MODEL' with cluster '57346' and type 'raw' and data '{"data":[8,42,10,10,208,41,40,0],"type":"Buffer"}'
Zigbee2MQTT:debug 2021-05-20 21:17:05: Received Zigbee message from '0x847127fffefe7e2a', type 'raw', cluster '57346', data '{"data":[8,43,10,11,208,41,10,0],"type":"Buffer"}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2021-05-20 21:17:05: No converter available for 'MODEL' with cluster '57346' and type 'raw' and data '{"data":[8,43,10,11,208,41,10,0],"type":"Buffer"}'
Zigbee2MQTT:debug 2021-05-20 21:17:07: Received Zigbee message from '0x847127fffefe7e2a', type 'raw', cluster '57346', data '{"data":[8,44,10,13,208,41,90,0],"type":"Buffer"}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2021-05-20 21:17:07: No converter available for 'MODEL' with cluster '57346' and type 'raw' and data '{"data":[8,44,10,13,208,41,90,0],"type":"Buffer"}'
Zigbee2MQTT:debug 2021-05-20 21:17:09: Received Zigbee message from '0x847127fffefe7e2a', type 'raw', cluster '57346', data '{"data":[8,45,10,14,208,41,20,0],"type":"Buffer"}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2021-05-20 21:17:09: No converter available for 'MODEL' with cluster '57346' and type 'raw' and data '{"data":[8,45,10,14,208,41,20,0],"type":"Buffer"}'
Zigbee2MQTT:debug 2021-05-20 21:17:11: Received Zigbee message from '0x847127fffefe7e2a', type 'raw', cluster '57346', data '{"data":[8,46,10,6,208,48,2],"type":"Buffer"}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2021-05-20 21:17:11: No converter available for 'MODEL' with cluster '57346' and type 'raw' and data '{"data":[8,46,10,6,208,48,2],"type":"Buffer"}'
Zigbee2MQTT:debug 2021-05-20 21:17:13: Received Zigbee message from '0x847127fffefe7e2a', type 'raw', cluster '57346', data '{"data":[8,47,10,15,208,48,2],"type":"Buffer"}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2021-05-20 21:17:13: No converter available for 'MODEL' with cluster '57346' and type 'raw' and data '{"data":[8,47,10,15,208,48,2],"type":"Buffer"}'
Zigbee2MQTT:debug 2021-05-20 21:17:15: Received Zigbee message from '0x847127fffefe7e2a', type 'raw', cluster '57346', data '{"data":[8,48,10,16,208,32,0],"type":"Buffer"}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2021-05-20 21:17:15: No converter available for 'MODEL' with cluster '57346' and type 'raw' and data '{"data":[8,48,10,16,208,32,0],"type":"Buffer"}'

My assumption based on Tuya developper guide :

ver seq cmd length + data check
[8, 80, 10, 10,208,41,40, 0]
[8, 81, 10, 11,208,41,10, 0]
[8, 82, 10, 13,208,41,90, 0]
[8, 83, 10, 14,208,41,20, 0]
[8, 84, 10, 6,208,48, 2]
[8, 85, 10, 15,208,48, 2]
[8, 86, 10, 16,208,32, 0]

Vebryn avatar May 19 '21 19:05 Vebryn

Tuya cluster is 0xEF00 according to https://github.com/Koenkk/zigbee-herdsman/blob/master/src/zcl/definition/cluster.ts What is 0xe002 cluster ? Does Tuya change its cluster id ? What is 0x55aa header into https://developer.tuya.com/en/docs/iot/tuya-zigbee-module-uart-communication-protocol?id=K9ear5khsqoty#title-2-Frame%20format%20description ?

So many questions ! I'm wondering if it will be easier to debug with a zigbee gateway and a sniffer.

Vebryn avatar May 24 '21 10:05 Vebryn

It could simply be NEO's special formatting, some manufacturers tend to bend the Tuya spec and tack on their own

blakadder avatar May 24 '21 10:05 blakadder

Think you're right, hope sensor will periodically send its data.

Using Zigbee2MQTT, just found meaning of some messages :

Humidity alarm (>90%, not sure about this threshold)

0x08 0x3e 0x0a 0x0f 0xd0 0x30 0x01

Humidity alarm back to normal

0x08 0x4b 0x0a 0x0f 0xd0 0x30 0x02

Back to normal alarm is also send after pairing. Following message may indicate a Temperature alarm (4th byte 0x06 instead of 0x0f) :

0x08 0x69 0x0a 0x06 0xd0 0x30 0x02

Vebryn avatar May 24 '21 21:05 Vebryn

I'm also interested on getting the temperature and humidity of this sensor. Please let me know if I can provide any additional data

marciogranzotto avatar Jun 07 '21 14:06 marciogranzotto

What I find strange is that the temperature and humidity show up great on the SmartLife app, but the illuminance always shows at 0 there. I wonder if the Tuya app doesn't change the device to temp/humidity mode or something...

marciogranzotto avatar Jun 11 '21 20:06 marciogranzotto

According to https://www.aliexpress.com/item/1005002434961203.html?spm=a2g0s.9042311.0.0.15874c4dZYVRAj

Note: when pair with the app, some function will be not working, please don't worry, it is because the gateway needs to be updated, tuya will send the update firmware on the end of May, please don't open dispute. And if you want to quick install the update firmware, please contact us and tell us your zigbee gateway ID, we will send to Tuya and you will receive the firmware sooner.

This is 0 illuminance issue.

What kind of Zigbee dongle do you have ? You can use it to sniff Tuya bridge data. I think Tuya bridge send a NEO specific data to query temp and humidity.

Vebryn avatar Jun 11 '21 21:06 Vebryn

@Vebryn I'm using a CC2531 with ZHA, but I have a Zemismart Wireless Zigbee hub that I'm not using. I can try to sniff it, but I have no idea on how to do it

marciogranzotto avatar Jun 12 '21 20:06 marciogranzotto

@Vebryn I'm using a CC2531 with ZHA, but I have a Zemismart Wireless Zigbee hub that I'm not using. I can try to sniff it, but I have no idea on how to do it

Great, there is some tutorials to flash CC2531 dongle and use Wireshark to sniff Zigbee data.

  1. flash cc2531
  2. try sniffing data
  3. unpair neo device
  4. start sniffing and pair neo device

We will see queries from tuya bridge and responses. It will help implementing neo device handler.

Vebryn avatar Jun 15 '21 07:06 Vebryn

image look at this guy, happly reporting temperature on 0x0402!

I'm trying to decrypt the logs, but I don't have any experience with it. Here's the logs of adding the device to my Zermismart hub and it reporting back temperature and humidity: adding_and_getting_values.zip

marciogranzotto avatar Jun 15 '21 21:06 marciogranzotto

Great job ! Hopelessly trace is encrypted, can you provide related keys ?

Best regards.

Vebryn avatar Jun 16 '21 07:06 Vebryn

If pairing one device you is having the network key in the sniff only look for transport key short after the device have joining the network and adding it in the key table for Zigbee in wireshark.

MattWestb avatar Jun 16 '21 09:06 MattWestb

oh, I simply add 5a6967426565416c6c69616e63653039 key from this link

Vebryn avatar Jun 16 '21 09:06 Vebryn

Yes that is working if not using Zigbee 3 and not updating the network key and using the well known one :-))

Dont being surprised is some neighbor is starting controlling your device !!

MattWestb avatar Jun 16 '21 10:06 MattWestb

Here is a focus on Report Attributes, first 8 packets appears after device inclusion (Tuya and non Tuya gateway) :

report_attributes

Vebryn avatar Jun 16 '21 10:06 Vebryn

Device doen't announce temp and hum capabilities,

image

Does Zigpy only consider reports from previously announced capabilities ?

Tuya gateway also force reading on default clusters :

image

Are we able to force reading using Zigpy ?

Vebryn avatar Jun 16 '21 11:06 Vebryn

Add the missing cluster in the quirk that is for :-))

MattWestb avatar Jun 16 '21 11:06 MattWestb

As I remember, I already try forcing temp and hum like @wdesponts I will check again and put my quirk here

Best regards.

Vebryn avatar Jun 16 '21 11:06 Vebryn

tuya devices is normally using "tuya cluster" but they is not always being presented on many TRVs so the quirk is adding it so the system is knowing it can / shall being used.

I dont knowing how to do it but in the end it shall being added in the replacement part of the quirk.

MattWestb avatar Jun 16 '21 11:06 MattWestb

TS0201 do not use the 0xef00 Tuya cluster, and indeed TS0201 use the standard cluster to provide Temperature and Humidity

pipiche38 avatar Jun 16 '21 11:06 pipiche38

Indeed but i was only pointing in the direction for finding how to adding missing clusters in on quirk ;-))

MattWestb avatar Jun 16 '21 11:06 MattWestb

So, I tried to create a quirk just adding the clusters, but it didn't work. Then I realized that temperature and humidity are on endpoint 2, not 1! image

So I tried:

class TemperatureHumidtyIlluminanceSensor(CustomDevice):
    """Neo Tuya Temperature, Humidity and Illumination Sensor."""

    signature = {
        #  <SimpleDescriptor endpoint=1, profile=260, device_type=262
        #  device_version=1
        #  input_clusters=[0, 1, 1024, 57346]
        #  output_clusters=[25, 10]>
        MODELS_INFO: [("_TZ3000_qaaysllp", "TS0201")],
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: DeviceType.LIGHT_SENSOR,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    PowerConfiguration.cluster_id,
                    IlluminanceMeasurement.cluster_id,
                    0xE002,
                ],
                OUTPUT_CLUSTERS: [
                    Time.cluster_id,
                    Ota.cluster_id,
                ],
            }
        },
    }

    replacement = {
        ENDPOINTS: {
            1: {
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    PowerConfiguration.cluster_id,
                    IlluminanceMeasurement.cluster_id,
                    0xE002,
                ],
                OUTPUT_CLUSTERS: [
                    Time.cluster_id,
                    Ota.cluster_id,
                ],
            },
            2: {
                INPUT_CLUSTERS: [
                    TemperatureMeasurement.cluster_id,
                    RelativeHumidity.cluster_id,
                ]
            },
        },
    }

However, I get this error on Home Assitant:

2021-06-16 13:12:06 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry TI CC2531 USB CDC, s/n: __0X00124B001CD4B395 - Texas Instruments for zha
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 293, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/usr/src/homeassistant/homeassistant/components/zha/__init__.py", line 102, in async_setup_entry
await zha_gateway.async_initialize()
File "/usr/src/homeassistant/homeassistant/components/zha/core/gateway.py", line 157, in async_initialize
self.application_controller = await app_controller_cls.new(
File "/usr/local/lib/python3.8/site-packages/zigpy/application.py", line 64, in new
await app._load_db()
File "/usr/local/lib/python3.8/site-packages/zigpy/application.py", line 56, in _load_db
await self._dblistener.load()
File "/usr/local/lib/python3.8/site-packages/zigpy/appdb.py", line 473, in load
device = zigpy.quirks.get_device(device)
File "/usr/local/lib/python3.8/site-packages/zigpy/quirks/__init__.py", line 42, in get_device
return _DEVICE_REGISTRY.get_device(device)
File "/usr/local/lib/python3.8/site-packages/zigpy/quirks/registry.py", line 148, in get_device
device = candidate(device._application, device.ieee, device.nwk, device)
File "/usr/local/lib/python3.8/site-packages/zigpy/quirks/__init__.py", line 96, in __init__
self.add_endpoint(endpoint_id, replace_device=replaces)
File "/usr/local/lib/python3.8/site-packages/zigpy/quirks/__init__.py", line 111, in add_endpoint
ep = custom_ep_type(self, endpoint_id, replacement_data, replace_device)
File "/usr/local/lib/python3.8/site-packages/zigpy/quirks/__init__.py", line 126, in __init__
set_device_attr(SIG_EP_PROFILE)
File "/usr/local/lib/python3.8/site-packages/zigpy/quirks/__init__.py", line 124, in set_device_attr
setattr(self, attr, getattr(replace_device[endpoint_id], attr))
File "/usr/local/lib/python3.8/site-packages/zigpy/device.py", line 359, in __getitem__
return self.endpoints[key]
KeyError: 2

looks like I can't add a replacement for endpoint 2 if it's not present on the signature. And I think I can't just add it to the signature since the device doesn't report that endpoint on discovery...

marciogranzotto avatar Jun 16 '21 16:06 marciogranzotto

I think its also possible making one virtual end point in one quirk but how to do that i think only @Adminiuga is knowing.

MattWestb avatar Jun 16 '21 16:06 MattWestb

Yeah, i don't think quirk could add non existing endpoints. Tuyas are such abomination.

You could try to define a custom device and override handle_message() method and if src_ep == 2 replace it with 1 and call original handle_message.

Then you could add humidity and temp clusters to the 1st endpoints in replacement

Adminiuga avatar Jun 16 '21 17:06 Adminiuga

Hah! Success! image

I added the new endpoint in the init function:

class TemperatureHumidtyIlluminanceSensor(CustomDevice):
    """Neo Tuya Temperature, Humidity and Illumination Sensor."""

    def __init__(self, *args, **kwargs):
        """Init."""
        super().__init__(*args, **kwargs)
        # Add missing endpoint 2
        sensor_endpoint = self.add_endpoint(2)
        sensor_endpoint.status = zigpy.endpoint.Status.ZDO_INIT
        sensor_endpoint.profile_id = zha.PROFILE_ID
        sensor_endpoint.device_type = DeviceType.TEMPERATURE_SENSOR
        sensor_endpoint.add_input_cluster(
            TemperatureMeasurement.cluster_id, TemperatureMeasurement(endpoint=sensor_endpoint, is_server=True)
        )
        sensor_endpoint.add_input_cluster(RelativeHumidity.cluster_id, RelativeHumidity(endpoint=sensor_endpoint, is_server=True))

    signature = {
        #  <SimpleDescriptor endpoint=1, profile=260, device_type=262
        #  device_version=1
        #  input_clusters=[0, 1, 1024, 57346]
        #  output_clusters=[25, 10]>
        MODELS_INFO: [("_TZ3000_qaaysllp", "TS0201")],
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: DeviceType.LIGHT_SENSOR,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    PowerConfiguration.cluster_id,
                    IlluminanceMeasurement.cluster_id,
                    0xE002,
                ],
                OUTPUT_CLUSTERS: [
                    Time.cluster_id,
                    Ota.cluster_id,
                ],
            },
        },
    }

    replacement = {
        ENDPOINTS: {
            1: {
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    PowerConfiguration.cluster_id,
                    IlluminanceMeasurement.cluster_id,
                    0xE002,
                ],
                OUTPUT_CLUSTERS: [
                    Time.cluster_id,
                    Ota.cluster_id,
                ],
            },
        },
    }

Opening a PR 🎉

marciogranzotto avatar Jun 16 '21 17:06 marciogranzotto

Thank you very much for your excellent work. I have added it in my quirk directory and the temperature data is not updated

image

albalaing avatar Jun 17 '21 12:06 albalaing

I get the same too, temperature and humidity stay at "Unknown" Also, when joining the device into the network:

Device 0x32dc (b4:e3:f9:ff:fe:0c:4b:34) joined the network
Device b4:e3:f9:ff:fe:0c:4b:34 changed id (0x474f => 0x32dc)
[0x32dc:zdo] ZDO request ZDOCmd.Device_annce: [0x32DC, b4:e3:f9:ff:fe:0c:4b:34, 128]
device - 0x32DC:b4:e3:f9:ff:fe:0c:4b:34 entering async_device_initialized - is_new_join: True
device - 0x32DC:b4:e3:f9:ff:fe:0c:4b:34 has joined the ZHA zigbee network
[0x32DC](TS0201): started configuration
[0x32DC:ZDO](TS0201): 'async_configure' stage succeeded
[0x32dc] Extending timeout for 0x1f request
[0x32DC:1:0x0000]: finished channel configuration
[0x32dc] Extending timeout for 0x20 request
[0x32DC:1:0x0019]: finished channel configuration
[0x32dc] Extending timeout for 0x21 request
[0x32DC:1:0x0400]: bound 'illuminance' cluster: Status.SUCCESS
[0x32dc] Extending timeout for 0x22 request
[0x32DC:1:0x0001]: bound 'power' cluster: Status.SUCCESS
[0x32dc] Extending timeout for 0x23 request
[0x32DC:2:0x0402]: bound 'temperature' cluster: Status.SUCCESS
[0x32dc] Extending timeout for 0x24 request
[0x32dc:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=44 command_id=Command.Report_Attributes>
[0x32dc:1:0x0400] ZCL request 0x000a: [[Attribute(attrid=61441, value=<TypeValue type=uint16_t, value=50>)]]
[0x32dc:1:0x0400] Attribute report received: 61441=50
[0x32dc:1:0x0400] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=34 command_id=Command.Default_Response>
[0x32DC:1:0x0400]: reporting 'measured_value' attr on 'illuminance' cluster: 30/900/1: Result: '[6, <Status.UNSUP_GENERAL_COMMAND: 130>]'
[0x32dc] Extending timeout for 0x25 request
Sending 'zdo_leave_req' failed: 
[0x32DC:1:0x0001]: failed to set reporting for 'battery_voltage' attr on 'power' cluster: 
[0x32dc] Extending timeout for 0x26 request
[0x32DC:2:0x0402]: failed to set reporting for 'measured_value' attr on 'temperature' cluster: 
[0x32DC:2:0x0402]: finished channel configuration
[0x32DC:2:0x0402]: 'async_configure' stage succeeded
[0x32DC:2:0x0405]: 'async_configure' stage failed: 
[0x32DC:1:0x0001]: failed to set reporting for 'battery_percentage_remaining' attr on 'power' cluster: Request failed after 5 attempts: <Status.MAC_TRANSACTION_EXPIRED: 240>
[0x32DC:1:0x0001]: finished channel configuration
[0x32DC:1:0x0400]: 'async_configure' stage failed: 'uint8_t' object is not subscriptable
[0x32DC:1:0x0000]: 'async_configure' stage succeeded
[0x32DC:1:0x0001]: 'async_configure' stage succeeded
[0x32DC:1:0x0019]: 'async_configure' stage succeeded
[0x32DC](TS0201): completed configuration
[0x32DC](TS0201): stored in registry: ZhaDeviceEntry(name='_TZ3000_qaaysllp TS0201', ieee='b4:e3:f9:ff:fe:0c:4b:34', last_seen=1623942267.298252)
[0x32DC](TS0201): started initialization
[0x32DC:ZDO](TS0201): 'async_initialize' stage succeeded
[0x32DC:1:0x0400]: initializing channel: from_cache: False
[0x32dc] Extending timeout for 0x27 request
[0x32DC:1:0x0000]: initializing channel: from_cache: False
[0x32DC:1:0x0000]: finished channel configuration
[0x32DC:1:0x0001]: initializing channel: from_cache: False
[0x32dc] Extending timeout for 0x28 request
[0x32DC:1:0x0019]: initializing channel: from_cache: False
[0x32DC:1:0x0019]: finished channel configuration
[0x32DC:2:0x0402]: initializing channel: from_cache: False
[0x32dc] Extending timeout for 0x29 request
[0x32DC:1:0x0400]: failed to get attributes '['measured_value']' on 'illuminance' cluster: Request failed after 5 attempts: <Status.MAC_TRANSACTION_EXPIRED: 240>
[0x32DC:1:0x0400]: finished channel configuration
[0x32DC:2:0x0405]: initializing channel: from_cache: False
[0x32dc] Extending timeout for 0x2a request
[0x32DC:1:0x0001]: failed to get attributes '['battery_voltage', 'battery_percentage_remaining']' on 'power' cluster: Request failed after 5 attempts: <Status.MAC_TRANSACTION_EXPIRED: 240>
[0x32dc] Extending timeout for 0x2b request

Mikk36 avatar Jun 17 '21 15:06 Mikk36