Skip to content

Commit 5e1d4f2

Browse files
committed
Merge branch 'release/0.0.35'
2 parents a730681 + 2a77f29 commit 5e1d4f2

File tree

10 files changed

+154
-52
lines changed

10 files changed

+154
-52
lines changed

Contributors.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@
1818
- [Nemesis24](https://github.com/Nemesis24)
1919
- [Andy Zickler](https://github.com/andyzickler)
2020
- [Piotr Majkrzak](https://github.com/majkrzak)
21+
- [Gleb Sinyavskiy](https://github.com/zhulik)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ If you are looking to make your first code contribution to this project then we
4040
- [Motion Sensor](https://www.aqara.com/en/motion_sensor.html): lumi.sensor_motion.aq2
4141
- [Temperature / Humidity Sensor](https://www.aqara.com/en/temperature_and_humidity_sensor-product.html): lumi.weather
4242
- [Water Leak](https://www.aqara.com/en/water_leak_sensor.html): lumi.sensor_wleak.aq1
43+
- [US Plug](https://www.aqara.com/en/smart_plug.html): lumi.plug.maus01
44+
- [EU Plug](https://zigbee.blakadder.com/Xiaomi_ZNCZ04LM.html): lumi.plug.mmeu01
4345

4446
### Osram
4547
- [OSRAM LIGHTIFY Dimming Switch](https://assets.osram-americas.com/assets/Documents/LTFY012.06c0d6e6-17c7-4dcb-bd2c-1fca7feecfb4.pdf):
@@ -96,6 +98,7 @@ If you are looking to make your first code contribution to this project then we
9698
- Cube sends the following events: `flip (90 and 180 degrees)`, `rotate_left`, `rotate_right`, `knock`, `drop`, `slide` and `shake`
9799
- Motion sensor exposes binary sensors for motion and occupancy.
98100
- Button sends events to Home Assistant
101+
- All supported plugs report power consumption and can be toggled
99102

100103
### SmartThings
101104

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import find_packages, setup
44

5-
VERSION = "0.0.34"
5+
VERSION = "0.0.35"
66

77

88
def readme():

zhaquirks/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def write_attributes(self, attributes, manufacturer=None):
5151
"""Prevent remote writes."""
5252
for attrid, value in attributes.items():
5353
if isinstance(attrid, str):
54-
attrid = self._attridx[attrid]
54+
attrid = self.attridx[attrid]
5555
if attrid not in self.attributes:
5656
self.error("%d is not a valid attribute id", attrid)
5757
continue

zhaquirks/xiaomi/__init__.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from zigpy import types as t
77
from zigpy.quirks import CustomCluster, CustomDevice
8-
from zigpy.zcl.clusters.general import Basic, PowerConfiguration
8+
from zigpy.zcl.clusters.general import AnalogInput, Basic, PowerConfiguration
99
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
1010
from zigpy.zcl.clusters.measurement import (
1111
OccupancySensing,
@@ -409,7 +409,23 @@ def pressure_reported(self, value):
409409
self._update_attribute(self.ATTR_ID, value)
410410

411411

412-
class ElectricalMeasurementCluster(CustomCluster, ElectricalMeasurement):
412+
class AnalogInputCluster(CustomCluster, AnalogInput):
413+
"""Analog input cluster, only used to relay power consumtion information to ElectricalMeasurementCluster."""
414+
415+
cluster_id = AnalogInput.cluster_id
416+
417+
def __init__(self, *args, **kwargs):
418+
"""Init."""
419+
self._current_state = {}
420+
super().__init__(*args, **kwargs)
421+
422+
def _update_attribute(self, attrid, value):
423+
super()._update_attribute(attrid, value)
424+
if value is not None and value >= 0:
425+
self.endpoint.device.power_bus.listener_event(POWER_REPORTED, value)
426+
427+
428+
class ElectricalMeasurementCluster(LocalDataCluster, ElectricalMeasurement):
413429
"""Electrical measurement cluster to receive reports that are sent to the basic cluster."""
414430

415431
cluster_id = ElectricalMeasurement.cluster_id
@@ -435,9 +451,3 @@ def voltage_reported(self, value):
435451
def consumption_reported(self, value):
436452
"""Consumption reported."""
437453
self._update_attribute(self.CONSUMPTION_ID, value)
438-
439-
async def read_attributes_raw(self, attributes, manufacturer=None):
440-
"""Prevent remote reads."""
441-
attributes = [t.uint16_t(a) for a in attributes]
442-
values = [self._attr_cache.get(attr) for attr in attributes]
443-
return values

zhaquirks/xiaomi/aqara/cube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
DROP_VALUE = 3
3636
DROPPED = "device_dropped"
3737

38-
FACE_ANY = "fave_any"
38+
FACE_ANY = "face_any"
3939
FACE_1 = "face_1"
4040
FACE_2 = "face_2"
4141
FACE_3 = "face_3"

zhaquirks/xiaomi/aqara/cube_aqgl01.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
DROP_VALUE = 3
3636
DROPPED = "device_dropped"
3737

38-
FACE_ANY = "fave_any"
38+
FACE_ANY = "face_any"
3939
FACE_1 = "face_1"
4040
FACE_2 = "face_2"
4141
FACE_3 = "face_3"

zhaquirks/xiaomi/aqara/plug.py renamed to zhaquirks/xiaomi/aqara/plug_maus01.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Xiaomi aqara button sensor."""
1+
"""Xiaomi lumi.plug.maus01 plug."""
22
import logging
33

44
from zigpy.profiles import zha
@@ -20,12 +20,12 @@
2020

2121
from .. import (
2222
LUMI,
23-
POWER_REPORTED,
23+
AnalogInputCluster,
2424
BasicCluster,
2525
ElectricalMeasurementCluster,
2626
XiaomiCustomDevice,
2727
)
28-
from ... import Bus, CustomCluster
28+
from ... import Bus
2929
from ...const import (
3030
DEVICE_TYPE,
3131
ENDPOINTS,
@@ -39,24 +39,8 @@
3939
_LOGGER = logging.getLogger(__name__)
4040

4141

42-
class AnalogInputCluster(CustomCluster, AnalogInput):
43-
"""Analog input cluster."""
44-
45-
cluster_id = AnalogInput.cluster_id
46-
47-
def __init__(self, *args, **kwargs):
48-
"""Init."""
49-
self._current_state = {}
50-
super().__init__(*args, **kwargs)
51-
52-
def _update_attribute(self, attrid, value):
53-
super()._update_attribute(attrid, value)
54-
if value is not None and value >= 0:
55-
self.endpoint.device.power_bus.listener_event(POWER_REPORTED, value)
56-
57-
5842
class Plug(XiaomiCustomDevice):
59-
"""lumi.plug.maus01 device."""
43+
"""lumi.plug.maus01 plug."""
6044

6145
def __init__(self, *args, **kwargs):
6246
"""Init."""
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
"""Xiaomi lumi.plug.mmeu01 plug."""
2+
import logging
3+
4+
from zigpy.profiles import zha
5+
from zigpy.zcl.clusters.general import (
6+
Alarms,
7+
AnalogInput,
8+
Basic,
9+
DeviceTemperature,
10+
GreenPowerProxy,
11+
Groups,
12+
Identify,
13+
OnOff,
14+
Ota,
15+
Scenes,
16+
Time,
17+
)
18+
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
19+
from zigpy.zcl.clusters.smartenergy import Metering
20+
21+
from .. import (
22+
LUMI,
23+
AnalogInputCluster,
24+
BasicCluster,
25+
ElectricalMeasurementCluster,
26+
XiaomiCustomDevice,
27+
)
28+
from ... import Bus
29+
from ...const import (
30+
DEVICE_TYPE,
31+
ENDPOINTS,
32+
INPUT_CLUSTERS,
33+
MODELS_INFO,
34+
OUTPUT_CLUSTERS,
35+
PROFILE_ID,
36+
SKIP_CONFIGURATION,
37+
)
38+
39+
_LOGGER = logging.getLogger(__name__)
40+
41+
XIAOMI_PROFILE_ID = 0xA1E0
42+
XIAOMI_DEVICE_TYPE = 0x61
43+
44+
45+
class Plug(XiaomiCustomDevice):
46+
"""lumi.plug.mmeu01 plug."""
47+
48+
def __init__(self, *args, **kwargs):
49+
"""Init."""
50+
self.voltage_bus = Bus()
51+
self.consumption_bus = Bus()
52+
self.power_bus = Bus()
53+
super().__init__(*args, **kwargs)
54+
55+
signature = {
56+
MODELS_INFO: [(LUMI, "lumi.plug.mmeu01")],
57+
ENDPOINTS: {
58+
# <SimpleDescriptor endpoint=1 profile=260 device_type=81
59+
# device_version=1
60+
# input_clusters=[0, 2, 3, 4, 5, 6, 9, 1794, 2820]
61+
# output_clusters=[10, 25]>
62+
1: {
63+
PROFILE_ID: zha.PROFILE_ID,
64+
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
65+
INPUT_CLUSTERS: [
66+
Basic.cluster_id,
67+
DeviceTemperature.cluster_id,
68+
Identify.cluster_id,
69+
Groups.cluster_id,
70+
Scenes.cluster_id,
71+
OnOff.cluster_id,
72+
Alarms.cluster_id,
73+
Metering.cluster_id,
74+
ElectricalMeasurement.cluster_id,
75+
],
76+
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
77+
},
78+
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
79+
# device_version=0
80+
# input_clusters=[]
81+
# output_clusters=[33]>
82+
242: {
83+
PROFILE_ID: XIAOMI_PROFILE_ID,
84+
DEVICE_TYPE: XIAOMI_DEVICE_TYPE,
85+
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
86+
},
87+
},
88+
}
89+
replacement = {
90+
SKIP_CONFIGURATION: True,
91+
ENDPOINTS: {
92+
1: {
93+
PROFILE_ID: zha.PROFILE_ID,
94+
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
95+
INPUT_CLUSTERS: [
96+
BasicCluster,
97+
DeviceTemperature.cluster_id,
98+
Identify.cluster_id,
99+
Groups.cluster_id,
100+
Scenes.cluster_id,
101+
OnOff.cluster_id,
102+
Alarms.cluster_id,
103+
Metering.cluster_id,
104+
ElectricalMeasurementCluster,
105+
],
106+
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
107+
},
108+
21: {
109+
PROFILE_ID: zha.PROFILE_ID,
110+
DEVICE_TYPE: zha.DeviceType.MAIN_POWER_OUTLET,
111+
INPUT_CLUSTERS: [AnalogInputCluster],
112+
OUTPUT_CLUSTERS: [AnalogInput.cluster_id, Groups.cluster_id],
113+
},
114+
242: {
115+
PROFILE_ID: XIAOMI_PROFILE_ID,
116+
DEVICE_TYPE: XIAOMI_DEVICE_TYPE,
117+
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
118+
},
119+
},
120+
}

zhaquirks/xiaomi/aqara/relay.py renamed to zhaquirks/xiaomi/aqara/relay_c2acn01.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Xiaomi aqara button sensor."""
1+
"""Xiaomi lumi.relay.c2acn01 relay."""
22
import logging
33

44
from zigpy.profiles import zha
@@ -19,12 +19,12 @@
1919

2020
from .. import (
2121
LUMI,
22-
POWER_REPORTED,
22+
AnalogInputCluster,
2323
BasicCluster,
2424
ElectricalMeasurementCluster,
2525
XiaomiCustomDevice,
2626
)
27-
from ... import Bus, CustomCluster
27+
from ... import Bus
2828
from ...const import (
2929
DEVICE_TYPE,
3030
ENDPOINTS,
@@ -38,24 +38,8 @@
3838
_LOGGER = logging.getLogger(__name__)
3939

4040

41-
class AnalogInputCluster(CustomCluster, AnalogInput):
42-
"""Analog input cluster."""
43-
44-
cluster_id = AnalogInput.cluster_id
45-
46-
def __init__(self, *args, **kwargs):
47-
"""Init."""
48-
self._current_state = {}
49-
super().__init__(*args, **kwargs)
50-
51-
def _update_attribute(self, attrid, value):
52-
super()._update_attribute(attrid, value)
53-
if value is not None and value >= 0:
54-
self.endpoint.device.power_bus.listener_event(POWER_REPORTED, value)
55-
56-
5741
class Relay(XiaomiCustomDevice):
58-
"""lumi.plug.maus01 device."""
42+
"""lumi.relay.c2acn01 relay."""
5943

6044
def __init__(self, *args, **kwargs):
6145
"""Init."""

0 commit comments

Comments
 (0)