Repository: zigpy/zha-device-handlers

Issue:
[Device Support Request] Philips Hue Power Cycle Attribute
Hi 

It would be great to have the Philips Hue Power Cycle attribute added. This allows for the bulb to remain powered on, off or set to previous settings when powered on.

The vendor attribute is `0x4003` and falls part of the `0x0006` (on_off) cluster. The possible values (enum8) are 

```
Off = 0x00
On = 0x01
Previous = 0xff
```

The device signature for the ambient color bulb is as follows:

```
{
  "node_descriptor": "<NodeDescriptor byte1=1 byte2=64 mac_capability_flags=142 manufacturer_code=4107 maximum_buffer_size=71 maximum_incoming_transfer_size=45 server_mask=0 maximum_outgoing_transfer_size=45 descriptor_capability_field=0>",
  "endpoints": {
    "11": {
      "profile_id": 49246,
      "device_type": "0x0210",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0008",
        "0x0300",
        "0x1000",
        "0xfc01"
      ],
      "out_clusters": [
        "0x0019"
      ]
    },
    "242": {
      "profile_id": 41440,
      "device_type": "0x0061",
      "in_clusters": [
        "0x0021"
      ],
      "out_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "Philips",
  "model": "LCT015",
  "class": "zigpy.device.Device"
}
```

The device signature for the dimmable white bulb is as follows:

```
{
  "node_descriptor": "<NodeDescriptor byte1=1 byte2=64 mac_capability_flags=142 manufacturer_code=4107 maximum_buffer_size=71 maximum_incoming_transfer_size=45 server_mask=0 maximum_outgoing_transfer_size=45 descriptor_capability_field=0>",
  "endpoints": {
    "11": {
      "profile_id": 49246,
      "device_type": "0x0100",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006",
        "0x0008",
        "0x1000"
      ],
      "out_clusters": [
        "0x0019"
      ]
    },
    "242": {
      "profile_id": 41440,
      "device_type": "0x0061",
      "in_clusters": [
        "0x0021"
      ],
      "out_clusters": [
        "0x0021"
      ]
    }
  },
  "manufacturer": "Philips",
  "model": "LWB010",
  "class": "zigpy.device.Device"
}
```

I hope this is all that is needed to implement this. Please let me know if there anything you need.

Thanks.

Kurt 


Discussion:
does the 2nd one support this? It doesn't have the Philips cluster...
nvm.

Resolving patch:
diff --git a/zhaquirks/philips/lct011.py b/zhaquirks/philips/lct.py
similarity index 83%
rename from zhaquirks/philips/lct011.py
rename to zhaquirks/philips/lct.py
--- a/zhaquirks/philips/lct011.py
+++ b/zhaquirks/philips/lct.py
@@ -1,4 +1,4 @@
-"""Quirk for Phillips LCT011."""
+"""Quirk for Phillips LCT bulbs."""
 from zigpy.profiles import zll
 from zigpy.quirks import CustomDevice
 from zigpy.zcl.clusters.general import (
@@ -26,11 +26,24 @@
 from zhaquirks.philips import PHILIPS, PhilipsOnOffCluster
 
 
-class PhilipsLCT011(CustomDevice):
-    """Philips LCT011 device."""
+class PhilipsLCT(CustomDevice):
+    """Philips LCT bulb device."""
 
     signature = {
-        MODELS_INFO: [(PHILIPS, "LCT011")],
+        MODELS_INFO: [
+            (PHILIPS, "LCT001"),
+            (PHILIPS, "LCT002"),
+            (PHILIPS, "LCT003"),
+            (PHILIPS, "LCT007"),
+            (PHILIPS, "LCT010"),
+            (PHILIPS, "LCT011"),
+            (PHILIPS, "LCT012"),
+            (PHILIPS, "LCT014"),
+            (PHILIPS, "LCT015"),
+            (PHILIPS, "LCT016"),
+            (PHILIPS, "LCT021"),
+            (PHILIPS, "LCT024"),
+        ],
         ENDPOINTS: {
             11: {
                 # <SimpleDescriptor endpoint=11 profile=49246 device_type=528
diff --git a/zhaquirks/philips/lct024.py b/zhaquirks/philips/lct024.py
deleted file mode 100644
--- a/zhaquirks/philips/lct024.py
+++ /dev/null
@@ -1,93 +0,0 @@
-"""Quirk for Phillips LCT024."""
-from zigpy.profiles import zll
-from zigpy.quirks import CustomDevice
-from zigpy.zcl.clusters.general import (
-    OnOff,
-    Basic,
-    Identify,
-    LevelControl,
-    Scenes,
-    Groups,
-    Ota,
-    GreenPowerProxy,
-)
-
-from zigpy.zcl.clusters.lighting import Color
-from zigpy.zcl.clusters.lightlink import LightLink
-
-from zhaquirks.const import (
-    ENDPOINTS,
-    OUTPUT_CLUSTERS,
-    INPUT_CLUSTERS,
-    DEVICE_TYPE,
-    PROFILE_ID,
-    MODELS_INFO,
-)
-from zhaquirks.philips import PHILIPS, PhilipsOnOffCluster
-
-
-class PhilipsLCT024(CustomDevice):
-    """Philips LCT024 device."""
-
-    signature = {
-        MODELS_INFO: [(PHILIPS, "LCT024")],
-        ENDPOINTS: {
-            11: {
-                # <SimpleDescriptor endpoint=11 profile=49246 device_type=528
-                # device_version=2
-                # input_clusters=[0, 3, 4, 5, 6, 8, 4096, 768, 64513]
-                # output_clusters=[25]
-                PROFILE_ID: zll.PROFILE_ID,
-                DEVICE_TYPE: zll.DeviceType.EXTENDED_COLOR_LIGHT,
-                INPUT_CLUSTERS: [
-                    Basic.cluster_id,
-                    Identify.cluster_id,
-                    Groups.cluster_id,
-                    Scenes.cluster_id,
-                    OnOff.cluster_id,
-                    LevelControl.cluster_id,
-                    LightLink.cluster_id,
-                    Color.cluster_id,
-                    64513,
-                ],
-                OUTPUT_CLUSTERS: [Ota.cluster_id],
-            },
-            242: {
-                # <SimpleDescriptor endpoint=242 profile=41440 device_type=97
-                # device_version=0
-                # input_clusters=[33]
-                # output_clusters=[33]
-                PROFILE_ID: 41440,
-                DEVICE_TYPE: 97,
-                INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
-                OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
-            },
-        },
-    }
-
-    replacement = {
-        ENDPOINTS: {
-            11: {
-                PROFILE_ID: zll.PROFILE_ID,
-                DEVICE_TYPE: zll.DeviceType.EXTENDED_COLOR_LIGHT,
-                INPUT_CLUSTERS: [
-                    Basic.cluster_id,
-                    Identify.cluster_id,
-                    Groups.cluster_id,
-                    Scenes.cluster_id,
-                    PhilipsOnOffCluster,
-                    LevelControl.cluster_id,
-                    LightLink.cluster_id,
-                    Color.cluster_id,
-                    64513,
-                ],
-                OUTPUT_CLUSTERS: [Ota.cluster_id],
-            },
-            242: {
-                PROFILE_ID: 41440,
-                DEVICE_TYPE: 97,
-                INPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
-                OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
-            },
-        }
-    }
diff --git a/zhaquirks/philips/lct016.py b/zhaquirks/philips/lwb010.py
similarity index 81%
rename from zhaquirks/philips/lct016.py
rename to zhaquirks/philips/lwb010.py
--- a/zhaquirks/philips/lct016.py
+++ b/zhaquirks/philips/lwb010.py
@@ -1,4 +1,4 @@
-"""Quirk for Phillips LCT016."""
+"""Quirk for Phillips LWB010."""
 from zigpy.profiles import zll
 from zigpy.quirks import CustomDevice
 from zigpy.zcl.clusters.general import (
@@ -12,7 +12,6 @@
     GreenPowerProxy,
 )
 
-from zigpy.zcl.clusters.lighting import Color
 from zigpy.zcl.clusters.lightlink import LightLink
 
 from zhaquirks.const import (
@@ -26,19 +25,19 @@
 from zhaquirks.philips import PHILIPS, PhilipsOnOffCluster
 
 
-class PhilipsLCT016(CustomDevice):
-    """Philips LCT016 device."""
+class PhilipsLBW010(CustomDevice):
+    """Philips LBW010 device."""
 
     signature = {
-        MODELS_INFO: [(PHILIPS, "LCT016")],
+        MODELS_INFO: [(PHILIPS, "LWB010")],
         ENDPOINTS: {
             11: {
                 # <SimpleDescriptor endpoint=11 profile=49246 device_type=528
                 # device_version=2
-                # input_clusters=[0, 3, 4, 5, 6, 8, 4096, 768, 64513]
+                # input_clusters=[0, 3, 4, 5, 6, 8, 4096]
                 # output_clusters=[25]
                 PROFILE_ID: zll.PROFILE_ID,
-                DEVICE_TYPE: zll.DeviceType.EXTENDED_COLOR_LIGHT,
+                DEVICE_TYPE: zll.DeviceType.DIMMABLE_LIGHT,
                 INPUT_CLUSTERS: [
                     Basic.cluster_id,
                     Identify.cluster_id,
@@ -47,8 +46,6 @@ class PhilipsLCT016(CustomDevice):
                     OnOff.cluster_id,
                     LevelControl.cluster_id,
                     LightLink.cluster_id,
-                    Color.cluster_id,
-                    64513,
                 ],
                 OUTPUT_CLUSTERS: [Ota.cluster_id],
             },
@@ -69,7 +66,7 @@ class PhilipsLCT016(CustomDevice):
         ENDPOINTS: {
             11: {
                 PROFILE_ID: zll.PROFILE_ID,
-                DEVICE_TYPE: zll.DeviceType.EXTENDED_COLOR_LIGHT,
+                DEVICE_TYPE: zll.DeviceType.DIMMABLE_LIGHT,
                 INPUT_CLUSTERS: [
                     Basic.cluster_id,
                     Identify.cluster_id,
@@ -78,8 +75,6 @@ class PhilipsLCT016(CustomDevice):
                     PhilipsOnOffCluster,
                     LevelControl.cluster_id,
                     LightLink.cluster_id,
-                    Color.cluster_id,
-                    64513,
                 ],
                 OUTPUT_CLUSTERS: [Ota.cluster_id],
             },


Test patch: