Skip to content
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

Fix Xiaomi MAEU01 plug #1479

Merged
merged 5 commits into from
Apr 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion zhaquirks/xiaomi/aqara/plug_mmeu01.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging

from zigpy.profiles import zha
import zigpy.types as types
from zigpy.zcl.clusters.general import (
Alarms,
AnalogInput,
Expand Down Expand Up @@ -33,13 +34,15 @@
AnalogInputCluster,
BasicCluster,
ElectricalMeasurementCluster,
XiaomiAqaraE1Cluster,
XiaomiCustomDevice,
)

_LOGGER = logging.getLogger(__name__)

XIAOMI_PROFILE_ID = 0xA1E0
XIAOMI_DEVICE_TYPE = 0x61
OPPLE_MFG_CODE = 0x115F


class Plug(XiaomiCustomDevice):
Expand All @@ -55,7 +58,6 @@ def __init__(self, *args, **kwargs):
signature = {
MODELS_INFO: [
(LUMI, "lumi.plug.mmeu01"),
(LUMI, "lumi.plug.maeu01"),
],
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=81
Expand Down Expand Up @@ -121,3 +123,58 @@ def __init__(self, *args, **kwargs):
},
},
}


class OppleCluster(XiaomiAqaraE1Cluster):
"""Opple cluster."""

ep_attribute = "opple_cluster"
attributes = {
0x0009: ("mode", types.uint8_t, True),
}
attr_config = {0x0009: 0x00}

async def bind(self):
"""Bind cluster."""
result = await super().bind()
await self.write_attributes(self.attr_config, manufacturer=OPPLE_MFG_CODE)
return result


class PlugMAEU01(Plug):
"""lumi.plug.maeu01 plug."""

signature = {
MODELS_INFO: [
(LUMI, "lumi.plug.maeu01"),
],
ENDPOINTS: Plug.signature[ENDPOINTS],
}

replacement = {
SKIP_CONFIGURATION: False,
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
DeviceTemperature.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Alarms.cluster_id,
Metering.cluster_id,
ElectricalMeasurement.cluster_id,
OppleCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
242: {
PROFILE_ID: XIAOMI_PROFILE_ID,
DEVICE_TYPE: XIAOMI_DEVICE_TYPE,
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
},
},
}