-
Notifications
You must be signed in to change notification settings - Fork 870
Add Sonoff ZBM5 light switch #4198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #4198 +/- ##
==========================================
- Coverage 91.46% 91.32% -0.14%
==========================================
Files 341 342 +1
Lines 11203 11255 +52
==========================================
+ Hits 10247 10279 +32
- Misses 956 976 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hi! Thanks for taking the time to make the quirk :) Personally I have the ZBM5-3C and -2C (Firmware: 0x00001003) and I'm running 2025.8 beta 1. I tried adding your version of the quirk to my Hass instance and while I am able to change the detach_relay_mask, the relay_x_detached only report "None". Is there something I could test? |
That was an old version. On the latest, you shouldn't see a mask. Only switches. And they are disabled by default. You have to enable them. |
@MindFreeze I meant in the "Manage Zigbee Device" screen, but gotcha, enabling the switches successfully allows me to toggle detach mode indeed! I don't see anything being logged when I press one of the buttons in detached mode, though. Does that work on your end? Can you respond to any physical button presses? |
Yes. On my switches it works as expected. The button toggles the switch in HA without changing the state of the physical relay |
So, you get 3 hass switches per sonoff button?
Might be slightly different on my end as I have the 120 version |
No, I get 2 switches per button. 1 for the button/relay and 1 to detach the relay. It works as described in zigpy/zigpy#1612 (comment) |
Ah I see :) They have an "Opening" sensor that changes state whenever detached mode is enabled and a button is pressed. I also have an ZBMINIR2 where this works as expected. Unfortunately, there's no sensor for my ZBM5-3C-120, so there's no way to detect a button press in detached mode :/ I was kind of expecting that it worked similarly to my Aqara Switch. This doesn't have a "sensor" in detached mdoe, but it simply fires events whenever a button is pressed or double-pressed, which you can hook into in automations. |
@sl33nyc nice, but if you don't use the relay of the first button, then you don't even need detached mode, do you? In proper detached mode, you should be able to handle the relays and buttons completely separately. In my case, that's what I'm trying to achieve. The 3 relays all have lights attached to them, but a combination of presses, or a doublepress, should control all lights in my living room at once. |
These sonoff switches don't support that. I don't even see an output cluster for OnOff, so you can't bind it to a light, which is the original use case for detached relay. |
@MindFreeze That's a shame :/ But I think you're right. Sonoff gives as a usecase: "With the detach relay enabled, smart lights won’t lose power when the wall switch is turned off, allowing them to remain smart at all times. *Supports connecting smart lights only in the neutral required mode." However, if you want to supply permanent power to a smart lightbulb anyway, why connect it to the smart switch in the first place? XD I wonder if there's a way to differentiate between "turned X" and "turned X triggered by action" in automations... That would allow me to build a workaround in detached mode. Because "turned X" means a button press, which doesn't change the relay, and "turned X triggered by action" means an action taken by home assistant, which does change the relay. Anyway, I'll figure it out. Looks like the PR can achieve everything that's possible :) thanks! For me it can be merged too |
Hello, I've applied this locally and tested Detached Relay mode works as expected. Thanks, |
Proposed change
Add the detached relay and related entities for ZBM5
but there is a catch.This switch has 2 modes because the neutral wire is optional. And if there is no neutral wire, detached relay is not supported. This can be determined from the "work_mode" sensor in this PR but I don't know how to conditionally add the detached relay entities only if
work_mode=1
The Sonoff site says that detached relay is only supported when there is a Neutral wire provided but after testing with 2 dual switches, this seems to be false. It works fine without a Neutral. I only tested it with a 20W light though so it may not work as well with a smaller load.
Additional information
Checklist
pre-commit
checks pass / the code has been formatted using Black