mirror of
https://github.com/home-assistant/core.git
synced 2026-09-07 22:20:07 +01:00
Co-authored-by: Simone Chemelli <simone.chemelli@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick@koston.org>
823 lines
29 KiB
Python
823 lines
29 KiB
Python
"""Midea Sensor entities."""
|
|
|
|
from dataclasses import dataclass
|
|
from typing import cast, override
|
|
|
|
from midealocal.const import DeviceType
|
|
|
|
from homeassistant.components.sensor import (
|
|
EntityCategory,
|
|
SensorDeviceClass,
|
|
SensorEntity,
|
|
SensorEntityDescription,
|
|
SensorStateClass,
|
|
)
|
|
from homeassistant.const import (
|
|
REVOLUTIONS_PER_MINUTE,
|
|
UnitOfDensity,
|
|
UnitOfElectricCurrent,
|
|
UnitOfElectricPotential,
|
|
UnitOfEnergy,
|
|
UnitOfFrequency,
|
|
UnitOfPower,
|
|
UnitOfRatio,
|
|
UnitOfTemperature,
|
|
UnitOfTime,
|
|
UnitOfVolume,
|
|
UnitOfVolumeFlowRate,
|
|
)
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|
from homeassistant.helpers.typing import StateType
|
|
|
|
from .entity import MideaConfigEntry, MideaEntity
|
|
|
|
PARALLEL_UPDATES = 0
|
|
|
|
|
|
@dataclass(kw_only=True, frozen=True)
|
|
class MideaSensorEntityDescription(SensorEntityDescription):
|
|
"""Describes Midea sensor entity."""
|
|
|
|
models: list[DeviceType] | None = None
|
|
|
|
|
|
COOKER_MODES: list[str] = [
|
|
"smart",
|
|
"reserve",
|
|
"cook_rice",
|
|
"fast_cook_rice",
|
|
"standard_cook_rice",
|
|
"gruel",
|
|
"cook_congee",
|
|
"stew_soup",
|
|
"stewing",
|
|
"heat_rice",
|
|
"make_cake",
|
|
"yoghourt",
|
|
"soup_rice",
|
|
"coarse_rice",
|
|
"five_ceeals_rice",
|
|
"eight_treasures_rice",
|
|
"crispy_rice",
|
|
"shelled_rice",
|
|
"eight_treasures_congee",
|
|
"infant_congee",
|
|
"older_rice",
|
|
"rice_soup",
|
|
"rice_paste",
|
|
"egg_custard",
|
|
"warm_milk",
|
|
"hot_spring_egg",
|
|
"millet_congee",
|
|
"firewood_rice",
|
|
"few_rice",
|
|
"red_potato",
|
|
"corn",
|
|
"quick_freeze_bun",
|
|
"steam_ribs",
|
|
"steam_egg",
|
|
"coarse_congee",
|
|
"steep_rice",
|
|
"appetizing_congee",
|
|
"corn_congee",
|
|
"sprout_rice",
|
|
"luscious_rice",
|
|
"luscious_boiled",
|
|
"fast_rice",
|
|
"fast_boil",
|
|
"bean_rice_congee",
|
|
"fast_congee",
|
|
"baby_congee",
|
|
"cook_soup",
|
|
"congee_coup",
|
|
"steam_corn",
|
|
"steam_red_potato",
|
|
"boil_congee",
|
|
"delicious_steam",
|
|
"boil_egg",
|
|
"rice_wine",
|
|
"fruit_vegetable_paste",
|
|
"vegetable_porridge",
|
|
"pork_porridge",
|
|
"fragrant_rice",
|
|
"assorte_rice",
|
|
"steame_fish",
|
|
"baby_rice",
|
|
"essence_rice",
|
|
"fragrant_dense_congee",
|
|
"one_two_cook",
|
|
"original_steame",
|
|
"hot_fast_rice",
|
|
"online_celebrity_rice",
|
|
"sushi_rice",
|
|
"stone_bowl_rice",
|
|
"no_water_treat",
|
|
"keep_fresh",
|
|
"low_sugar_rice",
|
|
"black_buckwheat_rice",
|
|
"resveratrol_rice",
|
|
"yellow_wheat_rice",
|
|
"green_buckwheat_rice",
|
|
"roughage_rice",
|
|
"millet_mixed_rice",
|
|
"iron_pan_rice",
|
|
"olla_pan_rice",
|
|
"vegetable_rice",
|
|
"baby_side",
|
|
"regimen_congee",
|
|
"earthen_pot_congee",
|
|
"regimen_soup",
|
|
"pottery_jar_soup",
|
|
"canton_soup",
|
|
"nutrition_stew",
|
|
"northeast_stew",
|
|
"uncap_boil",
|
|
"trichromatic_coarse_grain",
|
|
"four_color_vegetables",
|
|
"egg",
|
|
"chop",
|
|
"clean",
|
|
"keep_warm",
|
|
]
|
|
|
|
|
|
SENSOR_ENTITIES: list[MideaSensorEntityDescription] = [
|
|
MideaSensorEntityDescription(
|
|
key="indoor_humidity",
|
|
translation_key="indoor_humidity",
|
|
device_class=SensorDeviceClass.HUMIDITY,
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="indoor_temperature",
|
|
translation_key="indoor_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="outdoor_temperature",
|
|
translation_key="outdoor_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="total_energy_consumption",
|
|
translation_key="total_energy_consumption",
|
|
device_class=SensorDeviceClass.ENERGY,
|
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="current_energy_consumption",
|
|
translation_key="current_energy_consumption",
|
|
device_class=SensorDeviceClass.ENERGY,
|
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="realtime_power",
|
|
translation_key="realtime_power",
|
|
device_class=SensorDeviceClass.POWER,
|
|
native_unit_of_measurement=UnitOfPower.WATT,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="pmv",
|
|
translation_key="pmv",
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
entity_registry_enabled_default=False,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="compressor_frequency",
|
|
translation_key="compressor_frequency",
|
|
device_class=SensorDeviceClass.FREQUENCY,
|
|
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="target_compressor_frequency",
|
|
translation_key="target_compressor_frequency",
|
|
device_class=SensorDeviceClass.FREQUENCY,
|
|
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="compressor_current",
|
|
translation_key="compressor_current",
|
|
device_class=SensorDeviceClass.CURRENT,
|
|
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="compressor_voltage",
|
|
translation_key="compressor_voltage",
|
|
device_class=SensorDeviceClass.VOLTAGE,
|
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="indoor_coil_temperature",
|
|
translation_key="indoor_coil_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="evaporator_temperature",
|
|
translation_key="evaporator_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="condenser_temperature",
|
|
translation_key="condenser_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="outdoor_ambient_temperature",
|
|
translation_key="outdoor_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="discharge_pipe_temperature",
|
|
translation_key="discharge_pipe_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="indoor_fan_speed",
|
|
translation_key="indoor_fan_speed",
|
|
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="target_indoor_fan_speed",
|
|
translation_key="target_indoor_fan_speed",
|
|
native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="compressor_power",
|
|
translation_key="compressor_power",
|
|
device_class=SensorDeviceClass.POWER,
|
|
native_unit_of_measurement=UnitOfPower.WATT,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="tank_actual_temperature",
|
|
translation_key="tank_actual_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="total_produced_energy",
|
|
translation_key="total_produced_energy",
|
|
device_class=SensorDeviceClass.ENERGY,
|
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="temp_tw_in",
|
|
translation_key="temp_tw_in",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="temp_tw_out",
|
|
translation_key="temp_tw_out",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="instant_power0",
|
|
device_class=SensorDeviceClass.POWER,
|
|
native_unit_of_measurement=UnitOfPower.WATT,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="compressor_temperature",
|
|
translation_key="compressor_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="current_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="current_humidity",
|
|
device_class=SensorDeviceClass.HUMIDITY,
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="humidity",
|
|
device_class=SensorDeviceClass.HUMIDITY,
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="mode",
|
|
translation_key="mode",
|
|
models=[DeviceType.DB],
|
|
device_class=SensorDeviceClass.ENUM,
|
|
options=["normal", "factory_test", "service", "normal_continus"],
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="mode",
|
|
translation_key="mode",
|
|
models=[DeviceType.EA],
|
|
device_class=SensorDeviceClass.ENUM,
|
|
options=COOKER_MODES,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="mode",
|
|
translation_key="mode",
|
|
models=[DeviceType.EC],
|
|
device_class=SensorDeviceClass.ENUM,
|
|
options=[*COOKER_MODES, "diy"],
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="tank",
|
|
translation_key="tank_level",
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="temperature_raw",
|
|
translation_key="temperature_raw",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="humidity_raw",
|
|
translation_key="humidity_raw",
|
|
device_class=SensorDeviceClass.HUMIDITY,
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="temperature_compensate",
|
|
translation_key="temperature_compensate",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="humidity_compensate",
|
|
translation_key="humidity_compensate",
|
|
device_class=SensorDeviceClass.HUMIDITY,
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="tvoc",
|
|
translation_key="tvoc",
|
|
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
|
native_unit_of_measurement=UnitOfRatio.PARTS_PER_MILLION,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="co2",
|
|
device_class=SensorDeviceClass.CO2,
|
|
native_unit_of_measurement=UnitOfRatio.PARTS_PER_MILLION,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="pm25",
|
|
device_class=SensorDeviceClass.PM25,
|
|
native_unit_of_measurement=UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="hcho",
|
|
translation_key="hcho",
|
|
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
|
|
native_unit_of_measurement=UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="top_compartment_temperature",
|
|
translation_key="top_compartment_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="middle_compartment_temperature",
|
|
translation_key="middle_compartment_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="bottom_compartment_temperature",
|
|
translation_key="bottom_compartment_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="water_temperature",
|
|
translation_key="water_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="seat_temperature",
|
|
translation_key="seat_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="filter_life",
|
|
translation_key="filter_life",
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="flex_zone_actual_temp",
|
|
translation_key="flex_zone_actual_temp",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="flex_zone_setting_temp",
|
|
translation_key="flex_zone_setting_temp",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="freezer_actual_temp",
|
|
translation_key="freezer_actual_temp",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="freezer_setting_temp",
|
|
translation_key="freezer_setting_temp",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="energy_consumption",
|
|
translation_key="energy_consumption",
|
|
device_class=SensorDeviceClass.ENERGY,
|
|
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="refrigerator_actual_temp",
|
|
translation_key="refrigerator_actual_temp",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="refrigerator_setting_temp",
|
|
translation_key="refrigerator_setting_temp",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="right_flex_zone_actual_temp",
|
|
translation_key="right_flex_zone_actual_temp",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="right_flex_zone_setting_temp",
|
|
translation_key="right_flex_zone_setting_temp",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="variable_mode",
|
|
translation_key="variable_mode",
|
|
device_class=SensorDeviceClass.ENUM,
|
|
options=[
|
|
"none",
|
|
"soft_freezing",
|
|
"zero_fresh",
|
|
"cold_drink",
|
|
"fresh_product",
|
|
"partial_freezing",
|
|
"dry_zone",
|
|
"freeze_warm",
|
|
],
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="wash_time",
|
|
translation_key="wash_time",
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.MINUTES,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="soak_time",
|
|
translation_key="soak_time",
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.MINUTES,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="dehydration_time",
|
|
translation_key="dehydration_time",
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.MINUTES,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="dry_temperature",
|
|
translation_key="dry_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="heating_power",
|
|
translation_key="heating_power",
|
|
models=[DeviceType.E2],
|
|
device_class=SensorDeviceClass.POWER,
|
|
native_unit_of_measurement=UnitOfPower.WATT,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="water_consumption",
|
|
translation_key="water_consumption",
|
|
device_class=SensorDeviceClass.WATER,
|
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="heating_leaving_temperature",
|
|
translation_key="heating_leaving_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="bathing_leaving_temperature",
|
|
translation_key="bathing_leaving_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="target_temperature",
|
|
translation_key="target_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
models=[DeviceType.E8],
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="bottom_temperature",
|
|
translation_key="bottom_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="keep_warm_time",
|
|
translation_key="keep_warm_time",
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.MINUTES,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
models=[DeviceType.EA, DeviceType.EC],
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="keep_warm_time",
|
|
translation_key="keep_warm_time",
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.HOURS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
models=[DeviceType.ED],
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="top_temperature",
|
|
translation_key="top_temperature",
|
|
device_class=SensorDeviceClass.TEMPERATURE,
|
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="filter1",
|
|
translation_key="filter_available_days",
|
|
translation_placeholders={"filter_number": "1"},
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.DAYS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="filter2",
|
|
translation_key="filter_available_days",
|
|
translation_placeholders={"filter_number": "2"},
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.DAYS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="filter3",
|
|
translation_key="filter_available_days",
|
|
translation_placeholders={"filter_number": "3"},
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.DAYS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="life1",
|
|
translation_key="filter_life_level",
|
|
translation_placeholders={"filter_number": "1"},
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="life2",
|
|
translation_key="filter_life_level",
|
|
translation_placeholders={"filter_number": "2"},
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="life3",
|
|
translation_key="filter_life_level",
|
|
translation_placeholders={"filter_number": "3"},
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="filter1_life",
|
|
translation_key="filter_life_level",
|
|
translation_placeholders={"filter_number": "1"},
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="filter2_life",
|
|
translation_key="filter_life_level",
|
|
translation_placeholders={"filter_number": "2"},
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="in_tds",
|
|
translation_key="in_tds",
|
|
native_unit_of_measurement=UnitOfRatio.PARTS_PER_MILLION,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="out_tds",
|
|
translation_key="out_tds",
|
|
native_unit_of_measurement=UnitOfRatio.PARTS_PER_MILLION,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="velocity",
|
|
translation_key="flow_rate",
|
|
device_class=SensorDeviceClass.VOLUME_FLOW_RATE,
|
|
native_unit_of_measurement=UnitOfVolumeFlowRate.LITERS_PER_SECOND,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="soft_available",
|
|
translation_key="softwater_available",
|
|
device_class=SensorDeviceClass.VOLUME_STORAGE,
|
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="left_salt",
|
|
translation_key="salt_available",
|
|
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="remaining_days",
|
|
translation_key="remaining_days",
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.DAYS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="use_days",
|
|
translation_key="use_days",
|
|
device_class=SensorDeviceClass.DURATION,
|
|
native_unit_of_measurement=UnitOfTime.DAYS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="water_consumption_big",
|
|
translation_key="water_consumption_big",
|
|
device_class=SensorDeviceClass.WATER,
|
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
|
suggested_display_precision=2,
|
|
),
|
|
MideaSensorEntityDescription(
|
|
key="water_consumption_average",
|
|
translation_key="water_consumption_average",
|
|
device_class=SensorDeviceClass.VOLUME,
|
|
native_unit_of_measurement=UnitOfVolume.LITERS,
|
|
state_class=SensorStateClass.MEASUREMENT,
|
|
),
|
|
]
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
config_entry: MideaConfigEntry,
|
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
|
) -> None:
|
|
"""Set up sensors for device."""
|
|
device = config_entry.runtime_data
|
|
|
|
sensors: list[MideaSensor] = [
|
|
MideaSensor(device, description)
|
|
for description in SENSOR_ENTITIES
|
|
if device.attributes.get(description.key) is not None
|
|
and (not description.models or device.device_type in description.models)
|
|
]
|
|
|
|
async_add_entities(sensors)
|
|
|
|
|
|
class MideaSensor(MideaEntity, SensorEntity):
|
|
"""Represent a Midea sensor."""
|
|
|
|
@property
|
|
@override
|
|
def native_value(self) -> StateType:
|
|
"""Native value of the sensor."""
|
|
value = self._device.get_attribute(self.entity_description.key)
|
|
if (
|
|
self.entity_description.key == "indoor_humidity"
|
|
and isinstance(value, (int, float))
|
|
and value in {0, 0xFF}
|
|
):
|
|
return None
|
|
if value == "unknown":
|
|
return None
|
|
return cast("StateType", value)
|