forked from zigpy/zha-device-handlers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
z03mmc.py
153 lines (130 loc) · 5.06 KB
/
z03mmc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
"""Xiaomi LYWSD03MMC Bluetooth temperature and humidity sensor."""
from zigpy.profiles import zha
from zigpy.types import Bool, int16s, uint16_t
from zigpy.zcl.clusters.general import Basic, Identify, Ota, PowerConfiguration
from zigpy.zcl.clusters.hvac import UserInterface
from zigpy.zcl.clusters.measurement import RelativeHumidity, TemperatureMeasurement
from zigpy.zcl.foundation import ZCLAttributeDef
from zhaquirks import CustomCluster
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.xiaomi import XiaomiCustomDevice
class TemperatureMeasurementCustom(CustomCluster, TemperatureMeasurement):
"""Temperature Measurement Cluster with calibration attribute."""
class AttributeDefs(TemperatureMeasurement.AttributeDefs):
"""Attribute Definitions."""
# A value in 0.01ºC offset to fix up incorrect values from sensor
temperature_calibration = ZCLAttributeDef(
id=0x0010,
type=int16s,
access="rw",
is_manufacturer_specific=True,
)
class RelativeHumidityCustom(CustomCluster, RelativeHumidity):
"""Relative Humidity Cluster with calibration attribute."""
class AttributeDefs(RelativeHumidity.AttributeDefs):
"""Attribute Definitions."""
# A value in 0.01%RH offset to fix up incorrect values from sensor
humidity_calibration = ZCLAttributeDef(
id=0x0010,
type=int16s,
access="rw",
is_manufacturer_specific=True,
)
class UserInterfaceCustom(CustomCluster, UserInterface):
"""Custom User Interface Cluster with smiley control."""
class AttributeDefs(UserInterface.AttributeDefs):
"""Attribute Definitions."""
# of the 3 ZCL Thermostat User Interface spec attributes,
# only the first one (TemperatureDisplayMode) is implemented fully.
# KeypadLockout is implemented but completely unused in the device firmware
# and ScheduleProgrammingVisibility is not implemented at all
# https://github.com/devbis/z03mmc/blob/1.1.0/src/sensorEpCfg.c#L256
# 0 - smiley is off, 1 - smiley is on (according to comfort values)
smiley = ZCLAttributeDef(
id=0x0010,
type=Bool,
access="rw",
is_manufacturer_specific=True,
)
# display. 0 - display is off, 1 - display is on
display = ZCLAttributeDef(
id=0x0011,
type=Bool,
access="rw",
is_manufacturer_specific=True,
)
# comfort temperature min: A value in 0.01ºC to set minimum comfort temperature for happy face
comfort_temperature_min = ZCLAttributeDef(
id=0x0102,
type=int16s,
access="rw",
is_manufacturer_specific=True,
)
# comfort temperature max: A value in 0.01ºC to set maximum comfort temperature for happy face
comfort_temperature_max = ZCLAttributeDef(
id=0x0103,
type=int16s,
access="rw",
is_manufacturer_specific=True,
)
# comfort humidity min: A value in 0.01%RH to set minimum comfort humidity for happy face
comfort_humidity_min = ZCLAttributeDef(
id=0x0104,
type=uint16_t,
access="rw",
is_manufacturer_specific=True,
)
# comfort humidity max: A value in 0.01%RH to set maximum comfort humidity for happy face
comfort_humidity_max = ZCLAttributeDef(
id=0x0105,
type=uint16_t,
access="rw",
is_manufacturer_specific=True,
)
# https://github.com/devbis/z03mmc
# defined by 1.1.0 firmware (0x11003001)
# see README.md in the repo for more info
class LYWSD03MMC_devbis(XiaomiCustomDevice):
"""LYWSD03MMC sensor with devbis custom firmware."""
signature = {
MODELS_INFO: [("Xiaomi", "LYWSD03MMC")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
PowerConfiguration.cluster_id,
RelativeHumidity.cluster_id,
TemperatureMeasurement.cluster_id,
UserInterface.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
PowerConfiguration.cluster_id,
RelativeHumidityCustom,
TemperatureMeasurementCustom,
UserInterfaceCustom,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
},
}