Skip to content

Commit 18da059

Browse files
authored
Innr SP120 multiplier fix (#1174)
* Innr SP120 multiplier fix Fix Innr SP120 plug ElectricalMeasurement and Meter cluster multipliers and divisors. * Black code formating * isort + Black * isort * Another isort config try
1 parent d7e9949 commit 18da059

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

zhaquirks/innr/innr_sp120_plug.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
"""Innr SP 120 plug."""
2+
from zigpy.profiles import zll
3+
from zigpy.quirks import CustomCluster, CustomDevice
4+
from zigpy.zcl.clusters.general import (
5+
Basic,
6+
Groups,
7+
Identify,
8+
LevelControl,
9+
OnOff,
10+
Ota,
11+
Scenes,
12+
Time,
13+
)
14+
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
15+
from zigpy.zcl.clusters.lightlink import LightLink
16+
from zigpy.zcl.clusters.smartenergy import Metering
17+
18+
from zhaquirks.const import (
19+
DEVICE_TYPE,
20+
ENDPOINTS,
21+
INPUT_CLUSTERS,
22+
MODELS_INFO,
23+
OUTPUT_CLUSTERS,
24+
PROFILE_ID,
25+
)
26+
27+
MANUFACTURER = "innr"
28+
MODEL = "SP 120"
29+
30+
31+
class MeteringCluster(CustomCluster, Metering):
32+
"""Fix multiplier and divisor."""
33+
34+
cluster_id = Metering.cluster_id
35+
MULTIPLIER = 0x0301
36+
DIVISOR = 0x0302
37+
_CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 100}
38+
39+
40+
class ElectricalMeasurementCluster(CustomCluster, ElectricalMeasurement):
41+
"""Fix multiplier and divisor."""
42+
43+
cluster_id = ElectricalMeasurement.cluster_id
44+
MULTIPLIER = 0x0602
45+
DIVISOR = 0x0603
46+
_CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000}
47+
48+
49+
class SP120(CustomDevice):
50+
"""Innr SP 120 smart plug."""
51+
52+
signature = {
53+
ENDPOINTS: {
54+
1: {
55+
PROFILE_ID: 49246,
56+
DEVICE_TYPE: zll.DeviceType.ON_OFF_PLUGIN_UNIT,
57+
INPUT_CLUSTERS: [
58+
Basic.cluster_id,
59+
ElectricalMeasurement.cluster_id,
60+
Groups.cluster_id,
61+
Identify.cluster_id,
62+
LevelControl.cluster_id,
63+
Metering.cluster_id,
64+
OnOff.cluster_id,
65+
Scenes.cluster_id,
66+
Time.cluster_id,
67+
],
68+
OUTPUT_CLUSTERS: [
69+
Identify.cluster_id,
70+
Ota.cluster_id,
71+
Time.cluster_id,
72+
],
73+
},
74+
2: {
75+
PROFILE_ID: 49246,
76+
DEVICE_TYPE: 0x1000,
77+
INPUT_CLUSTERS: [
78+
LightLink.cluster_id,
79+
],
80+
OUTPUT_CLUSTERS: [],
81+
},
82+
},
83+
MODELS_INFO: [(MANUFACTURER, MODEL)],
84+
}
85+
86+
replacement = {
87+
ENDPOINTS: {
88+
1: {
89+
PROFILE_ID: 0x0104,
90+
DEVICE_TYPE: zll.DeviceType.ON_OFF_PLUGIN_UNIT,
91+
INPUT_CLUSTERS: [
92+
Basic.cluster_id,
93+
ElectricalMeasurementCluster,
94+
Groups.cluster_id,
95+
Identify.cluster_id,
96+
LevelControl.cluster_id,
97+
MeteringCluster,
98+
OnOff.cluster_id,
99+
Scenes.cluster_id,
100+
Time.cluster_id,
101+
],
102+
OUTPUT_CLUSTERS: [
103+
Identify.cluster_id,
104+
Ota.cluster_id,
105+
Time.cluster_id,
106+
],
107+
},
108+
2: {
109+
PROFILE_ID: 49246,
110+
DEVICE_TYPE: 0x1000,
111+
INPUT_CLUSTERS: [
112+
LightLink.cluster_id,
113+
],
114+
OUTPUT_CLUSTERS: [],
115+
},
116+
},
117+
}

0 commit comments

Comments
 (0)