# MINI-ZB2GS ghost switch events

**URL:** <https://forum.ewelink.cc/t/mini-zb2gs-ghost-switch-events/209465>\
**Category:** Uncategorized\
**Tags:** zigbee\
**Created:** [October 21, 2026, 11:30am UTC](https://forum.ewelink.cc/t/mini-zb2gs-ghost-switch-events/209465 "2026-10-21T11:30:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![giof](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@giof](https://forum.ewelink.cc/u/giof)\
**Post date:** [October 21, 2026, 11:30am UTC](https://forum.ewelink.cc/t/mini-zb2gs-ghost-switch-events/209465/1 "2026-10-21T11:30:45Z")

</div>

Hello,

In my house, connected via a sonoff usb mg24 adapter to home assistant, I have 2 ZB2GS installed several months ago via zha. Right now I’m using official quirk, untill some weeks ago I was using the quirk published in github official pull request proposal (when I bought them it was not approved yet).  
They are both in detached mode on both lines. It randomly happens, maybe once a week, that the detach state changes without me (or anuything else on HA) pressing or doing anything, resulting in lights being switched on with no reason.  
It happened on different versions of HA during last months, when it happens in HA history I just see the detached switch toggle event, nothing else. At first I thought the mini was rebooting and so it could make sense that the state changed, but in the near minutes there is no other event from that device, so I guess it did not restart.

Anyone else saw or is having same issue?

Any way I can get more logs from ZHA? Today I can’t see anything useful in logs about zigbee/zha

Thank you

Giorgio

---

<div class="post-metadata">

**Author:** ![jam3](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/jam3/32/7918_2.png) [@jam3](https://forum.ewelink.cc/u/jam3)\
**Post date:** [October 21, 2026, 11:41am UTC](https://forum.ewelink.cc/t/mini-zb2gs-ghost-switch-events/209465/2 "2026-10-21T11:41:30Z")

</div>

I wouldn’t assume the quirk is the cause yet. The state change in HA history alone isn’t enough to determine what triggered it. The most useful next step would be to enable debug logging for ZHA/zigpy and correlate the logs with the entity history and any commands sent by automations around the time it happens.

To get more detailed logs, add the following to your configuration.yaml:

```auto
logger:
  default: warning
  logs:
    homeassistant.components.zha: debug
    zigpy: debug

```

Then restart Home Assistant and wait for the issue to occur. Once the state changes unexpectedly, check the logs around that exact time and compare them with the entity history.

Since this happens only about once a week, keep in mind that debug logging can generate a lot of data, so disable it once you’ve captured the relevant logs.

Also, could you clarify where you got the quirk you’re currently using. Is it the one included in the official HA release or a custom version from GitHub?

---

<div class="post-metadata">

**Author:** ![giof](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@giof](https://forum.ewelink.cc/u/giof)\
**Post date:** [October 21, 2026, 12:06pm UTC](https://forum.ewelink.cc/t/mini-zb2gs-ghost-switch-events/209465/3 "2026-10-21T12:06:13Z")

</div>

thank you for the quick response  
Can’t tell you exactly where I copied it, it was march/april and I did not take note on where I found it, however I can paste here the code I had in the custom quirk.

```auto
"""Sonoff MINI-ZB2GS - Zigbee Switch."""

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

class SonoffCluster(CustomCluster):
"""Custom Sonoff cluster."""

cluster_id = 0xFC11
manufacturer_id_override = foundation.ZCLHeader.NO_MANUFACTURER_ID

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

    external_trigger_mode = ZCLAttributeDef(
        id=0x0016,
        type=t.uint8_t,
    )
    detach_relay = ZCLAttributeDef(
        id=0x0019,
        type=t.bitmap8,
    )
    turbo_mode = ZCLAttributeDef(
        id=0x0012,
        type=t.int16s,
    )
    network_led = ZCLAttributeDef(
        id=0x0001,
        type=t.Bool,
    )

class SonoffExternalSwitchTriggerType(types.enum8):
"""extern switch trigger type."""

Edge_trigger = 0x00
Pulse_trigger = 0x01
Normally_off_follow_trigger = 0x02
Normally_on_follow_trigger = 0x82

class SonoffDetachRelayType(types.enum8):
"""detach relay type."""

All_channels_disabled = 0x00
CH1_enabled = 0x01
CH2_enabled = 0x02
All_channels_enabled = 0x03

(
QuirkBuilder("SONOFF", "MINI-ZB2GS")
.replaces(SonoffCluster, endpoint_id=1)
.replaces(SonoffCluster, endpoint_id=2)
.enum(
SonoffCluster.AttributeDefs.external_trigger_mode.name,
SonoffExternalSwitchTriggerType,
SonoffCluster.cluster_id,
translation_key="external_trigger_mode",
fallback_name="External trigger mode",
endpoint_id=1,
)
.enum(
SonoffCluster.AttributeDefs.detach_relay.name,
SonoffDetachRelayType,
SonoffCluster.cluster_id,
translation_key="detach_relay",
fallback_name="Detach relay",
endpoint_id=1,
)
.enum(
SonoffCluster.AttributeDefs.external_trigger_mode.name,
SonoffExternalSwitchTriggerType,
SonoffCluster.cluster_id,
translation_key="external_trigger_mode",
fallback_name="External trigger mode",
endpoint_id=2,
)
.switch(
SonoffCluster.AttributeDefs.turbo_mode.name,
SonoffCluster.cluster_id,
off_value=9,
on_value=20,
translation_key="turbo_mode",
fallback_name="Turbo mode",
endpoint_id=1,
)
.switch(
SonoffCluster.AttributeDefs.network_led.name,
SonoffCluster.cluster_id,
translation_key="network_led",
fallback_name="Network LED",
endpoint_id=1,
)
.add_to_registry()
)

```

Just a question about zha and debug: does ha/zha stores debug logs from reboot or only last n lines or last n MBs? I would avoid keeping all these debug logs for days waiting for the incident to happen

---

<div class="post-metadata">

**Author:** ![jam3](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/jam3/32/7918_2.png) [@jam3](https://forum.ewelink.cc/u/jam3)\
**Post date:** [October 21, 2026, 2:08pm UTC](https://forum.ewelink.cc/t/mini-zb2gs-ghost-switch-events/209465/4 "2026-10-21T14:08:57Z")

</div>

Regarding debug logs: Home Assistant writes logs to home-assistant.log, but they are not intended to be a long-term event history. Log rotation and the amount of retained data depend on the logging configuration, so older entries may be overwritten before the issue occurs. Debug logs also won’t contain anything from before debugging was enabled.

For ZHA, I’d recommend enabling debug logging directly from Settings → Devices & services → ZHA → ⋮ → Enable debug logging. When the issue happens, disable debug logging and download the log file.

Unfortunately, since the issue occurs only about once a week, you may need to leave debugging enabled until it happens. I’d check the log file size and rotation behavior first, so you don’t lose the relevant entries.

The custom quirk you pasted is also useful. It defines the detach\_relay attribute (0x0019) in the manufacturer-specific cluster 0xFC11. If you can capture the Zigbee traffic or debug logs around the unexpected change, you may be able to determine whether the device reports a change itself or whether a command is being sent to it.
