Add sensor platform to Midea (#177884)

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>
This commit is contained in:
Lucas Mindêllo de Andrade
2026-08-26 13:53:19 +02:00
committed by GitHub
co-authored by Simone Chemelli Copilot Autofix powered by AI J. Nick Koston
parent 0c6f3c7578
commit 7c662cdfd1
8 changed files with 3570 additions and 0 deletions
@@ -34,6 +34,7 @@ _PLATFORMS: list[Platform] = [
Platform.LIGHT,
Platform.NUMBER,
Platform.SELECT,
Platform.SENSOR,
Platform.SWITCH,
]
@@ -5,14 +5,30 @@ from midealocal.const import DeviceType
MIDEA_DEVICE_NAMES: dict[DeviceType, str] = {
DeviceType.A1: "Dehumidifier",
DeviceType.AC: "Air Conditioner",
DeviceType.AD: "Air Detector",
DeviceType.B0: "Microwave Oven",
DeviceType.B1: "Electric Oven",
DeviceType.B3: "Dish Sterilizer",
DeviceType.B4: "Toaster",
DeviceType.B6: "Range Hood",
DeviceType.BF: "Microwave Steam Oven",
DeviceType.C2: "Toilet",
DeviceType.C3: "Heat Pump Wi-Fi Controller",
DeviceType.CA: "Refrigerator",
DeviceType.CC: "MDV Wi-Fi Controller",
DeviceType.CD: "Heat Pump Water Heater",
DeviceType.CE: "Fresh Air Appliance",
DeviceType.CF: "Heat Pump",
DeviceType.DA: "Top Load Washer",
DeviceType.DB: "Front Load Washer",
DeviceType.DC: "Clothes Dryer",
DeviceType.E1: "Dishwasher",
DeviceType.E2: "Electric Water Heater",
DeviceType.E3: "Gas Water Heater",
DeviceType.E6: "Gas Boiler",
DeviceType.E8: "Electric Slow Cooker",
DeviceType.EA: "Electric Rice Cooker",
DeviceType.EC: "Electric Pressure Cooker",
DeviceType.ED: "Water Drinking Appliance",
DeviceType.FA: "Fan",
DeviceType.FB: "Electric Heater",
@@ -20,5 +36,6 @@ MIDEA_DEVICE_NAMES: dict[DeviceType, str] = {
DeviceType.FD: "Humidifier",
DeviceType.X13: "Light",
DeviceType.X26: "Bathroom Master",
DeviceType.X34: "Sink Dishwasher",
DeviceType.X40: "Integrated Ceiling Fan",
}
+32
View File
@@ -27,6 +27,38 @@
}
}
}
},
"sensor": {
"filter_life": {
"default": "mdi:air-filter"
},
"filter_life_level": {
"default": "mdi:air-filter"
},
"hcho": {
"default": "mdi:molecule"
},
"in_tds": {
"default": "mdi:water"
},
"indoor_fan_speed": {
"default": "mdi:fan"
},
"mode": {
"default": "mdi:auto-mode"
},
"out_tds": {
"default": "mdi:water-plus"
},
"pmv": {
"default": "mdi:thermometer-lines"
},
"tank_level": {
"default": "mdi:cup-water"
},
"target_indoor_fan_speed": {
"default": "mdi:fan-clock"
}
}
}
}
+822
View File
@@ -0,0 +1,822 @@
"""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)
+325
View File
@@ -319,6 +319,331 @@
}
}
},
"sensor": {
"bathing_leaving_temperature": {
"name": "Bathing leaving temperature"
},
"bottom_compartment_temperature": {
"name": "Bottom compartment temperature"
},
"bottom_temperature": {
"name": "Bottom temperature"
},
"compressor_current": {
"name": "Compressor current"
},
"compressor_frequency": {
"name": "Compressor frequency"
},
"compressor_power": {
"name": "Compressor power"
},
"compressor_temperature": {
"name": "Compressor temperature"
},
"compressor_voltage": {
"name": "Compressor voltage"
},
"condenser_temperature": {
"name": "Condenser temperature"
},
"current_energy_consumption": {
"name": "Current energy consumption"
},
"dehydration_time": {
"name": "Dehydration time"
},
"discharge_pipe_temperature": {
"name": "Discharge pipe temperature"
},
"dry_temperature": {
"name": "Dry temperature"
},
"energy_consumption": {
"name": "Energy consumption"
},
"evaporator_temperature": {
"name": "Evaporator temperature"
},
"filter_available_days": {
"name": "Filter {filter_number} available days"
},
"filter_life": {
"name": "Filter life"
},
"filter_life_level": {
"name": "Filter {filter_number} life level"
},
"flex_zone_actual_temp": {
"name": "Flex zone actual temperature"
},
"flex_zone_setting_temp": {
"name": "Flex zone setting temperature"
},
"flow_rate": {
"name": "Flow rate"
},
"freezer_actual_temp": {
"name": "Freezer actual temperature"
},
"freezer_setting_temp": {
"name": "Freezer setting temperature"
},
"hcho": {
"name": "Formaldehyde"
},
"heating_leaving_temperature": {
"name": "Heating leaving temperature"
},
"heating_power": {
"name": "Heating power"
},
"humidity_compensate": {
"name": "Humidity compensation"
},
"humidity_raw": {
"name": "Raw humidity"
},
"in_tds": {
"name": "In TDS"
},
"indoor_coil_temperature": {
"name": "Indoor coil temperature"
},
"indoor_fan_speed": {
"name": "Indoor fan speed"
},
"indoor_humidity": {
"name": "Indoor humidity"
},
"indoor_temperature": {
"name": "Indoor temperature"
},
"keep_warm_time": {
"name": "Keep warm time"
},
"middle_compartment_temperature": {
"name": "Middle compartment temperature"
},
"mode": {
"name": "Mode",
"state": {
"appetizing_congee": "Appetizing congee",
"assorte_rice": "Assorted rice",
"baby_congee": "Baby congee",
"baby_rice": "Baby rice",
"baby_side": "Baby side",
"bean_rice_congee": "Bean rice congee",
"black_buckwheat_rice": "Black buckwheat rice",
"boil_congee": "Boil congee",
"boil_egg": "Boil egg",
"canton_soup": "Canton soup",
"chop": "Chop",
"clean": "Clean",
"coarse_congee": "Coarse congee",
"coarse_rice": "Coarse rice",
"congee_coup": "Congee soup",
"cook_congee": "Cook congee",
"cook_rice": "Cook rice",
"cook_soup": "Cook soup",
"corn": "Corn",
"corn_congee": "Corn congee",
"crispy_rice": "Crispy rice",
"delicious_steam": "Delicious steam",
"diy": "DIY",
"earthen_pot_congee": "Earthen pot congee",
"egg": "Egg",
"egg_custard": "Egg custard",
"eight_treasures_congee": "Eight treasures congee",
"eight_treasures_rice": "Eight treasures rice",
"essence_rice": "Essence rice",
"factory_test": "Factory test",
"fast_boil": "Fast boil",
"fast_congee": "Fast congee",
"fast_cook_rice": "Fast cook rice",
"fast_rice": "Fast rice",
"few_rice": "Few rice",
"firewood_rice": "Firewood rice",
"five_ceeals_rice": "Five cereals rice",
"four_color_vegetables": "Four color vegetables",
"fragrant_dense_congee": "Fragrant dense congee",
"fragrant_rice": "Fragrant rice",
"fruit_vegetable_paste": "Fruit vegetable paste",
"green_buckwheat_rice": "Green buckwheat rice",
"gruel": "Gruel",
"heat_rice": "Heat rice",
"hot_fast_rice": "Hot fast rice",
"hot_spring_egg": "Hot spring egg",
"infant_congee": "Infant congee",
"iron_pan_rice": "Iron pan rice",
"keep_fresh": "Keep fresh",
"keep_warm": "Keep warm",
"low_sugar_rice": "Low sugar rice",
"luscious_boiled": "Luscious boiled",
"luscious_rice": "Luscious rice",
"make_cake": "Make cake",
"millet_congee": "Millet congee",
"millet_mixed_rice": "Millet mixed rice",
"no_water_treat": "No water treat",
"normal": "Normal",
"normal_continus": "Normal continuous",
"northeast_stew": "Northeast stew",
"nutrition_stew": "Nutrition stew",
"older_rice": "Older rice",
"olla_pan_rice": "Olla pan rice",
"one_two_cook": "One two cook",
"online_celebrity_rice": "Online celebrity rice",
"original_steame": "Original steam",
"pork_porridge": "Pork porridge",
"pottery_jar_soup": "Pottery jar soup",
"quick_freeze_bun": "Quick freeze bun",
"red_potato": "Red potato",
"regimen_congee": "Regimen congee",
"regimen_soup": "Regimen soup",
"reserve": "Reserve",
"resveratrol_rice": "Resveratrol rice",
"rice_paste": "Rice paste",
"rice_soup": "Rice soup",
"rice_wine": "Rice wine",
"roughage_rice": "Roughage rice",
"service": "Service",
"shelled_rice": "Shelled rice",
"smart": "Smart",
"soup_rice": "Soup rice",
"sprout_rice": "Sprout rice",
"standard_cook_rice": "Standard cook rice",
"steam_corn": "Steam corn",
"steam_egg": "Steam egg",
"steam_red_potato": "Steam red potato",
"steam_ribs": "Steam ribs",
"steame_fish": "Steamed fish",
"steep_rice": "Steep rice",
"stew_soup": "Stew soup",
"stewing": "Stewing",
"stone_bowl_rice": "Stone bowl rice",
"sushi_rice": "Sushi rice",
"trichromatic_coarse_grain": "Trichromatic coarse grain",
"uncap_boil": "Uncap boil",
"vegetable_porridge": "Vegetable porridge",
"vegetable_rice": "Vegetable rice",
"warm_milk": "Warm milk",
"yellow_wheat_rice": "Yellow wheat rice",
"yoghourt": "Yoghourt"
}
},
"out_tds": {
"name": "Out TDS"
},
"outdoor_temperature": {
"name": "Outdoor temperature"
},
"pmv": {
"name": "Predicted mean vote"
},
"realtime_power": {
"name": "Real-time power"
},
"refrigerator_actual_temp": {
"name": "Refrigerator actual temperature"
},
"refrigerator_setting_temp": {
"name": "Refrigerator setting temperature"
},
"remaining_days": {
"name": "Remaining days"
},
"right_flex_zone_actual_temp": {
"name": "Right flex zone actual temperature"
},
"right_flex_zone_setting_temp": {
"name": "Right flex zone setting temperature"
},
"salt_available": {
"name": "Salt available"
},
"seat_temperature": {
"name": "Seat temperature"
},
"soak_time": {
"name": "Soak time"
},
"softwater_available": {
"name": "Soft water available"
},
"tank_actual_temperature": {
"name": "Tank temperature"
},
"tank_level": {
"name": "Tank level"
},
"target_compressor_frequency": {
"name": "Target compressor frequency"
},
"target_indoor_fan_speed": {
"name": "Target indoor fan speed"
},
"target_temperature": {
"name": "Target temperature"
},
"temp_tw_in": {
"name": "Water inlet temperature"
},
"temp_tw_out": {
"name": "Water outlet temperature"
},
"temperature_compensate": {
"name": "Temperature compensation"
},
"temperature_raw": {
"name": "Raw temperature"
},
"top_compartment_temperature": {
"name": "Top compartment temperature"
},
"top_temperature": {
"name": "Top temperature"
},
"total_energy_consumption": {
"name": "Total energy consumption"
},
"total_produced_energy": {
"name": "Total produced energy"
},
"tvoc": {
"name": "TVOC"
},
"use_days": {
"name": "Days of use"
},
"variable_mode": {
"name": "Variable mode",
"state": {
"cold_drink": "Cold drink",
"dry_zone": "Dry zone",
"freeze_warm": "Freeze warm",
"fresh_product": "Fresh product",
"none": "None",
"partial_freezing": "Partial freezing",
"soft_freezing": "Soft freezing",
"zero_fresh": "Zero fresh"
}
},
"wash_time": {
"name": "Wash time"
},
"water_consumption": {
"name": "Water consumption"
},
"water_consumption_average": {
"name": "Water consumption average"
},
"water_consumption_big": {
"name": "Water consumption aggregated"
},
"water_temperature": {
"name": "Water temperature"
}
},
"switch": {
"anion": {
"name": "Anion"
+2
View File
@@ -83,6 +83,8 @@ class DummyDevice:
def set_attribute(self, attr: str, value: Any) -> None:
"""Record set attribute call."""
self.attributes[attr] = value
self.notify_update({attr: value})
self.calls.append(("set_attribute", attr, value))
def set_target_temperature(self, **kwargs: Any) -> None:
File diff suppressed because it is too large Load Diff
+247
View File
@@ -0,0 +1,247 @@
"""Tests for Midea sensor.py."""
from collections.abc import Callable
from unittest.mock import patch
from midealocal.const import DeviceType
from midealocal.devices.ac import DeviceAttributes as ACAttributes
from midealocal.devices.c3 import DeviceAttributes as C3Attributes
from midealocal.devices.db import DeviceAttributes as DBAttributes
from midealocal.devices.e8 import DeviceAttributes as E8Attributes
from midealocal.devices.ea import DeviceAttributes as EAAttributes
from midealocal.devices.ec import DeviceAttributes as ECAttributes
from midealocal.devices.ed import DeviceAttributes as EDAttributes
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import setup_integration
from .conftest import DummyDevice, SetDeviceAttribute, entity_entries
from .const import TEST_DEVICE_ID
from tests.common import MockConfigEntry, snapshot_platform
@pytest.mark.parametrize(
"device",
[
pytest.param(
DummyDevice(
DeviceType.AC,
attributes={
ACAttributes.power: True,
ACAttributes.mode: 1,
ACAttributes.target_temperature: 22.0,
ACAttributes.indoor_temperature: 21.0,
ACAttributes.comfort_mode: False,
ACAttributes.eco_mode: False,
ACAttributes.boost_mode: False,
ACAttributes.sleep_mode: False,
ACAttributes.frost_protect: False,
ACAttributes.fan_speed: 103,
ACAttributes.swing_vertical: True,
ACAttributes.swing_horizontal: True,
ACAttributes.indoor_humidity: 50,
},
),
id="ac",
),
pytest.param(
DummyDevice(
DeviceType.C3,
attributes={
C3Attributes.zone_temp_type: [True, False],
C3Attributes.temperature_min: [16, 17],
C3Attributes.temperature_max: [30, 29],
C3Attributes.mode: 1,
C3Attributes.zone1_power: True,
C3Attributes.zone2_power: False,
C3Attributes.target_temperature: [22, 23],
C3Attributes.temp_tw_out: 21.5,
},
),
id="c3",
),
pytest.param(
DummyDevice(
DeviceType.E8,
attributes={
E8Attributes.status: 1,
E8Attributes.time_remaining: 3600,
E8Attributes.keep_warm_remaining: 1800,
E8Attributes.working_time: 7200,
E8Attributes.target_temperature: 22.0,
E8Attributes.current_temperature: 21.0,
E8Attributes.finished: False,
E8Attributes.water_shortage: False,
},
),
id="e8",
),
pytest.param(
DummyDevice(
DeviceType.DB,
attributes={
DBAttributes.power: True,
DBAttributes.mode: "normal",
DBAttributes.temperature: 22.0,
DBAttributes.wash_time: 65,
DBAttributes.dehydration_time: 30,
DBAttributes.program: "cotton",
},
),
id="db",
),
pytest.param(
DummyDevice(
DeviceType.DB,
attributes={
DBAttributes.power: False,
DBAttributes.mode: "unknown",
DBAttributes.temperature: 22.0,
DBAttributes.wash_time: 65,
DBAttributes.dehydration_time: 30,
DBAttributes.program: "unknown",
},
),
id="db_unknown_attributes",
),
pytest.param(
DummyDevice(
DeviceType.EA,
attributes={
EAAttributes.bottom_temperature: 180,
EAAttributes.cooking: 1,
EAAttributes.keep_warm: True,
EAAttributes.mode: "heat_rice",
EAAttributes.progress: 50,
EAAttributes.keep_warm_time: 30,
EAAttributes.time_remaining: 5,
EAAttributes.top_temperature: 200,
},
),
id="ea",
),
pytest.param(
DummyDevice(
DeviceType.EC,
attributes={
ECAttributes.cooking: 1,
ECAttributes.mode: "diy",
ECAttributes.progress: 50,
ECAttributes.keep_warm_time: 30,
ECAttributes.time_remaining: 5,
ECAttributes.top_temperature: 200,
ECAttributes.with_pressure: True,
},
),
id="ec",
),
pytest.param(
DummyDevice(
DeviceType.ED,
attributes={
EDAttributes.keep_warm: True,
EDAttributes.boil_temperature: 100,
EDAttributes.boiling: True,
EDAttributes.keep_warm_time: 30,
EDAttributes.child_lock: True,
EDAttributes.cl_sterilization: True,
EDAttributes.cooling: True,
EDAttributes.current_temperature: 150,
EDAttributes.dispensing: True,
EDAttributes.error: 3,
EDAttributes.filter1: 30,
EDAttributes.filter2: 20,
EDAttributes.filter3: 100,
EDAttributes.flushing_days: 50,
EDAttributes.heating: True,
EDAttributes.hot_water_dispensing: True,
EDAttributes.in_tds: 200,
EDAttributes.keep_warm_remaining: 20,
EDAttributes.lack_water: True,
EDAttributes.leak_water: True,
EDAttributes.out_tds: 100,
EDAttributes.power: True,
EDAttributes.water_consumption: 500,
EDAttributes.water_consumption_big: 6000,
EDAttributes.water_consumption_average: 30,
},
),
id="ed",
),
],
)
async def test_all_entities(
hass: HomeAssistant,
device: DummyDevice,
mock_config_entry: Callable[[DummyDevice], MockConfigEntry],
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Test sensor entities are created."""
config_entry = mock_config_entry(device)
with patch("homeassistant.components.midea._PLATFORMS", [Platform.SENSOR]):
await setup_integration(hass, config_entry, device)
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
async def test_sensor_state_update(
hass: HomeAssistant,
set_device_attribute: SetDeviceAttribute,
mock_config_entry: Callable[[DummyDevice], MockConfigEntry],
) -> None:
"""Test sensor state follows push updates from the device."""
device = DummyDevice(
DeviceType.AC,
attributes={
ACAttributes.power: True,
ACAttributes.mode: 1,
ACAttributes.target_temperature: 22.0,
ACAttributes.indoor_temperature: 21.0,
ACAttributes.indoor_humidity: 0,
ACAttributes.full_dust: False,
ACAttributes.outdoor_temperature: "unknown",
},
)
config_entry = mock_config_entry(device)
with patch("homeassistant.components.midea._PLATFORMS", [Platform.SENSOR]):
await setup_integration(hass, config_entry, device)
assert len(entity_entries(hass, config_entry)) == 3
entity_entry = entity_entries(hass, config_entry)[
f"{TEST_DEVICE_ID}_indoor_temperature"
]
state = hass.states.get(entity_entry.entity_id)
assert state is not None
assert state.state == "21.0"
await set_device_attribute(device, ACAttributes.indoor_temperature, 19.5)
state = hass.states.get(entity_entry.entity_id)
assert state is not None
assert state.state == "19.5"
entity_entry = entity_entries(hass, config_entry)[
f"{TEST_DEVICE_ID}_outdoor_temperature"
]
state = hass.states.get(entity_entry.entity_id)
assert state is not None
assert state.state == "unknown"
entity_entry = entity_entries(hass, config_entry)[
f"{TEST_DEVICE_ID}_indoor_humidity"
]
state = hass.states.get(entity_entry.entity_id)
assert state is not None
assert state.state == "unknown"
await set_device_attribute(device, ACAttributes.indoor_humidity, 255)
state = hass.states.get(entity_entry.entity_id)
assert state is not None
assert state.state == "unknown"