Sonoff ZBMINIR2 not reporting input sensor in ZHA

Hi,

I’m trying to use Sonoff ZBMINIR2 via ZHA to check the state of the S1/S2 input. I connected a magnetic sensor there mounted on the doors to check if the doors are closed, but the in the HA the sensor is reported as “closed” all the time.

On the other hand the sensor is coupled with the switch (even if I enable the “detach” mode - apparently it doesn’t work correctly), so when I open/close that input the switch toggles its state. That could be enough for me, I could sacrifice that one switch, but unfortunately if I toggle that switch once through HA, then subsequent readings of my door sensor are negated. Even if I set trigger mode to “Normally off follow trigger”.

Any hints? Or any recommendations for buying another zigbee switch that works fine with ZHA and could be used just as a open/closed door sensor?

I tried to use Sonoff MINI-D (via WiFi) - but that one had another issue. When its input is shorted the ZHA “Action” sensor input changes to “single” for half a second and then changes back to “”. So it only signals an edge. I tried to change trigger settings through eWeLink app (as I suppose it’s the module, not HA issue), but the only change I could get was receiving these signals on both edges or just one (off->on). And I need to read current state.

I’ve read that ZBMINIL2 reports sensor input correctly (and it has about 1-second delay due to powering without neutral wire), so maybe I’ll give it a try.

P.

This is a bug in ZHA / ZIGPY affecting many many devices with both ONOFF Cluster for Input and Output (Server and Client). This will hopefully be changed soon, a fix is ongoing. Due to many ONOFF Cluster devices extensive testing is needed.

Pull Request with a partial fix: Match incoming cluster commands based on `direction` by puddly · Pull Request #1615 · zigpy/zigpy · GitHub (there need to be more fixes applied for this to work).

Once this is fixed, the ONOFF Input Cluster and ONOFF Output Cluster.

The other fixes is zigpy will then also fix the issue with detached relay mode.

The bug is that the ONOFF event coming from the device and sent to the coordinator is routed in ZHA to wrong event handler and therefore it just toggles the switch’s state. The Sensor “Opening” never changes due to this.