4 Commits

Author SHA1 Message Date
sususweet
b6e7bcb729 fix: T0xCA translation issues. 2025-09-25 11:55:06 +08:00
sususweet
c12158cd09 fix: translation and unit issues. 2025-09-25 11:45:46 +08:00
sususweet
40ba24c32a feat: support more devices. 2025-09-25 10:50:39 +08:00
sususweet
f99019bdca feat: support more devices. 2025-09-24 23:31:31 +08:00
23 changed files with 4929 additions and 299 deletions

View File

@@ -17,13 +17,30 @@
## 目前支持的设备类型
- T0xAC 空调
- T0xB3 消毒碗柜
- T0xB8 智能扫地机器人
- T0xCA 对开门冰箱
- T0xCE 新风机
- T0xCF 中央空调暖家
- T0xD9 复式洗衣机
- T0xDB 滚筒洗衣机
- T0xDC 干衣机
- T0xE1 洗碗机
- T0xE3 恒温式燃气热水器
- T0xEA 电饭锅
- T0xED 软水机
- T0xFD 加湿器
欢迎合作开发添加更多设备支持。
合作开发方法:添加本插件后,找到未能正确识别的设备,点击对应设备`传感器`分类下的`连通性`
![img.png](img.png)
展开下面的`属性`卡片把里面这些字段复制给我或随issue提交等待适配就可以了。
![img_1.png](img_1.png)
## 实体映射
映射文件位于`device_mapping`下, 每个大的品类一个映射文件,目前支持映射的实体类型如下:

View File

@@ -53,7 +53,8 @@ PLATFORMS: list[Platform] = [
Platform.CLIMATE,
Platform.SELECT,
Platform.WATER_HEATER,
Platform.FAN
Platform.FAN,
Platform.HUMIDIFIER
]

View File

@@ -100,7 +100,13 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
@property
def current_temperature(self):
return self.device_attributes.get(self._key_current_temperature)
temp = self.device_attributes.get(self._key_current_temperature)
if temp is not None:
try:
return float(temp)
except (ValueError, TypeError):
return None
return None
@property
def target_temperature(self):
@@ -108,10 +114,19 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
temp_int = self.device_attributes.get(self._key_target_temperature[0])
tem_dec = self.device_attributes.get(self._key_target_temperature[1])
if temp_int is not None and tem_dec is not None:
return temp_int + tem_dec
try:
return float(temp_int) + float(tem_dec)
except (ValueError, TypeError):
return None
return None
else:
return self.device_attributes.get(self._key_target_temperature)
temp = self.device_attributes.get(self._key_target_temperature)
if temp is not None:
try:
return float(temp)
except (ValueError, TypeError):
return None
return None
@property
def min_temp(self):

View File

@@ -0,0 +1,195 @@
from homeassistant.const import Platform, UnitOfTemperature, UnitOfTime
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [
"upstair_work_status", "downstair_work_status", "middlestair_work_status",
"upstair_mode", "downstair_mode", "middlestair_mode",
"upstair_temp", "downstair_temp", "middlestair_temp"
],
"entities": {
Platform.BINARY_SENSOR: {
"door_middlestair": {
"device_class": BinarySensorDeviceClass.DOOR,
},
"door_upstair": {
"device_class": BinarySensorDeviceClass.DOOR,
},
"door_downstair": {
"device_class": BinarySensorDeviceClass.DOOR,
},
"downstair_ispreheat": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"upstair_ispreheat": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"downstair_iscooling": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"upstair_iscooling": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"middlestair_ispreheat": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"middlestair_iscooling": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"lock": {
"device_class": BinarySensorDeviceClass.LOCK,
},
"is_error": {
"device_class": BinarySensorDeviceClass.PROBLEM,
},
"uv_disinfect": {
"device_class": BinarySensorDeviceClass.RUNNING,
}
},
Platform.SELECT: {
"upstair_work_status": {
"options": {
"power_off": {"upstair_work_status": "power_off"},
"power_on": {"upstair_work_status": "power_on"},
"working": {"upstair_work_status": "working"},
"pause": {"upstair_work_status": "pause"},
"finish": {"upstair_work_status": "finish"},
"error": {"upstair_work_status": "error"}
}
},
"downstair_work_status": {
"options": {
"power_off": {"downstair_work_status": "power_off"},
"power_on": {"downstair_work_status": "power_on"},
"working": {"downstair_work_status": "working"},
"pause": {"downstair_work_status": "pause"},
"finish": {"downstair_work_status": "finish"},
"error": {"downstair_work_status": "error"}
}
},
"middlestair_work_status": {
"options": {
"power_off": {"middlestair_work_status": "power_off"},
"power_on": {"middlestair_work_status": "power_on"},
"working": {"middlestair_work_status": "working"},
"pause": {"middlestair_work_status": "pause"},
"finish": {"middlestair_work_status": "finish"},
"error": {"middlestair_work_status": "error"}
}
},
"upstair_mode": {
"options": {
"off": {"upstair_mode": "0"},
"bake": {"upstair_mode": "1"},
"roast": {"upstair_mode": "2"},
"grill": {"upstair_mode": "3"},
"convection": {"upstair_mode": "4"},
"defrost": {"upstair_mode": "5"}
}
},
"downstair_mode": {
"options": {
"off": {"downstair_mode": "0"},
"bake": {"downstair_mode": "1"},
"roast": {"downstair_mode": "2"},
"grill": {"downstair_mode": "3"},
"convection": {"downstair_mode": "4"},
"defrost": {"downstair_mode": "5"}
}
},
"middlestair_mode": {
"options": {
"off": {"middlestair_mode": "0"},
"bake": {"middlestair_mode": "1"},
"roast": {"middlestair_mode": "2"},
"grill": {"middlestair_mode": "3"},
"convection": {"middlestair_mode": "4"},
"defrost": {"middlestair_mode": "5"}
}
}
},
Platform.SENSOR: {
"upstair_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"downstair_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"middlestair_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"upstair_hour": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"upstair_min": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"upstair_sec": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.SECONDS,
"state_class": SensorStateClass.MEASUREMENT
},
"middlestair_hour": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"middlestair_min": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"middlestair_sec": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.SECONDS,
"state_class": SensorStateClass.MEASUREMENT
},
"downstair_hour": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"downstair_min": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"downstair_sec": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.SECONDS,
"state_class": SensorStateClass.MEASUREMENT
},
"order_hour": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"order_min": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"order_sec": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.SECONDS,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -105,8 +105,7 @@ DEVICE_MAPPING = {
},
Platform.SENSOR: {
"dust_count": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"area": {
"device_class": SensorDeviceClass.AREA,
@@ -119,12 +118,10 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"switch_status": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"water_station_status": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"work_time": {
"device_class": SensorDeviceClass.DURATION,
@@ -137,8 +134,7 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"planner_status": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"sweep_then_mop_mode_progress": {
"device_class": SensorDeviceClass.BATTERY,
@@ -146,12 +142,10 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"error_desc": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"station_error_desc": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
}
}
}

View File

@@ -0,0 +1,309 @@
from homeassistant.const import Platform, UnitOfTemperature, UnitOfTime, PERCENTAGE, PRECISION_HALVES
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [
"freezing_mode", "intelligent_mode", "energy_saving_mode", "holiday_mode",
"moisturize_mode", "preservation_mode", "acme_freezing_mode", "variable_mode",
"storage_power", "left_flexzone_power", "right_flexzone_power", "freezing_power",
"function_zone_power", "storage_temperature", "freezing_temperature",
"left_flexzone_temperature", "right_flexzone_temperature"
],
"entities": {
Platform.SWITCH: {
"freezing_mode": {
"device_class": SwitchDeviceClass.SWITCH,
},
"intelligent_mode": {
"device_class": SwitchDeviceClass.SWITCH,
},
"energy_saving_mode": {
"device_class": SwitchDeviceClass.SWITCH,
},
"holiday_mode": {
"device_class": SwitchDeviceClass.SWITCH,
},
"moisturize_mode": {
"device_class": SwitchDeviceClass.SWITCH,
},
"preservation_mode": {
"device_class": SwitchDeviceClass.SWITCH,
},
"acme_freezing_mode": {
"device_class": SwitchDeviceClass.SWITCH,
},
"storage_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"left_flexzone_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"right_flexzone_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"freezing_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"function_zone_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"cross_peak_electricity": {
"device_class": SwitchDeviceClass.SWITCH,
},
"all_refrigeration_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"remove_dew_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"humidify_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"unfreeze_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"floodlight_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"radar_mode_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"milk_mode_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"icea_mode_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"plasma_aseptic_mode_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"acquire_icea_mode_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"brash_icea_mode_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"acquire_water_mode_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"freezing_ice_machine_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"microcrystal_fresh": {
"device_class": SwitchDeviceClass.SWITCH,
},
"dry_zone": {
"device_class": SwitchDeviceClass.SWITCH,
},
"electronic_smell": {
"device_class": SwitchDeviceClass.SWITCH,
},
"eradicate_pesticide_residue": {
"device_class": SwitchDeviceClass.SWITCH,
},
"performance_mode": {
"device_class": SwitchDeviceClass.SWITCH,
},
"ice_mouth_power": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.BINARY_SENSOR: {
"storage_door_state": {
"device_class": BinarySensorDeviceClass.DOOR,
},
"freezer_door_state": {
"device_class": BinarySensorDeviceClass.DOOR,
},
"flexzone_door_state": {
"device_class": BinarySensorDeviceClass.DOOR,
},
"storage_ice_home_door_state": {
"device_class": BinarySensorDeviceClass.DOOR,
},
"bar_door_state": {
"device_class": BinarySensorDeviceClass.DOOR,
},
"is_error": {
"device_class": BinarySensorDeviceClass.PROBLEM,
}
},
Platform.CLIMATE: {
"storage_zone": {
"power": "storage_power",
"hvac_modes": {
"off": {"storage_power": "off"},
"heat": {"storage_power": "on"}
},
"target_temperature": "storage_temperature",
"current_temperature": "refrigeration_real_temperature",
"min_temp": -10,
"max_temp": 10,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
},
"freezing_zone": {
"power": "freezing_power",
"hvac_modes": {
"off": {"freezing_power": "off"},
"heat": {"freezing_power": "on"}
},
"target_temperature": "freezing_temperature",
"current_temperature": "freezing_real_temperature",
"min_temp": -30,
"max_temp": -10,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
},
"left_flexzone": {
"power": "left_flexzone_power",
"hvac_modes": {
"off": {"left_flexzone_power": "off"},
"heat": {"left_flexzone_power": "on"}
},
"target_temperature": "left_flexzone_temperature",
"current_temperature": "left_variable_real_temperature",
"min_temp": -30,
"max_temp": 10,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
},
"right_flexzone": {
"power": "right_flexzone_power",
"hvac_modes": {
"off": {"right_flexzone_power": "off"},
"heat": {"right_flexzone_power": "on"}
},
"target_temperature": "right_flexzone_temperature",
"current_temperature": "right_variable_real_temperature",
"min_temp": -30,
"max_temp": 10,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
}
},
Platform.SELECT: {
"variable_mode": {
"options": {
"none_mode": {"variable_mode": "none_mode"},
"freezing": {"variable_mode": "freezing"},
"refrigeration": {"variable_mode": "refrigeration"},
"wine": {"variable_mode": "wine"},
"vegetable": {"variable_mode": "vegetable"}
}
},
"icea_bar_function_switch": {
"options": {
"default": {"icea_bar_function_switch": "default"},
"ice": {"icea_bar_function_switch": "ice"},
"water": {"icea_bar_function_switch": "water"},
"off": {"icea_bar_function_switch": "off"}
}
},
"food_site": {
"options": {
"left_freezing_room": {"food_site": "left_freezing_room"},
"right_freezing_room": {"food_site": "right_freezing_room"},
"storage_room": {"food_site": "storage_room"},
"function_zone": {"food_site": "function_zone"}
}
},
"temperature_unit": {
"options": {
"celsius": {"temperature_unit": "celsius"},
"fahrenheit": {"temperature_unit": "fahrenheit"}
}
}
},
Platform.SENSOR: {
"storage_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"freezing_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"left_flexzone_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"right_flexzone_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"refrigeration_real_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"freezing_real_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"left_variable_real_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"right_variable_real_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"interval_room_humidity_level": {
"device_class": SensorDeviceClass.HUMIDITY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"normal_zone_level": {
"device_class": SensorDeviceClass.ENUM
},
"function_zone_level": {
"device_class": SensorDeviceClass.ENUM
},
"freeze_fahrenheit_level": {
"device_class": SensorDeviceClass.ENUM
},
"refrigeration_fahrenheit_level": {
"device_class": SensorDeviceClass.ENUM
},
"leach_expire_day": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.DAYS,
"state_class": SensorStateClass.MEASUREMENT
},
"power_consumption_low": {
"device_class": SensorDeviceClass.POWER,
"unit_of_measurement": "W",
"state_class": SensorStateClass.MEASUREMENT
},
"power_consumption_high": {
"device_class": SensorDeviceClass.POWER,
"unit_of_measurement": "W",
"state_class": SensorStateClass.MEASUREMENT
},
"fast_cold_minute": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"fast_freeze_minute": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -0,0 +1,185 @@
from homeassistant.const import Platform, UnitOfTemperature, UnitOfTime
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [
"power", "mode_state", "fan_set", "room_temp_value", "humidity_set"
],
"entities": {
Platform.SWITCH: {
"lock_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"esp_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"passby_enable": {
"device_class": SwitchDeviceClass.SWITCH,
},
"preheat_enable": {
"device_class": SwitchDeviceClass.SWITCH,
},
"remain_able": {
"device_class": SwitchDeviceClass.SWITCH,
},
"hcho_check_enable": {
"device_class": SwitchDeviceClass.SWITCH,
},
"co2_check_enable": {
"device_class": SwitchDeviceClass.SWITCH,
},
"function_set_link": {
"device_class": SwitchDeviceClass.SWITCH,
},
"function_set_sleep": {
"device_class": SwitchDeviceClass.SWITCH,
},
"function_set_energy_save": {
"device_class": SwitchDeviceClass.SWITCH,
},
"function_set_prheat": {
"device_class": SwitchDeviceClass.SWITCH,
},
"function_set_ultimate": {
"device_class": SwitchDeviceClass.SWITCH,
},
"clean_net_clean_flg": {
"device_class": SwitchDeviceClass.SWITCH,
},
"change_net_change_flg": {
"device_class": SwitchDeviceClass.SWITCH,
},
"condensation_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"humidity_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"preheat_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"esp_enable": {
"device_class": SwitchDeviceClass.SWITCH,
},
"pm25_check_enable": {
"device_class": SwitchDeviceClass.SWITCH,
},
"timer_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"freeze_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"humidity_check_enable": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.SELECT: {
"mode_state": {
"options": {
"passby": {"mode_state": "passby"},
"auto": {"mode_state": "auto"},
"manual": {"mode_state": "manual"},
"sleep": {"mode_state": "sleep"},
"energy_save": {"mode_state": "energy_save"},
"ultimate": {"mode_state": "ultimate"}
}
},
"fan_set": {
"options": {
"off": {"fan_set": "0"},
"low": {"fan_set": "1"},
"medium": {"fan_set": "2"},
"high": {"fan_set": "3"},
"auto": {"fan_set": "4"}
}
}
},
Platform.SENSOR: {
"room_temp_value": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"clean_net_used_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"change_net_used_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"tvoc_value": {
"device_class": SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
"unit_of_measurement": "mg/m³",
"state_class": SensorStateClass.MEASUREMENT
},
"change_set_real_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"clean_set_real_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"error_code": {
"device_class": SensorDeviceClass.ENUM
},
"humidity_set": {
"device_class": SensorDeviceClass.HUMIDITY,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
},
"room_aqi_value": {
"device_class": SensorDeviceClass.AQI,
"state_class": SensorStateClass.MEASUREMENT
},
"change_net_set_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"clean_net_set_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"humidity_value": {
"device_class": SensorDeviceClass.HUMIDITY,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
},
"hcho_value": {
"device_class": SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
"unit_of_measurement": "mg/m³",
"state_class": SensorStateClass.MEASUREMENT
},
"pm25_value": {
"device_class": SensorDeviceClass.PM25,
"unit_of_measurement": "µg/m³",
"state_class": SensorStateClass.MEASUREMENT
},
"co2_value": {
"device_class": SensorDeviceClass.CO2,
"unit_of_measurement": "ppm",
"state_class": SensorStateClass.MEASUREMENT
},
"machine_type": {
"device_class": SensorDeviceClass.ENUM
}
}
}
}
}

View File

@@ -0,0 +1,167 @@
from homeassistant.const import Platform, UnitOfTemperature, PRECISION_HALVES
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [
"power_state", "run_mode", "temp_set", "heat_enable", "cool_enable"
],
"entities": {
Platform.CLIMATE: {
"thermostat": {
"power": "power_state",
"hvac_modes": {
"off": {"power_state": "off"},
"heat": {"power_state": "on", "run_mode": "heat", "heat_enable": "on"},
"cool": {"power_state": "on", "run_mode": "cool", "cool_enable": "on"},
"auto": {"power_state": "on", "run_mode": "auto", "heat_enable": "on", "cool_enable": "on"}
},
"target_temperature": "temp_set",
"current_temperature": "cur_temp",
"min_temp": 5,
"max_temp": 70,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
}
},
Platform.SWITCH: {
"freeze_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"power_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"heat_enable": {
"device_class": SwitchDeviceClass.SWITCH,
},
"cool_enable": {
"device_class": SwitchDeviceClass.SWITCH,
},
"silence_set_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"time_set_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"silence_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"holiday_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"holiday_set_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"holiday_on_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"room_temp_ctrl": {
"device_class": SwitchDeviceClass.SWITCH,
},
"room_temp_set": {
"device_class": SwitchDeviceClass.SWITCH,
},
"comp_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"day_time_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"week_time_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"warn_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"defrost_state": {
"device_class": SwitchDeviceClass.SWITCH,
},
"pre_heat": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.SELECT: {
"run_mode": {
"options": {
"heat": {"run_mode": "heat"},
"cool": {"run_mode": "cool"},
"auto": {"run_mode": "auto"},
"fan": {"run_mode": "fan"},
"dry": {"run_mode": "dry"}
}
},
"temp_type": {
"options": {
"water_temperature": {"temp_type": "water_temperature"},
"room_temperature": {"temp_type": "room_temperature"},
"outdoor_temperature": {"temp_type": "outdoor_temperature"}
}
}
},
Platform.SENSOR: {
"cur_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"error_code": {
"device_class": SensorDeviceClass.ENUM
},
"heat_max_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"heat_min_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"cool_max_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"cool_min_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"auto_max_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"auto_min_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"preheat_on_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"preheat_max_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"preheat_min_set_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"temp_set": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -0,0 +1,181 @@
from homeassistant.const import Platform, UnitOfElectricPotential, UnitOfTemperature, UnitOfTime
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": [0, 1],
"calculate": {
"get": [
{
"lvalue": "[remaining_time]",
"rvalue": "[db_remain_time]"
}
],
"set": {
}
},
"entities": {
Platform.SWITCH: {
"db_power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_clean_notification": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_softener_needed": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_detergent_needed": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_nightly_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_baby_lock": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_light": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_steam_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_fast_clean_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"db_wash_dry_link": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.SELECT: {
"db_running_status": {
"options": {
"stop": {"db_running_status": "stop"},
"start": {"db_running_status": "start"},
"pause": {"db_running_status": "pause"},
"finish": {"db_running_status": "finish"},
"error": {"db_running_status": "error"}
}
},
"db_program": {
"options": {
"fast_wash_30": {"db_program": "fast_wash_30"},
"normal_wash": {"db_program": "normal_wash"},
"heavy_wash": {"db_program": "heavy_wash"},
"delicate_wash": {"db_program": "delicate_wash"},
"quick_wash": {"db_program": "quick_wash"},
"eco_wash": {"db_program": "eco_wash"}
}
},
"db_water_level": {
"options": {
"low": {"db_water_level": "1"},
"medium": {"db_water_level": "2"},
"high": {"db_water_level": "3"},
"extra_high": {"db_water_level": "4"}
}
},
"db_temperature": {
"options": {
"cold": {"db_temperature": "1"},
"warm": {"db_temperature": "2"},
"hot": {"db_temperature": "3"},
"extra_hot": {"db_temperature": "4"}
}
},
"dehydration_speed": {
"options": {
"low": {"dehydration_speed": "1"},
"medium": {"dehydration_speed": "2"},
"high": {"dehydration_speed": "3"},
"extra_high": {"dehydration_speed": "4"}
}
},
"db_detergent": {
"options": {
"none": {"db_detergent": "1"},
"little": {"db_detergent": "2"},
"normal": {"db_detergent": "3"},
"more": {"db_detergent": "4"}
}
},
"db_softener": {
"options": {
"none": {"db_softener": "1"},
"little": {"db_softener": "2"},
"normal": {"db_softener": "3"},
"more": {"db_softener": "4"}
}
},
"db_position": {
"options": {
"position_1": {"db_position": "1"},
"position_2": {"db_position": "2"},
"position_3": {"db_position": "3"}
}
},
"db_location": {
"options": {
"location_1": {"db_location": "1"},
"location_2": {"db_location": "2"},
"location_3": {"db_location": "3"}
}
}
},
Platform.SENSOR: {
"db_remain_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"db_progress": {
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
},
"db_error_code": {
"device_class": SensorDeviceClass.ENUM
},
"db_set_dewater_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"db_set_wash_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"db_device_software_version": {
"device_class": SensorDeviceClass.ENUM
},
"db_rinse_count": {
"device_class": SensorDeviceClass.ENUM
},
"db_wash_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"db_appointment_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"db_appointment": {
"device_class": SensorDeviceClass.ENUM
},
"db_dehydration_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"db_cycle_memory": {
"device_class": SensorDeviceClass.ENUM
}
}
}
}
}

View File

@@ -0,0 +1,381 @@
from homeassistant.const import Platform, UnitOfElectricPotential, UnitOfTemperature, UnitOfTime
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": [0, 1],
"calculate": {
"get": [
{
"lvalue": "[remaining_time]",
"rvalue": "[remain_time]"
}
],
"set": {
}
},
"entities": {
Platform.SWITCH: {
"power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"softener_lack": {
"device_class": SwitchDeviceClass.SWITCH,
},
"detergent_lack": {
"device_class": SwitchDeviceClass.SWITCH,
},
"door_opened": {
"device_class": SwitchDeviceClass.SWITCH,
},
"bucket_water_overheating": {
"device_class": SwitchDeviceClass.SWITCH,
},
"memory": {
"device_class": SwitchDeviceClass.SWITCH,
},
"appointment": {
"device_class": SwitchDeviceClass.SWITCH,
},
"spray_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"old_speedy": {
"device_class": SwitchDeviceClass.SWITCH,
},
"nightly": {
"device_class": SwitchDeviceClass.SWITCH,
},
"down_light": {
"device_class": SwitchDeviceClass.SWITCH,
},
"easy_ironing": {
"device_class": SwitchDeviceClass.SWITCH,
},
"super_clean_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"intelligent_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"strong_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"silent": {
"device_class": SwitchDeviceClass.SWITCH,
},
"speedy": {
"device_class": SwitchDeviceClass.SWITCH,
},
"lock": {
"device_class": SwitchDeviceClass.SWITCH,
},
"flocks_switcher": {
"device_class": SwitchDeviceClass.SWITCH,
},
"fresh_anion_switch": {
"device_class": SwitchDeviceClass.SWITCH,
},
"dry_weighing_already": {
"device_class": SwitchDeviceClass.SWITCH,
},
"keep_fresh_status": {
"device_class": SwitchDeviceClass.SWITCH,
},
"drying_tunnel_overheating": {
"device_class": SwitchDeviceClass.SWITCH,
},
"fast_clean_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"steam_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"beforehand_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"ai_flag": {
"device_class": SwitchDeviceClass.SWITCH,
},
"water_plus": {
"device_class": SwitchDeviceClass.SWITCH,
},
"soak": {
"device_class": SwitchDeviceClass.SWITCH,
},
"ultraviolet_lamp": {
"device_class": SwitchDeviceClass.SWITCH,
},
"eye_wash": {
"device_class": SwitchDeviceClass.SWITCH,
},
"microbubble": {
"device_class": SwitchDeviceClass.SWITCH,
},
"wind_dispel": {
"device_class": SwitchDeviceClass.SWITCH,
},
"cycle_memory": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.SELECT: {
"running_status": {
"options": {
"standby": {"running_status": "standby"},
"running": {"running_status": "running"},
"pause": {"running_status": "pause"},
"finish": {"running_status": "finish"},
"error": {"running_status": "error"}
}
},
"db_dehydration_speed": {
"options": {
"low": {"db_dehydration_speed": "1"},
"medium": {"db_dehydration_speed": "2"},
"high": {"db_dehydration_speed": "3"},
"extra_high": {"db_dehydration_speed": "4"}
}
},
"mode": {
"options": {
"normal": {"mode": "normal"},
"eco": {"mode": "eco"},
"quick": {"mode": "quick"},
"heavy": {"mode": "heavy"},
"delicate": {"mode": "delicate"}
}
},
"water_level": {
"options": {
"low": {"water_level": "low"},
"medium": {"water_level": "medium"},
"high": {"water_level": "high"},
"extra_high": {"water_level": "extra_high"}
}
},
"program": {
"options": {
"ssp": {"program": "ssp"},
"cotton": {"program": "cotton"},
"synthetic": {"program": "synthetic"},
"wool": {"program": "wool"},
"delicate": {"program": "delicate"},
"quick": {"program": "quick"}
}
},
"temperature": {
"options": {
"cold": {"temperature": "cold"},
"warm": {"temperature": "warm"},
"hot": {"temperature": "hot"},
"extra_hot": {"temperature": "extra_hot"}
}
},
"detergent_density": {
"options": {
"low": {"detergent_density": "low"},
"medium": {"detergent_density": "medium"},
"high": {"detergent_density": "high"},
"extra_high": {"detergent_density": "extra_high"}
}
},
"softener_density": {
"options": {
"low": {"softener_density": "low"},
"medium": {"softener_density": "medium"},
"high": {"softener_density": "high"},
"extra_high": {"softener_density": "extra_high"}
}
},
"detergent": {
"options": {
"none": {"detergent": "none"},
"little": {"detergent": "little"},
"normal": {"detergent": "normal"},
"more": {"detergent": "more"}
}
},
"softener": {
"options": {
"none": {"softener": "none"},
"little": {"softener": "little"},
"normal": {"softener": "normal"},
"more": {"softener": "more"}
}
},
"season": {
"options": {
"spring": {"season": "spring"},
"summer": {"season": "summer"},
"autumn": {"season": "autumn"},
"winter": {"season": "winter"}
}
},
"disinfectant": {
"options": {
"none": {"disinfectant": "none"},
"light": {"disinfectant": "light"},
"medium": {"disinfectant": "medium"},
"strong": {"disinfectant": "strong"}
}
},
"dirty_degree": {
"options": {
"light": {"dirty_degree": "light"},
"medium": {"dirty_degree": "medium"},
"heavy": {"dirty_degree": "heavy"},
"extra_heavy": {"dirty_degree": "extra_heavy"}
}
},
"stains": {
"options": {
"none": {"stains": "none"},
"light": {"stains": "light"},
"medium": {"stains": "medium"},
"heavy": {"stains": "heavy"}
}
},
"add_rinse": {
"options": {
"none": {"add_rinse": "none"},
"one": {"add_rinse": "one"},
"two": {"add_rinse": "two"},
"three": {"add_rinse": "three"}
}
},
"soak_count": {
"options": {
"none": {"soak_count": "none"},
"one": {"soak_count": "one"},
"two": {"soak_count": "two"},
"three": {"soak_count": "three"}
}
}
},
Platform.SENSOR: {
"wash_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"appointment_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"remain_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"dryer": {
"device_class": SensorDeviceClass.ENUM
},
"remote_control_flag": {
"device_class": SensorDeviceClass.ENUM
},
"progress": {
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
},
"cloud_cycle_low": {
"device_class": SensorDeviceClass.ENUM
},
"cloud_cycle_high": {
"device_class": SensorDeviceClass.ENUM
},
"cloud_cycle_jiepai1": {
"device_class": SensorDeviceClass.ENUM
},
"cloud_cycle_jiepai2": {
"device_class": SensorDeviceClass.ENUM
},
"cloud_cycle_jiepai3": {
"device_class": SensorDeviceClass.ENUM
},
"cloud_cycle_jiepai4": {
"device_class": SensorDeviceClass.ENUM
},
"cloud_cycle_jiepai_time1": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"dehydration_time_value": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"cloud_cycle_jiepai_time3": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"cloud_cycle_jiepai_time4": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"customize_machine_cycle": {
"device_class": SensorDeviceClass.ENUM
},
"detergent_global": {
"device_class": SensorDeviceClass.ENUM
},
"softener_global": {
"device_class": SensorDeviceClass.ENUM
},
"detergent_density_global": {
"device_class": SensorDeviceClass.ENUM
},
"softener_density_global": {
"device_class": SensorDeviceClass.ENUM
},
"fresh_air_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"flocks_remind_period": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"device_software_version": {
"device_class": SensorDeviceClass.ENUM
},
"expert_step": {
"device_class": SensorDeviceClass.ENUM
},
"error_code": {
"device_class": SensorDeviceClass.ENUM
},
"flocks_wash_count": {
"device_class": SensorDeviceClass.ENUM
},
"active_oxygen": {
"device_class": SensorDeviceClass.ENUM
},
"dehydration_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"cloud_cycle_jiepai_time2": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"wash_time_value": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -0,0 +1,147 @@
from homeassistant.const import Platform, UnitOfTime
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [
"power", "ai_switch", "light", "appointment", "prevent_wrinkle_switch",
"steam_switch", "damp_dry_signal", "eco_dry_switch", "bucket_clean_switch",
"water_box", "baby_lock", "remind_sound", "steam", "prevent_wrinkle",
"material", "sterilize", "dryness_level", "dry_temp", "intensity", "program"
],
"entities": {
Platform.SWITCH: {
"ai_switch": {
"device_class": SwitchDeviceClass.SWITCH,
},
"light": {
"device_class": SwitchDeviceClass.SWITCH,
},
"appointment": {
"device_class": SwitchDeviceClass.SWITCH,
},
"prevent_wrinkle_switch": {
"device_class": SwitchDeviceClass.SWITCH,
},
"steam_switch": {
"device_class": SwitchDeviceClass.SWITCH,
},
"damp_dry_signal": {
"device_class": SwitchDeviceClass.SWITCH,
},
"eco_dry_switch": {
"device_class": SwitchDeviceClass.SWITCH,
},
"bucket_clean_switch": {
"device_class": SwitchDeviceClass.SWITCH,
},
"water_box": {
"device_class": SwitchDeviceClass.SWITCH,
},
"baby_lock": {
"device_class": SwitchDeviceClass.SWITCH,
},
"remind_sound": {
"device_class": SwitchDeviceClass.SWITCH,
},
"steam": {
"device_class": SwitchDeviceClass.SWITCH,
},
"power": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.BINARY_SENSOR: {
"door_warn": {
"device_class": BinarySensorDeviceClass.PROBLEM,
}
},
Platform.SELECT: {
"prevent_wrinkle": {
"options": {
"off": {"prevent_wrinkle": "0"},
"low": {"prevent_wrinkle": "1"},
"medium": {"prevent_wrinkle": "2"},
"high": {"prevent_wrinkle": "3"}
}
},
"material": {
"options": {
"cotton": {"material": "0"},
"synthetic": {"material": "1"},
"wool": {"material": "2"},
"delicate": {"material": "3"},
"mixed": {"material": "4"}
}
},
"sterilize": {
"options": {
"off": {"sterilize": "0"},
"on": {"sterilize": "1"}
}
},
"dryness_level": {
"options": {
"extra_dry": {"dryness_level": "0"},
"dry": {"dryness_level": "1"},
"normal": {"dryness_level": "2"},
"damp": {"dryness_level": "3"}
}
},
"dry_temp": {
"options": {
"low": {"dry_temp": "0"},
"medium": {"dry_temp": "1"},
"high": {"dry_temp": "2"},
"extra_high": {"dry_temp": "3"}
}
},
"intensity": {
"options": {
"low": {"intensity": "0"},
"medium": {"intensity": "1"},
"high": {"intensity": "2"}
}
},
"program": {
"options": {
"mixed_wash": {"program": "mixed_wash"},
"cotton": {"program": "cotton"},
"synthetic": {"program": "synthetic"},
"wool": {"program": "wool"},
"delicate": {"program": "delicate"},
"quick": {"program": "quick"},
"eco": {"program": "eco"}
}
}
},
Platform.SENSOR: {
"appointment_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"remain_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"progress": {
"device_class": SensorDeviceClass.ENUM
},
"error_code": {
"device_class": SensorDeviceClass.ENUM
},
"dry_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -0,0 +1,182 @@
from homeassistant.const import Platform, UnitOfTemperature, UnitOfVolume, UnitOfTime, PERCENTAGE, PRECISION_HALVES
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [
"power", "bubble", "cold_water", "bathtub", "safe", "cold_water_dot",
"change_litre_switch", "cold_water_ai", "cold_water_pressure",
"person_mode_one", "person_mode_two", "person_mode_three", "gesture_function",
"mode", "power_level", "type_machine", "capacity", "temperature"
],
"entities": {
Platform.SWITCH: {
"bubble": {
"device_class": SwitchDeviceClass.SWITCH,
},
"cold_water": {
"device_class": SwitchDeviceClass.SWITCH,
},
"bathtub": {
"device_class": SwitchDeviceClass.SWITCH,
},
"safe": {
"device_class": SwitchDeviceClass.SWITCH,
},
"cold_water_dot": {
"device_class": SwitchDeviceClass.SWITCH,
},
"change_litre_switch": {
"device_class": SwitchDeviceClass.SWITCH,
},
"cold_water_ai": {
"device_class": SwitchDeviceClass.SWITCH,
},
"cold_water_pressure": {
"device_class": SwitchDeviceClass.SWITCH,
},
"person_mode_one": {
"device_class": SwitchDeviceClass.SWITCH,
},
"person_mode_two": {
"device_class": SwitchDeviceClass.SWITCH,
},
"person_mode_three": {
"device_class": SwitchDeviceClass.SWITCH,
},
"gesture_function": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.CLIMATE: {
"water_heater": {
"power": "power",
"hvac_modes": {
"off": {"power": "off"},
"heat": {"power": "on", "mode": "shower"}
},
"target_temperature": "temperature",
"current_temperature": "out_water_tem",
"min_temp": 20,
"max_temp": 60,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
}
},
Platform.SELECT: {
"mode": {
"options": {
"shower": {"mode": "shower"},
"bath": {"mode": "bath"},
"mixed": {"mode": "mixed"},
"eco": {"mode": "eco"}
}
},
"power_level": {
"options": {
"low": {"power_level": "0"},
"medium": {"power_level": "1"},
"high": {"power_level": "2"},
"max": {"power_level": "3"}
}
},
"type_machine": {
"options": {
"standard": {"type_machine": "20"},
"premium": {"type_machine": "21"},
"deluxe": {"type_machine": "22"}
}
},
"capacity": {
"options": {
"small": {"capacity": "1"},
"medium": {"capacity": "2"},
"large": {"capacity": "3"}
}
},
"gesture_function_type": {
"options": {
"none": {"gesture_function_type": "0"},
"wave": {"gesture_function_type": "1"},
"touch": {"gesture_function_type": "2"},
"proximity": {"gesture_function_type": "3"}
}
}
},
Platform.SENSOR: {
"out_water_tem": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"water_volume": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.TOTAL_INCREASING
},
"zero_cold_tem": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"bath_out_volume": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.TOTAL_INCREASING
},
"return_water_tem": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"change_litre": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.TOTAL_INCREASING
},
"bathtub_water_level": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.TOTAL_INCREASING
},
"temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"gas_lift_percent": {
"device_class": SensorDeviceClass.POWER_FACTOR,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"person_tem_one": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"person_tem_two": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"person_tem_three": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"in_water_tem": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"error_code": {
"device_class": SensorDeviceClass.ENUM
}
}
}
}
}

View File

@@ -76,15 +76,16 @@ DEVICE_MAPPING = {
Platform.SENSOR: {
"micro_leak_protection_value": {
"device_class": SensorDeviceClass.PRESSURE,
"unit_of_measurement": "kPa",
"state_class": SensorStateClass.MEASUREMENT
},
"regeneration_current_stages": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"water_hardness": {
"device_class": SensorDeviceClass.WATER,
"state_class": SensorStateClass.MEASUREMENT
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.TOTAL_INCREASING
},
"timing_regeneration_hour": {
"device_class": SensorDeviceClass.DURATION,
@@ -107,12 +108,10 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"maintenance_reminder_setting": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"mixed_water_gear": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"use_days": {
"device_class": SensorDeviceClass.DURATION,
@@ -126,6 +125,7 @@ DEVICE_MAPPING = {
},
"velocity": {
"device_class": SensorDeviceClass.SPEED,
"unit_of_measurement": "m/s",
"state_class": SensorStateClass.MEASUREMENT
},
"supply_voltage": {
@@ -149,12 +149,10 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"salt_setting": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"regeneration_count": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"battery_voltage": {
"device_class": SensorDeviceClass.VOLTAGE,
@@ -162,8 +160,7 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"error": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"days_since_last_two_regeneration": {
"device_class": SensorDeviceClass.DURATION,
@@ -176,20 +173,16 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"real_date_setting_year": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"real_date_setting_month": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"real_date_setting_day": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"category": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"real_time_setting_min": {
"device_class": SensorDeviceClass.DURATION,
@@ -197,28 +190,27 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"regeneration_stages": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
"device_class": SensorDeviceClass.ENUM
},
"soft_available_big": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.MEASUREMENT
"state_class": SensorStateClass.TOTAL_INCREASING
},
"water_consumption_big": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.MEASUREMENT
"state_class": SensorStateClass.TOTAL_INCREASING
},
"water_consumption_today": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.MEASUREMENT
"state_class": SensorStateClass.TOTAL_INCREASING
},
"water_consumption_average": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.MEASUREMENT
"state_class": SensorStateClass.TOTAL_INCREASING
},
"salt_alarm_threshold": {
"device_class": SensorDeviceClass.WEIGHT,
@@ -227,6 +219,7 @@ DEVICE_MAPPING = {
},
"leak_water_protection_value": {
"device_class": SensorDeviceClass.PRESSURE,
"unit_of_measurement": "kPa",
"state_class": SensorStateClass.MEASUREMENT
}
}

View File

@@ -0,0 +1,157 @@
from homeassistant.const import Platform, UnitOfTemperature, UnitOfTime, PERCENTAGE
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
from homeassistant.components.humidifier import HumidifierDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [
"power", "disinfect_on_off", "netions_on_off", "airdry_on_off",
"wind_gear", "wind_speed", "light_color", "bright_led",
"humidity_mode", "tank_status", "humidity", "cur_humidity"
],
"entities": {
Platform.SWITCH: {
"disinfect_on_off": {
"device_class": SwitchDeviceClass.SWITCH,
},
"netions_on_off": {
"device_class": SwitchDeviceClass.SWITCH,
},
"airdry_on_off": {
"device_class": SwitchDeviceClass.SWITCH,
},
"power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"buzzer": {
"device_class": SwitchDeviceClass.SWITCH,
},
"power_on_timer": {
"device_class": SwitchDeviceClass.SWITCH,
},
"power_off_timer": {
"device_class": SwitchDeviceClass.SWITCH,
},
"display_on_off": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.BINARY_SENSOR: {
"add_water_flag": {
"device_class": BinarySensorDeviceClass.PROBLEM,
}
},
Platform.HUMIDIFIER: {
"humidifier": {
"device_class": HumidifierDeviceClass.HUMIDIFIER,
"power": "power",
"target_humidity": "humidity",
"current_humidity": "cur_humidity",
"min_humidity": 30,
"max_humidity": 80,
"mode": "humidity_mode",
"modes": {
"manual": {"humidity_mode": "manual"},
"auto": {"humidity_mode": "auto"},
"sleep": {"humidity_mode": "sleep"},
"baby": {"humidity_mode": "baby"}
}
}
},
Platform.SELECT: {
"wind_gear": {
"options": {
"low": {"wind_gear": "low"},
"medium": {"wind_gear": "medium"},
"high": {"wind_gear": "high"},
"auto": {"wind_gear": "auto"},
"invalid": {"wind_gear": "invalid"}
}
},
"wind_speed": {
"options": {
"low": {"wind_speed": "low"},
"medium": {"wind_speed": "medium"},
"high": {"wind_speed": "high"},
"auto": {"wind_speed": "auto"}
}
},
"light_color": {
"options": {
"warm": {"light_color": "warm"},
"cool": {"light_color": "cool"},
"white": {"light_color": "white"},
"blue": {"light_color": "blue"},
"green": {"light_color": "green"},
"red": {"light_color": "red"},
"off": {"light_color": "off"}
}
},
"bright_led": {
"options": {
"light": {"bright_led": "light"},
"dim": {"bright_led": "dim"},
"off": {"bright_led": "off"}
}
},
"tank_status": {
"options": {
"normal": {"tank_status": "0"},
"low": {"tank_status": "1"},
"empty": {"tank_status": "2"},
"error": {"tank_status": "3"}
}
}
},
Platform.SENSOR: {
"running_percent": {
"device_class": SensorDeviceClass.POWER_FACTOR,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"error_code": {
"device_class": SensorDeviceClass.ENUM
},
"cur_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"sensor_battery": {
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"sensor_humidify": {
"device_class": SensorDeviceClass.HUMIDITY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"sensor_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"air_dry_left_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"time_on": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"time_off": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -1,6 +1,5 @@
from homeassistant.const import Platform, UnitOfTemperature
from homeassistant.const import Platform, UnitOfTemperature, PRECISION_HALVES
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.climate.const import PRECISION_HALVES
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass

View File

@@ -0,0 +1,151 @@
from homeassistant.components.humidifier import (
HumidifierEntity,
HumidifierDeviceClass
)
from homeassistant.const import Platform
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .midea_entity import MideaEntity
from . import load_device_config
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up humidifier entities for Midea devices."""
account_bucket = hass.data.get(DOMAIN, {}).get("accounts", {}).get(config_entry.entry_id)
if not account_bucket:
async_add_entities([])
return
device_list = account_bucket.get("device_list", {})
coordinator_map = account_bucket.get("coordinator_map", {})
devs = []
for device_id, info in device_list.items():
device_type = info.get("type")
sn8 = info.get("sn8")
config = await load_device_config(hass, device_type, sn8) or {}
entities_cfg = (config.get("entities") or {}).get(Platform.HUMIDIFIER, {})
manufacturer = config.get("manufacturer")
rationale = config.get("rationale")
coordinator = coordinator_map.get(device_id)
device = coordinator.device if coordinator else None
for entity_key, ecfg in entities_cfg.items():
devs.append(MideaHumidifierEntity(
coordinator, device, manufacturer, rationale, entity_key, ecfg
))
async_add_entities(devs)
class MideaHumidifierEntity(MideaEntity, HumidifierEntity):
"""Generic humidifier entity."""
def __init__(self, coordinator, device, manufacturer, rationale, entity_key, config):
super().__init__(
coordinator,
device.device_id,
device.device_name,
f"T0x{device.device_type:02X}",
device.sn,
device.sn8,
device.model,
entity_key,
device=device,
manufacturer=manufacturer,
rationale=rationale,
config=config,
)
self._device = device
self._manufacturer = manufacturer
self._rationale = rationale
self._entity_key = entity_key
self._config = config
@property
def device_class(self):
"""Return the device class."""
return self._config.get("device_class", HumidifierDeviceClass.HUMIDIFIER)
@property
def is_on(self):
"""Return if the humidifier is on."""
power_key = self._config.get("power")
if power_key:
value = self.device_attributes.get(power_key)
if isinstance(value, bool):
return value
return value == 1 or value == "on" or value == "true"
return False
@property
def target_humidity(self):
"""Return the target humidity."""
target_humidity_key = self._config.get("target_humidity")
if target_humidity_key:
return self.device_attributes.get(target_humidity_key, 0)
return 0
@property
def current_humidity(self):
"""Return the current humidity."""
current_humidity_key = self._config.get("current_humidity")
if current_humidity_key:
return self.device_attributes.get(current_humidity_key, 0)
return 0
@property
def min_humidity(self):
"""Return the minimum humidity."""
return self._config.get("min_humidity", 30)
@property
def max_humidity(self):
"""Return the maximum humidity."""
return self._config.get("max_humidity", 80)
@property
def mode(self):
"""Return the current mode."""
mode_key = self._config.get("mode")
if mode_key:
return self.device_attributes.get(mode_key, "manual")
return "manual"
@property
def available_modes(self):
"""Return the available modes."""
modes = self._config.get("modes", {})
return list(modes.keys())
async def async_turn_on(self, **kwargs):
"""Turn the humidifier on."""
power_key = self._config.get("power")
if power_key:
await self._device.set_attribute(power_key, True)
async def async_turn_off(self, **kwargs):
"""Turn the humidifier off."""
power_key = self._config.get("power")
if power_key:
await self._device.set_attribute(power_key, False)
async def async_set_humidity(self, humidity: int):
"""Set the target humidity."""
target_humidity_key = self._config.get("target_humidity")
if target_humidity_key:
await self._device.set_attribute(target_humidity_key, humidity)
async def async_set_mode(self, mode: str):
"""Set the mode."""
mode_key = self._config.get("mode")
modes = self._config.get("modes", {})
if mode_key and mode in modes:
mode_config = modes[mode]
for attr_key, attr_value in mode_config.items():
await self._device.set_attribute(attr_key, attr_value)

View File

@@ -7,5 +7,5 @@
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/sususweet/midea-meiju-codec/issues",
"requirements": [],
"version": "v0.0.3"
"version": "v0.0.5"
}

View File

@@ -124,8 +124,10 @@ class MideaEntity(CoordinatorEntity[MideaDataUpdateCoordinator], Entity):
@property
def available(self) -> bool:
"""Return if entity is available."""
MideaLogger.debug(f"available available={self.coordinator.data} ")
return self.coordinator.data.available
if self.coordinator.data:
return self.coordinator.data.available
else:
return False
async def _publish_command(self) -> None:
"""Publish commands to the device."""

View File

@@ -66,4 +66,26 @@ class MideaSensorEntity(MideaEntity, SensorEntity):
@property
def native_value(self):
"""Return the native value of the sensor."""
return self.device_attributes.get(self._entity_key)
value = self.device_attributes.get(self._entity_key)
# Handle invalid string values
if isinstance(value, str) and value.lower() in ['invalid', 'none', 'null', '']:
return None
# Try to convert to number if it's a string that looks like a number
if isinstance(value, str):
try:
# Try integer first
if '.' not in value:
return int(value)
# Then float
return float(value)
except (ValueError, TypeError):
# If conversion fails, return None for numeric sensors
# or return the original string for enum sensors
device_class = self._config.get("device_class")
if device_class and "enum" not in device_class.lower():
return None
return value
return value

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

BIN
img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
img_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB