Add (some) of ZCL concentration clusters to ZHA component (#47590)

* Update registries.py

Add concentration clusters recently added to zigpy

* Update measurement.py

Add concentration clusters recently added to ZigPy

* Update sensor.py

Add concentration clusters recently added to ZigPy

* Update sensor.py

remove unnecessary tabs

* Update measurement.py

remove unnecessary tabs

* Update sensor.py

Just adding CO and CO2 for now.

* Update registries.py

Just adding CO2 and CO for now.

* Update measurement.py

Just adding CO2 and CO for now

* Update sensor.py

import const CONCENTRATION_PARTS_PER_MILLION

* Update registries.py

removed trailing whitespace

* Update sensor.py

added extra blank lines and removed trailing whitespace

* Update measurement.py

added extra blank lines and removed trailing whitespace

* Update sensor.py

add device classes for CO and CO2
pull/47583/head
B-Hartley 2021-03-08 16:22:13 +00:00 committed by GitHub
parent 24db0ff956
commit ee2658f9e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 0 deletions

View File

@ -74,3 +74,31 @@ class TemperatureMeasurement(ZigbeeChannel):
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 50),
}
]
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
measurement.CarbonMonoxideConcentration.cluster_id
)
class CarbonMonoxideConcentration(ZigbeeChannel):
"""Carbon Monoxide measurement channel."""
REPORT_CONFIG = [
{
"attr": "measured_value",
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.000001),
}
]
@registries.ZIGBEE_CHANNEL_REGISTRY.register(
measurement.CarbonDioxideConcentration.cluster_id
)
class CarbonDioxideConcentration(ZigbeeChannel):
"""Carbon Dioxide measurement channel."""
REPORT_CONFIG = [
{
"attr": "measured_value",
"config": (REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, 0.000001),
}
]

View File

@ -68,6 +68,8 @@ SINGLE_INPUT_CLUSTER_DEVICE_CLASS = {
zcl.clusters.general.PowerConfiguration.cluster_id: SENSOR,
zcl.clusters.homeautomation.ElectricalMeasurement.cluster_id: SENSOR,
zcl.clusters.hvac.Fan.cluster_id: FAN,
zcl.clusters.measurement.CarbonDioxideConcentration.cluster_id: SENSOR,
zcl.clusters.measurement.CarbonMonoxideConcentration.cluster_id: SENSOR,
zcl.clusters.measurement.IlluminanceMeasurement.cluster_id: SENSOR,
zcl.clusters.measurement.OccupancySensing.cluster_id: BINARY_SENSOR,
zcl.clusters.measurement.PressureMeasurement.cluster_id: SENSOR,

View File

@ -5,6 +5,8 @@ from typing import Any, Callable, Dict, List, Optional, Union
from homeassistant.components.sensor import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CO,
DEVICE_CLASS_CO2,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_POWER,
@ -14,6 +16,7 @@ from homeassistant.components.sensor import (
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
LIGHT_LUX,
PERCENTAGE,
POWER_WATT,
@ -279,3 +282,25 @@ class Temperature(Sensor):
_device_class = DEVICE_CLASS_TEMPERATURE
_divisor = 100
_unit = TEMP_CELSIUS
@STRICT_MATCH(channel_names="carbon_dioxide_concentration")
class CarbonDioxideConcentration(Sensor):
"""Carbon Dioxide Concentration sensor."""
SENSOR_ATTR = "measured_value"
_device_class = DEVICE_CLASS_CO2
_decimals = 0
_multiplier = 1e6
_unit = CONCENTRATION_PARTS_PER_MILLION
@STRICT_MATCH(channel_names="carbon_monoxide_concentration")
class CarbonMonoxideConcentration(Sensor):
"""Carbon Monoxide Concentration sensor."""
SENSOR_ATTR = "measured_value"
_device_class = DEVICE_CLASS_CO
_decimals = 0
_multiplier = 1e6
_unit = CONCENTRATION_PARTS_PER_MILLION