I am new to HA and YAML but successfully got a generic Chinese 1-gang scene switch (TS0041) working using a modified quirk. (The trick is to use the TS0044 quirk and change the name – see separate postings).
I use it to toggle a ceiling light with a simple automation. I had it working on my test bench but when I installed it on site it behaves oddly: it repeatedly ‘configures’ until the time runs out and then does not work.
I set ZHA to search for new devices
I put the scene switch in pairing mode by pressing the button for 6 seconds (the light flashes)
ZHA finds it, goes through configuration and says it is “device is ready to use” (and shows the name I set for it)
The switch works briefly … but the ‘pairing’ light on the device continues flashing and
Then ZHA starts configuring it again …
And again … and again until the time runs out (3 min).
At this point it is not working and if I start a new search it cannot be found.
I can start again if I remove the battery and replace it, but the same thing happens.
I first suspected a poor Zigbee signal but it is only a couple of metres away from the nearest repeater and I tried explicitly linking it to that repeater. I tried it in other locations including close to the (SONOFF) hub (which is how I tested it originally) – no difference.There are other Zigbee items in the same room that work fine.
Somehow it seems the device does not ‘know’ that it is paired. Is there a signal ZHA sends to tell it to go out of pairing mode?
Submit a device feature request to https://github.com/zigpy/zha-device-handlers/issues for tracking until it work as it should so get a dedicated quirk that can be reused and referenced by others in the future.
For those kinds of symptoms I otherwise always highly recommend starting by following this in-depth best practice guide regarding reception optimization and interference avoidance before troubleshooting any further, regardless of which Zigbee Coordinator radio adapter and Zigbee gateway solution that you use → Guide for Zigbee interference avoidance and network range/coverage optimization (and then if still have issues then also follow these other related best practices to at least re-pair your devices again in their final location after tried to take on all the suggested actions → Zigbee Home Automation - Home Assistant).
If your problem(s) remains after that then you need to open an issue for the ZHA integration in the Home Assistant core with included debug logs etc. → https://github.com/home-assistant/core/issues
Thanks for the reference to your tips regarding optimisation of the Zigbee network, which I shall study carefully. I already followed the HA tips. However as I said I already tried the device in several locations, and the final location has a repeater nearby, so the network is not likely to be pertinent to the problem of this thread.
If I do not get a solution from this posting I will try to gather the information for an issue report later, but am otherwise engaged for the next couple of months.