Repository: zigpy/zha-device-handlers

Issue:
Konke Temp/Humidity Sensor - Battery Not Working
This is the Konke Temp/Humidity Sensor: https://zigbee.blakadder.com/Konke_KPFT.html

Temperature and Humidity sensor works flawlessly, battery size shows as unknown:

![image](https://user-images.githubusercontent.com/11084412/76045218-6a01f600-5f2a-11ea-88bf-344ce92e89c4.png)

Here is the zigpy debug log when joining the device:

https://paste.ubuntu.com/p/XBmJ287gTD/

```
2020-03-05 21:34:26 INFO (MainThread) [zigpy.application] Device 0x41b8 (08:6b:d7:ff:fe:91:5f:7a) joined the network
2020-03-05 21:34:26 INFO (MainThread) [zigpy.device] [0x41b8] Requesting 'Node Descriptor'
2020-03-05 21:34:26 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x3e request
2020-03-05 21:34:26 DEBUG (MainThread) [zigpy.device] Ignoring message (b'08710a0000210813') on cluster 1029: unknown endpoint or cluster id: 1
2020-03-05 21:34:27 INFO (MainThread) [zigpy.device] [0x41b8] Node Descriptor: <Optional 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>
2020-03-05 21:34:27 INFO (MainThread) [zigpy.device] [0x41b8] Discovering endpoints
2020-03-05 21:34:27 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x40 request
2020-03-05 21:34:28 INFO (MainThread) [zigpy.device] [0x41b8] Discovered endpoints: [1]
2020-03-05 21:34:28 INFO (MainThread) [zigpy.endpoint] [0x41b8:1] Discovering endpoint information
2020-03-05 21:34:28 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x42 request
2020-03-05 21:34:29 INFO (MainThread) [zigpy.endpoint] [0x41b8:1] Discovered endpoint information: <SimpleDescriptor endpoint=1 profile=260 device_type=770 device_version=0 input_clusters=[0, 1, 3, 1026, 1029] output_clusters=[3]>
2020-03-05 21:34:29 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x44 request
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=68 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.endpoint] [0x41b8:1] Manufacturer: Konke
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.endpoint] [0x41b8:1] Model: 3AFE140103020000
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Checking quirks for Konke 3AFE140103020000 (08:6b:d7:ff:fe:91:5f:7a)
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'bellows.zigbee.application.EZSPCoordinator'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Fail because device_type mismatch on at least one endpoint
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.gledopto.soposhgu10.SoposhGU10'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {11, 13} {1}
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.lutron.lzl4bwhl01remote.LutronLZL4BWHL01Remote2'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Fail because profile_id mismatch on at least one endpoint
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.netvox.z308e3ed.Z308E3ED'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.osram.a19twhite.A19TunableWhite'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {3} {1}
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.philips.rom001.PhilipsROM001'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.philips.rwl021.PhilipsRWL021'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {1, 2} {1}
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.smartthings.multi.SmartthingsMultiPurposeSensor'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.smartthings.tag_v4.SmartThingsTagV4'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.xbee.xbee3_io.XBee3Sensor'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Fail because endpoint list mismatch: {232, 230} {1}
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.xbee.xbee_io.XBeeSensor'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.quirks.registry] Considering <class 'zhaquirks.xiaomi.mija.smoke.MijiaHoneywellSmokeDetectorSensor'>
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x46 request
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x48 request
2020-03-05 21:34:30 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x4a request
2020-03-05 21:34:31 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x4c request
2020-03-05 21:34:31 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x4e request
2020-03-05 21:34:31 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x50 request
2020-03-05 21:34:32 DEBUG (MainThread) [zigpy.application] Sent 'mgmt_permit_joining_req' to 00:0d:6f:ff:fe:2a:d7:57: [<Status.SUCCESS: 0>]
2020-03-05 21:34:32 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=76 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:34:32 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0402] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=78 command_id=Command.Configure_Reporting_rsp>
2020-03-05 21:34:32 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x54 request
2020-03-05 21:34:32 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=80 command_id=Command.Configure_Reporting_rsp>
2020-03-05 21:34:33 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x56 request
2020-03-05 21:34:33 DEBUG (MainThread) [zigpy.zdo] [0x41b8:zdo] ZDO request 0x8021: [<Status.SUCCESS: 0>]
2020-03-05 21:34:33 DEBUG (MainThread) [zigpy.zdo] [0x41b8:zdo] Unsupported ZDO request:0x8021
2020-03-05 21:34:34 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x58 request
2020-03-05 21:34:34 DEBUG (MainThread) [zigpy.zdo] [0x41b8:zdo] ZDO request 0x8021: [<Status.SUCCESS: 0>]
2020-03-05 21:34:34 DEBUG (MainThread) [zigpy.zdo] [0x41b8:zdo] Unsupported ZDO request:0x8021
2020-03-05 21:34:34 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=86 command_id=Command.Configure_Reporting_rsp>
2020-03-05 21:34:35 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0405] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=88 command_id=Command.Configure_Reporting_rsp>
2020-03-05 21:34:36 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x5a request
2020-03-05 21:34:36 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x5c request
2020-03-05 21:34:36 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x5e request
2020-03-05 21:34:36 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=90 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:34:36 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x60 request
2020-03-05 21:34:36 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=92 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:34:36 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0402] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=94 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:34:36 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x62 request
2020-03-05 21:34:37 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0405] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=True> manufacturer=None tsn=96 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:34:37 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=98 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:34:37 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x64 request
2020-03-05 21:34:38 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=100 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:34:38 DEBUG (MainThread) [zigpy.device] [0x41b8] Extending timeout for 0x66 request
2020-03-05 21:34:39 DEBUG (MainThread) [zigpy.zcl] [0x41b8: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=102 command_id=Command.Read_Attributes_rsp>
2020-03-05 21:35:03 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0402] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=118 command_id=Command.Report_Attributes>
2020-03-05 21:35:03 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0402] ZCL request 0x000a: [[<Attribute attrid=0 value=<TypeValue type=int16s, value=2252>>]]
2020-03-05 21:35:03 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0402] Attribute report received: measured_value=2252
2020-03-05 21:35:06 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0405] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=GLOBAL_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=119 command_id=Command.Report_Attributes>
2020-03-05 21:35:06 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0405] ZCL request 0x000a: [[<Attribute attrid=0 value=<TypeValue type=uint16_t, value=4456>>]]
2020-03-05 21:35:06 DEBUG (MainThread) [zigpy.zcl] [0x41b8:1:0x0405] Attribute report received: measured_value=4456
```



Discussion:
What size battery does it have?
CR2450 3v

Resolving patch:
diff --git a/zhaquirks/konke/motion.py b/zhaquirks/konke/motion.py
--- a/zhaquirks/konke/motion.py
+++ b/zhaquirks/konke/motion.py
@@ -6,7 +6,7 @@
 from zigpy.zcl.clusters.security import IasZone
 
 from . import KONKE, MotionCluster, OccupancyCluster
-from .. import Bus
+from .. import Bus, PowerConfigurationCluster
 from ..const import (
     DEVICE_TYPE,
     ENDPOINTS,
@@ -58,7 +58,7 @@ def __init__(self, *args, **kwargs):
             1: {
                 INPUT_CLUSTERS: [
                     Basic.cluster_id,
-                    PowerConfiguration.cluster_id,
+                    PowerConfigurationCluster,
                     Identify.cluster_id,
                     OccupancyCluster,
                     MotionCluster,
diff --git a/zhaquirks/konke/temp.py b/zhaquirks/konke/temp.py
new file mode 100644
--- /dev/null
+++ b/zhaquirks/konke/temp.py
@@ -0,0 +1,60 @@
+"""Konke temp and humidity sensor."""
+
+from zigpy.profiles import zha
+from zigpy.quirks import CustomDevice
+from zigpy.zcl.clusters.general import Basic, Identify, PowerConfiguration
+from zigpy.zcl.clusters.measurement import RelativeHumidity, TemperatureMeasurement
+
+from . import KONKE
+from .. import PowerConfigurationCluster
+from ..const import (
+    DEVICE_TYPE,
+    ENDPOINTS,
+    INPUT_CLUSTERS,
+    MODELS_INFO,
+    OUTPUT_CLUSTERS,
+    PROFILE_ID,
+)
+
+
+class KonkeTempHumidity(CustomDevice):
+    """Custom device representing konke temp and humidity sensors."""
+
+    signature = {
+        #  <SimpleDescriptor endpoint=1 profile=260 device_type=770
+        # device_version=0
+        # input_clusters=[0, 1, 3, 1026, 1029]
+        # output_clusters=[3]>
+        MODELS_INFO: [(KONKE, "3AFE140103020000")],
+        ENDPOINTS: {
+            1: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    PowerConfiguration.cluster_id,
+                    Identify.cluster_id,
+                    TemperatureMeasurement.cluster_id,
+                    RelativeHumidity.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [Identify.cluster_id],
+            }
+        },
+    }
+
+    replacement = {
+        ENDPOINTS: {
+            1: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    PowerConfigurationCluster,
+                    Identify.cluster_id,
+                    TemperatureMeasurement.cluster_id,
+                    RelativeHumidity.cluster_id,
+                ],
+                OUTPUT_CLUSTERS: [Identify.cluster_id],
+            }
+        }
+    }


Test patch: