Add entites for air purifier #72

This commit is contained in:
Andre Basche 2023-06-21 00:59:00 +02:00
parent a181359faa
commit 78727e89cd
9 changed files with 225 additions and 50 deletions

View file

@ -242,6 +242,16 @@ BINARY_SENSORS: dict[str, tuple[HonBinarySensorEntityDescription, ...]] = {
translation_key="holiday_mode",
),
),
"AP": (
HonBinarySensorEntityDescription(
key="attributes.parameters.onOffStatus",
name="On",
device_class=BinarySensorDeviceClass.RUNNING,
on_value="1",
icon="mdi:power-cycle",
translation_key="on",
),
),
}

View file

@ -188,3 +188,18 @@ AC_HUMAN_SENSE = {
"2": "follow_touch",
"3": "unknown",
}
AP_MACH_MODE = {
"0": "standby",
"1": "sleep",
"2": "auto",
"3": "allergens",
"4": "max",
}
AP_DIFFUSER_LEVEL = {
"1": "soft",
"2": "mid",
"3": "h_biotics",
"4": "custom",
}

View file

@ -167,7 +167,29 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
key="startProgram.lightStatus",
name="Light status",
icon="mdi:lightbulb",
entity_category=EntityCategory.CONFIG,
),
),
"AP": (
HonNumberEntityDescription(
key="settings.aromaTimeOn",
name="Aroma Time On",
icon="mdi:thermometer",
native_unit_of_measurement=UnitOfTime.SECONDS,
),
HonNumberEntityDescription(
key="settings.aromaTimeOff",
name="Aroma Time Off",
icon="mdi:thermometer",
native_unit_of_measurement=UnitOfTime.SECONDS,
),
HonNumberEntityDescription(
key="settings.lightStatus",
name="Light status",
icon="mdi:lightbulb",
),
HonNumberEntityDescription(
key="settings.pollenLevel",
name="Pollen Level",
),
),
}
@ -206,7 +228,7 @@ class HonNumberEntity(HonEntity, NumberEntity):
@property
def native_value(self) -> float | None:
return self._device.get(self.entity_description.key)
return self._device.get(self.entity_description.key.split(".")[-1])
async def async_set_native_value(self, value: float) -> None:
setting = self._device.settings[self.entity_description.key]
@ -223,7 +245,7 @@ class HonNumberEntity(HonEntity, NumberEntity):
self._attr_native_max_value = setting.max
self._attr_native_min_value = setting.min
self._attr_native_step = setting.step
self._attr_native_value = setting.value
self._attr_native_value = self.native_value
if update:
self.async_write_ha_state()

View file

@ -133,6 +133,19 @@ SELECTS = {
translation_key="ref_zones",
),
),
"AP": (
HonSelectEntityDescription(
key="settings.aromaStatus",
name="Diffuser Level",
option_list=const.AP_DIFFUSER_LEVEL,
),
HonSelectEntityDescription(
key="settings.machMode",
name="Mode",
icon="mdi:run",
option_list=const.AP_MACH_MODE,
),
),
}
SELECTS["WD"] = unique_entities(SELECTS["WM"], SELECTS["TD"])

View file

@ -9,7 +9,12 @@ from homeassistant.components.sensor import (
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE
from homeassistant.const import (
PERCENTAGE,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
)
from homeassistant.const import (
REVOLUTIONS_PER_MINUTE,
UnitOfEnergy,
@ -637,6 +642,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
name="Temperature",
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="temperature",
),
@ -673,6 +679,7 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
icon="mdi:thermometer",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
translation_key="temperature",
),
HonSensorEntityDescription(
@ -683,6 +690,76 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
translation_key="programs_wc",
),
),
"AP": (
HonSensorEntityDescription(
key="errors", name="Error", icon="mdi:math-log", translation_key="errors"
),
HonSensorEntityDescription(
key="mainFilterStatus",
name="Main Filter Status",
native_unit_of_measurement=PERCENTAGE,
),
HonSensorEntityDescription(
key="preFilterStatus",
name="Pre Filter Status",
native_unit_of_measurement=PERCENTAGE,
),
HonSensorEntityDescription(
key="totalWorkTime",
name="Total Work Time",
native_unit_of_measurement=UnitOfTime.MINUTES,
device_class=SensorDeviceClass.DURATION,
),
HonSensorEntityDescription(
key="coLevel",
name="CO Level",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.CO,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
),
HonSensorEntityDescription(
key="pm10ValueIndoor",
name="pm10",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.PM10,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
),
HonSensorEntityDescription(
key="pm2p5ValueIndoor",
name="pm2p5",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.PM25,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
),
HonSensorEntityDescription(
key="vocValueIndoor",
name="VOC",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION,
),
HonSensorEntityDescription(
key="humidityIndoor",
name="Humidity",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE,
translation_key="humidity",
),
HonSensorEntityDescription(
key="temp",
name="Temperature",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
translation_key="temperature",
),
HonSensorEntityDescription(key="windSpeed", name="Wind Speed"),
HonSensorEntityDescription(
key="airQuality",
name="Air Quality",
),
),
}
SENSORS["WD"] = unique_entities(SENSORS["WM"], SENSORS["TD"])

View file

@ -333,6 +333,16 @@ SWITCHES: dict[str, tuple[HonSwitchEntityDescription, ...]] = {
key="lightStatus", name="Light", icon="mdi:lightbulb"
),
),
"AP": (
HonSwitchEntityDescription(
key="touchToneStatus",
name="Touch Tone",
),
HonSwitchEntityDescription(
key="lockStatus",
name="Lock Status",
),
),
}
SWITCHES["WD"] = unique_entities(SWITCHES["WD"], SWITCHES["WM"])