zha-device-handlers: [BUG] 2 Gang Tuya Light Switch - Toggle Switches Both Lights

Bug description

Bug is as per issue [zigpy/zha-device-handlers] ts0012 - new firmware (Issue #1744)

Steps to reproduce

  1. Add 2 gang Tuya switch to ZHA
  2. Issue command from HA via ZHA to toggle one of the two switches
  3. ZHA will toggle both switches

Expected behavior

Toggling a single switch in ZHA should toggle the single corrisonding switch only.

Screenshots/Video

Screenshots/Video

[Paste/upload your media here]

Device signature

Device signature
{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *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)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0100",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0x0004",
        "0x0005",
        "0x0006"
      ],
      "out_clusters": [
        "0x0019"
      ]
    },
    "2": {
      "profile_id": 260,
      "device_type": "0x0100",
      "in_clusters": [
        "0x0004",
        "0x0005",
        "0x0006"
      ],
      "out_clusters": []
    }
  },
  "manufacturer": "_TZ3000_18ejxno0",
  "model": "TS0012",
  "class": "zhaquirks.tuya.ts001x.TuyaDoubleNoNeutralSwitch_2"
}

Diagnostic information

Diagnostic information
{
  "ieee": "**REDACTED**",
  "nwk": 60050,
  "manufacturer": "_TZ3000_18ejxno0",
  "model": "TS0012",
  "name": "_TZ3000_18ejxno0 TS0012",
  "quirk_applied": true,
  "quirk_class": "zhaquirks.tuya.ts001x.TuyaDoubleNoNeutralSwitch_2",
  "manufacturer_code": 4417,
  "power_source": "Battery or Unknown",
  "lqi": 36,
  "rssi": null,
  "last_seen": "2023-05-06T16:22:15",
  "available": true,
  "device_type": "EndDevice",
  "signature": {
    "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4417, maximum_buffer_size=66, maximum_incoming_transfer_size=66, server_mask=10752, maximum_outgoing_transfer_size=66, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *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)",
    "endpoints": {
      "1": {
        "profile_id": 260,
        "device_type": "0x0100",
        "in_clusters": [
          "0x0000",
          "0x0003",
          "0x0004",
          "0x0005",
          "0x0006"
        ],
        "out_clusters": [
          "0x0019"
        ]
      },
      "2": {
        "profile_id": 260,
        "device_type": "0x0100",
        "in_clusters": [
          "0x0004",
          "0x0005",
          "0x0006"
        ],
        "out_clusters": []
      }
    }
  },
  "active_coordinator": false,
  "entities": [
    {
      "entity_id": "button.tz3000_18ejxno0_ts0012_identify",
      "name": "_TZ3000_18ejxno0 TS0012"
    },
    {
      "entity_id": "light.tz3000_18ejxno0_ts0012_light",
      "name": "_TZ3000_18ejxno0 TS0012"
    },
    {
      "entity_id": "light.tz3000_18ejxno0_ts0012_light_2",
      "name": "_TZ3000_18ejxno0 TS0012"
    }
  ],
  "neighbors": [],
  "routes": [],
  "endpoint_names": [
    {
      "name": "ON_OFF_LIGHT"
    },
    {
      "name": "ON_OFF_LIGHT"
    }
  ],
  "user_given_name": null,
  "device_reg_id": "cf35eb0d04f1bbf928d5e240c01aa321",
  "area_id": null,
  "cluster_details": {
    "1": {
      "device_type": {
        "name": "ON_OFF_LIGHT",
        "id": 256
      },
      "profile_id": 260,
      "in_clusters": {
        "0x0000": {
          "endpoint_attribute": "basic",
          "attributes": {
            "0x0004": {
              "attribute_name": "manufacturer",
              "value": "_TZ3000_18ejxno0"
            },
            "0x0005": {
              "attribute_name": "model",
              "value": "TS0012"
            }
          },
          "unsupported_attributes": {}
        },
        "0x0003": {
          "endpoint_attribute": "identify",
          "attributes": {},
          "unsupported_attributes": {}
        },
        "0x0004": {
          "endpoint_attribute": "groups",
          "attributes": {},
          "unsupported_attributes": {}
        },
        "0x0005": {
          "endpoint_attribute": "scenes",
          "attributes": {},
          "unsupported_attributes": {}
        },
        "0x0006": {
          "endpoint_attribute": "on_off",
          "attributes": {
            "0x0000": {
              "attribute_name": "on_off",
              "value": 1
            },
            "0x4001": {
              "attribute_name": "on_time",
              "value": 0
            },
            "0x4002": {
              "attribute_name": "off_wait_time",
              "value": 0
            },
            "0x8001": {
              "attribute_name": "backlight_mode",
              "value": 1
            },
            "0x8002": {
              "attribute_name": "power_on_state",
              "value": 0
            }
          },
          "unsupported_attributes": {}
        }
      },
      "out_clusters": {
        "0x0019": {
          "endpoint_attribute": "ota",
          "attributes": {},
          "unsupported_attributes": {}
        }
      }
    },
    "2": {
      "device_type": {
        "name": "ON_OFF_LIGHT",
        "id": 256
      },
      "profile_id": 260,
      "in_clusters": {
        "0x0004": {
          "endpoint_attribute": "groups",
          "attributes": {},
          "unsupported_attributes": {}
        },
        "0x0005": {
          "endpoint_attribute": "scenes",
          "attributes": {},
          "unsupported_attributes": {}
        },
        "0x0006": {
          "endpoint_attribute": "on_off",
          "attributes": {
            "0x0000": {
              "attribute_name": "on_off",
              "value": 1
            },
            "0x4001": {
              "attribute_name": "on_time",
              "value": 0
            },
            "0x4002": {
              "attribute_name": "off_wait_time",
              "value": 0
            }
          },
          "unsupported_attributes": {}
        }
      },
      "out_clusters": {}
    }
  }
}

Logs

Logs
[Paste the logs here]

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Yep finally the “new” Moes 2 Gang TS0012 works as it should - running HA 2023.10.1 “older” TS0012 worked fine before - as others have said. They still work now on 2023.10.1

Thank you soooo much

Probably I know why we have to do this manually: However zhaquirks.tuya.ts001x.TuyaDoubleNoNeutralSwitch_2 already derives from EnchantedDevice https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/ts001x.py#L285 the spell will not be invoked as device uses Identify.cluster_id https://github.com/zigpy/zha-device-handlers/blob/dev/zhaquirks/tuya/__init__.py#L538

The test checks that every quirk merged into this repo would successfully cast a spell when used with Home Assistant. However, the quirks in ts001x.py had SKIP_CONFIGURATION set which would prevent ZHA to bind any cluster (thus also not “casting the spell”). This was fixed with https://github.com/zigpy/zha-device-handlers/pull/2524 (and tests now check for that) So for those devices (including the original post/issue), a fix should (hopefully) be in Home Assistant Core 2023.9.0