|
1 | | -"""Xiaomi lumi.plug.mmeu01 plug.""" |
| 1 | +"""Xiaomi Aqara EU plugs.""" |
| 2 | +import asyncio |
2 | 3 | import logging |
3 | 4 |
|
| 5 | +import zigpy |
4 | 6 | from zigpy.profiles import zha |
5 | 7 | import zigpy.types as types |
6 | 8 | from zigpy.zcl.clusters.general import ( |
|
45 | 47 | OPPLE_MFG_CODE = 0x115F |
46 | 48 |
|
47 | 49 |
|
48 | | -class Plug(XiaomiCustomDevice): |
| 50 | +async def remove_from_ep(dev: zigpy.device.Device) -> None: |
| 51 | + """Remove devices that are in group 0 by default, so IKEA devices don't control them.""" |
| 52 | + endpoint = dev.endpoints.get(1) |
| 53 | + if endpoint is not None: |
| 54 | + dev.debug("Removing endpoint 1 from group 0") |
| 55 | + await endpoint.remove_from_group(0) |
| 56 | + dev.debug("Removed endpoint 1 from group 0") |
| 57 | + |
| 58 | + |
| 59 | +class PlugMMEU01(XiaomiCustomDevice): |
49 | 60 | """lumi.plug.mmeu01 plug.""" |
50 | 61 |
|
51 | 62 | def __init__(self, *args, **kwargs): |
@@ -141,14 +152,19 @@ async def bind(self): |
141 | 152 | return result |
142 | 153 |
|
143 | 154 |
|
144 | | -class PlugMAEU01(Plug): |
| 155 | +class PlugMAEU01(PlugMMEU01): |
145 | 156 | """lumi.plug.maeu01 plug.""" |
146 | 157 |
|
| 158 | + def __init__(self, *args, **kwargs): |
| 159 | + """Init.""" |
| 160 | + super().__init__(*args, **kwargs) |
| 161 | + asyncio.create_task(remove_from_ep(self)) |
| 162 | + |
147 | 163 | signature = { |
148 | 164 | MODELS_INFO: [ |
149 | 165 | (LUMI, "lumi.plug.maeu01"), |
150 | 166 | ], |
151 | | - ENDPOINTS: Plug.signature[ENDPOINTS], |
| 167 | + ENDPOINTS: PlugMMEU01.signature[ENDPOINTS], |
152 | 168 | } |
153 | 169 |
|
154 | 170 | replacement = { |
|
0 commit comments