zha-device-handlers: [Device Support Request] - ZHA - Legrand / Bticino K4003C switch doesn't support status light

Problem description

The problem

The K4003C BTicino switch in ZHA doesn’t support three key features:

  • led_in_dark
  • led_if_on
  • identify

Those are fully supported by zigbee2mqtt https://www.zigbee2mqtt.io/devices/K4003C_L4003C_N4003C_NT4003C.html

Today I’ve confirmed that the status light of the switch cannot be configured with the ZHA integration

This issue was originally reported by @PoVPoV29 but nobody picked it up. https://github.com/home-assistant/core/issues/80720

This issue was also reported on HA GitHub https://github.com/home-assistant/core/issues/110009

2024-02-08 13:52:26.312 DEBUG (MainThread) [homeassistant.components.zha.websocket_api] Get bindable devices: source_ieee: [00:04:74:00:00:ca:5c:a9], bindable devices: [[{'ieee': '00:12:4b:00:2a:2e:53:b5', 'nwk': 0x0000, 'manufacturer': 'Texas Instruments', 'model': 'Coordinator', 'name': 'Texas Instruments Coordinator', 'quirk_applied': False, 'quirk_class': 'zigpy_znp.zigbee.device.ZNPCoordinator', 'quirk_id': None, 'manufacturer_code': 0, 'power_source': 'Mains', 'lqi': None, 'rssi': None, 'last_seen': '2024-02-08T13:52:17', 'available': True, 'device_type': 'Coordinator', 'signature': {'node_descriptor': 'NodeDescriptor(logical_type=<LogicalType.Coordinator: 0>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AlternatePanCoordinator|FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 143>, manufacturer_code=0, maximum_buffer_size=80, maximum_incoming_transfer_size=160, server_mask=11265, maximum_outgoing_transfer_size=160, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=True, *is_coordinator=True, *is_end_device=False, *is_full_function_device=True, *is_mains_powered=True, *is_receiver_on_when_idle=True, *is_router=False, *is_security_capable=False)', 'endpoints': {2: {'profile_id': '0xc05e', 'device_type': '0x0820', 'input_clusters': ['0x0000'], 'output_clusters': []}, 1: {'profile_id': '0x0104', 'device_type': '0x0400', 'input_clusters': ['0x0000', '0x0006', '0x000a', '0x0019', '0x0501'], 'output_clusters': ['0x0001', '0x0020', '0x0500', '0x0502']}}, 'manufacturer': 'Texas Instruments', 'model': 'Coordinator'}, 'active_coordinator': True, 'entities': [], 'neighbors': [], 'routes': [], 'endpoint_names': [{'name': 'CONTROLLER'}, {'name': 'IAS_CONTROL'}], 'user_given_name': None, 'device_reg_id': 'c8c612b28d44aa7ca98ce41965d9b633', 'area_id': None}, {'ieee': '00:04:74:00:00:ca:5c:a9', 'nwk': 0xF202, 'manufacturer': ' Legrand', 'model': ' Light switch with neutral', 'name': ' Legrand  Light switch with neutral', 'quirk_applied': False, 'quirk_class': 'zigpy.device.Device', 'quirk_id': None, 'manufacturer_code': 4129, 'power_source': 'Mains', 'lqi': 72, 'rssi': None, 'last_seen': '2024-02-08T13:47:47', 'available': True, 'device_type': 'Router', 'signature': {'node_descriptor': 'NodeDescriptor(logical_type=<LogicalType.Router: 1>, complex_descriptor_available=0, user_descriptor_available=1, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.FullFunctionDevice|MainsPowered|RxOnWhenIdle|AllocateAddress: 142>, manufacturer_code=4129, maximum_buffer_size=89, maximum_incoming_transfer_size=63, server_mask=10752, maximum_outgoing_transfer_size=63, 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': '0x0104', 'device_type': '0x0100', 'input_clusters': ['0x0000', '0x0003', '0x0004', '0x0005', '0x0006', '0x000f', '0xfc01'], 'output_clusters': ['0x0000', '0x0005', '0x0006', '0x0019', '0xfc01']}, 242: {'profile_id': '0xa1e0', 'device_type': '0x0066', 'input_clusters': ['0x0021'], 'output_clusters': ['0x0021']}}, 'manufacturer': ' Legrand', 'model': ' Light switch with neutral'}, 'active_coordinator': False, 'entities': [{'entity_id': 'binary_sensor.legrand_4_lights_binary_input', 'name': ' Legrand  Light switch with neutral'}, {'entity_id': 'button.legrand_4_lights_identify', 'name': ' Legrand  Light switch with neutral'}, {'entity_id': 'light.legrand_4_lights_light', 'name': ' Legrand  Light switch with neutral'}, {'entity_id': 'binary_sensor.legrand_4_lights_opening', 'name': ' Legrand  Light switch with neutral'}, {'entity_id': 'select.legrand_4_lights_start_up_behavior', 'name': ' Legrand  Light switch with neutral'}], 'neighbors': [], 'routes': [], 'endpoint_names': [{'name': 'ON_OFF_LIGHT'}, {'name': 'COMBO_BASIC'}], 'user_given_name': 'Legrand - 4 Lights', 'device_reg_id': '4c6bbfbabca684c73bfe37ac8b568a62', 'area_id': 'kitchen'}]]

What version of Home Assistant Core has the issue?

core-2024.1.6

Home Assistant Container

Integration causing the issue

Zigbee Home Assistant (ZHA)

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zha

Solution description

Support for the following 3 properties:

  • led_in_dark
  • led_if_on
  • identify

Screenshots/Video

Screenshots/Video

[Paste/upload your media here]

Device signature

Device signature
[Paste the device signature here]

Diagnostic information

Diagnostic information
[Paste the diagnostic information here]

Logs

Logs
[Paste the logs here]

Custom quirk

Custom quirk
[Paste your custom quirk here]

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 2
  • Comments: 25

Most upvoted comments

If any one interested in the options on the devices as entities (See image below)

Image

Use these custom quirks:

K4411C (dimmer.py)

# """V2 Quirk for Legrand/Bticino dimmer switch."""

import logging

from zigpy.quirks import CustomCluster
from zigpy.quirks.v2 import QuirkBuilder
import zigpy.types as t
from zigpy.zcl.foundation import (
    BaseAttributeDefs,
    DataTypeId,
    ZCLAttributeDef,
)


from zhaquirks.legrand import LEGRAND, MANUFACTURER_SPECIFIC_CLUSTER_ID


class DeviceMode(t.enum16):
    """Device mode."""
    DimmerOn = 0x0101
    DimmerOff = 0x0100


class LegrandCluster(CustomCluster):
    """LegrandCluster."""

    cluster_id = MANUFACTURER_SPECIFIC_CLUSTER_ID
    name = "LegrandCluster"
    ep_attribute = "legrand_cluster"

    class AttributeDefs(BaseAttributeDefs):
        """Attribute definitions for LegrandCluster."""

        device_mode = ZCLAttributeDef(
            id=0x0000,
            type=DeviceMode,
            zcl_type=DataTypeId.data16,
            is_manufacturer_specific=True,
        )
        led_in_dark = ZCLAttributeDef(
            id=0x0001,
            type=t.Bool,
            is_manufacturer_specific=True,
        )
        led_if_on = ZCLAttributeDef(
            id=0x0002,
            type=t.Bool,
            is_manufacturer_specific=True,
        )

(
     QuirkBuilder(f" {LEGRAND}", " Dimmer switch w/o neutral")
     .also_applies_to(f" {LEGRAND}", " Dimmer switch with neutral")
    .replaces(LegrandCluster)
    .switch(
        attribute_name=LegrandCluster.AttributeDefs.led_in_dark.name,
        cluster_id=LegrandCluster.cluster_id,
        translation_key="led_in_dark",
        fallback_name="Enable Led in the dark",
    )
    .switch(
        attribute_name=LegrandCluster.AttributeDefs.led_if_on.name,
        cluster_id=LegrandCluster.cluster_id,
        translation_key="led_if_on",
        fallback_name="Enable Led if on",
    )
    .enum(
        attribute_name=LegrandCluster.AttributeDefs.device_mode.name,
        cluster_id=LegrandCluster.cluster_id,
        enum_class=DeviceMode,
        translation_key="device_mode",
        fallback_name="Device mode",
    )
    .add_to_registry()
)

K4003C (switch.py)

# """Quirk for  Legrand  Light switch with neutral."""

from zigpy.quirks import  CustomCluster
import zigpy.types as t
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef

from zigpy.quirks.v2 import (
    QuirkBuilder,
)

from zhaquirks.legrand import LEGRAND, MANUFACTURER_SPECIFIC_CLUSTER_ID

class LegrandCluster(CustomCluster):
    """Manufacturer specific cluster to relay motion event to IAS Zone cluster."""

    cluster_id = MANUFACTURER_SPECIFIC_CLUSTER_ID

    class AttributeDefs(BaseAttributeDefs):
        """Attribute definitions."""

        led_in_dark = ZCLAttributeDef(
            id=0x0001,
            type=t.Bool,
            is_manufacturer_specific=True,
        )
        led_if_on = ZCLAttributeDef(
            id=0x0002,
            type=t.Bool,
            is_manufacturer_specific=True,
        )

(
     QuirkBuilder(f" {LEGRAND}", " Light switch with neutral")
    .replaces(LegrandCluster)
    .switch(
        attribute_name=LegrandCluster.AttributeDefs.led_in_dark.name,
        cluster_id=LegrandCluster.cluster_id,
        translation_key="led_in_dark",
        fallback_name="Enable Led in the dark",
    )
    .switch(
        attribute_name=LegrandCluster.AttributeDefs.led_if_on.name,
        cluster_id=LegrandCluster.cluster_id,
        translation_key="led_if_on",
        fallback_name="Enable Led if on",
    )
    .add_to_registry()
)

K4027C (cover.py)

# """V2 Quirk for Legrand/Bticino dimmer switch."""

from zigpy.quirks import CustomCluster
from zigpy.quirks.v2 import QuirkBuilder
import zigpy.types as t
from zigpy.zcl.foundation import (
    BaseAttributeDefs,
    ZCLAttributeDef,
)

from zhaquirks.legrand import LEGRAND, MANUFACTURER_SPECIFIC_CLUSTER_ID


class LegrandCluster(CustomCluster):
    """LegrandCluster."""

    cluster_id = MANUFACTURER_SPECIFIC_CLUSTER_ID
    name = "LegrandCluster"
    ep_attribute = "legrand_cluster"

    class AttributeDefs(BaseAttributeDefs):
        """Attribute definitions for LegrandCluster."""

        led_in_dark = ZCLAttributeDef(
            id=0x0001,
            type=t.Bool,
            is_manufacturer_specific=True,
        )
        led_if_on = ZCLAttributeDef(
            id=0x0002,
            type=t.Bool,
            is_manufacturer_specific=True,
        )

(
     QuirkBuilder(f" {LEGRAND}", " Shutter SW with level control")
    .replaces(LegrandCluster)
    .switch(
        attribute_name=LegrandCluster.AttributeDefs.led_in_dark.name,
        cluster_id=LegrandCluster.cluster_id,
        translation_key="led_in_dark",
        fallback_name="Enable Led in the dark",
    )
    .switch(
        attribute_name=LegrandCluster.AttributeDefs.led_if_on.name,
        cluster_id=LegrandCluster.cluster_id,
        translation_key="led_if_on",
        fallback_name="Enable Led if on",
    )

    .add_to_registry()
)

Put these files under /config/custom_zha_quirks/ and enable quirks in the configuration.yaml file:

zha:
  custom_quirks_path: /config/custom_zha_quirks/
  enable_quirks: true

I am moving back Zigbee2Mqtt due to other incompatibility issues with Bticino/Legrand devices and the lack of the ZHA community to fix these stuff.