Skip to content

Commit

Permalink
Merge pull request #1453 from Vova-SH/master
Browse files Browse the repository at this point in the history
Add support for LifeControl MCLH-08
  • Loading branch information
AlexxIT authored Oct 27, 2024
2 parents 15503ec + 142c0d6 commit 3f3eff5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions custom_components/xiaomi_gateway3/core/converters/zigbee.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,22 @@ def decode(self, device: "XDevice", payload: dict, data: dict):
except:
pass

@dataclass
class ZLifeControlHumidity(ZMathConv):
cluster_id = TemperatureMeasurement.cluster_id
attr_id = TemperatureMeasurement.AttributeDefs.min_measured_value.id
multiply: float = 0.01

@dataclass
class ZLifeControlECO2(ZMathConv):
cluster_id = TemperatureMeasurement.cluster_id
attr_id = TemperatureMeasurement.AttributeDefs.max_measured_value.id

@dataclass
class ZLifeControlVOC(ZMathConv):
cluster_id = TemperatureMeasurement.cluster_id
attr_id = TemperatureMeasurement.AttributeDefs.tolerance.id


# Thanks to zigbee2mqtt:
# https://github.com/Koenkk/zigbee-herdsman/blob/528b7626f2970ba87a0792920590926105a3cb48/src/zcl/definition/cluster.ts#LL460C32-L460C37
Expand Down
9 changes: 9 additions & 0 deletions custom_components/xiaomi_gateway3/core/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,15 @@
ZIASZoneConv("moisture", "binary_sensor"),
ZBatteryPercConv("battery", "sensor", multiply=1.0),
],
}, {
"VOC_Sensor": ["LifeControl", "Air quality Sensor", "MCLH-08"],
"spec": [
ZTemperatureConv("temperature", "sensor"),
ZLifeControlHumidity("humidity", "sensor"),
ZLifeControlECO2("eco_two", "sensor"),
ZLifeControlVOC("tvoc", "sensor"),
ZBatteryPercConv("battery", "sensor", multiply=1.0),
],
}, {
"default": "zigbee", # default zigbee device
"spec": [
Expand Down
2 changes: 2 additions & 0 deletions custom_components/xiaomi_gateway3/hass/entity_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from homeassistant.const import (
CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
MAJOR_VERSION,
MINOR_VERSION,
Expand Down Expand Up @@ -86,6 +87,7 @@
"smoke_density": {"icon": "mdi:google-circles-communities", "units": "% obs/ft"},
"supply": {"icon": "mdi:gauge", "units": PERCENTAGE},
"tvoc": {"icon": "mdi:cloud", "units": CONCENTRATION_PARTS_PER_BILLION},
"eco_two": {"name": "eCO2", "icon": "mdi:molecule-co2", "units": CONCENTRATION_PARTS_PER_MILLION},
##
# stats sensors
"binary_sensor.gateway": {
Expand Down

0 comments on commit 3f3eff5

Please sign in to comment.