Merge pull request #88 from Cyborg2017/master

Fix functionality gaps for several specific devices; add support for two new device models T0xB6 and T0xB8Master
This commit is contained in:
Yingqi Tang
2026-01-07 11:52:50 +08:00
committed by GitHub
11 changed files with 486 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
from homeassistant.components.switch import SwitchDeviceClass
from homeassistant.const import Platform, UnitOfTime, UnitOfArea, UnitOfTemperature
from homeassistant.const import Platform, PERCENTAGE, UnitOfTime, UnitOfArea, UnitOfTemperature
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
@@ -22,13 +22,20 @@ DEVICE_MAPPING = {
"light_brightness": {
"min": 20,
"max": 100,
"step": 1
"step": 1,
"unit_of_measurement": PERCENTAGE
},
"custom_height": {
"min": 0,
"max": 100,
"step": 10,
"translation_key": "laundry_height",
},
"custom_timing": {
"min": 0,
"max": 180,
"step": 5,
"unit_of_measurement": UnitOfTime.MINUTES
}
},
Platform.SWITCH: {

View File

@@ -165,7 +165,13 @@ DEVICE_MAPPING = {
"max": 100,
"step": 1,
"unit_of_measurement": PERCENTAGE
}
},
"radar_induction_closing_time": {
"min": 1,
"max": 5,
"step": 1,
"unit_of_measurement": UnitOfTime.MINUTES
}
},
Platform.SWITCH: {
"radar_induction_enable": {

View File

@@ -1,5 +1,5 @@
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import Platform, UnitOfElectricPotential
from homeassistant.const import Platform, PERCENTAGE, UnitOfTime, UnitOfElectricPotential
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
@@ -44,14 +44,6 @@ DEVICE_MAPPING = {
}
},
Platform.BUTTON: {
"light_off": {
"command": {"electronic_control_version": 2, "type": "b6", "b6_action": "setting",
"setting": "light", "light": "off"},
},
"light_on": {
"command": {"electronic_control_version": 2, "type": "b6", "b6_action": "setting",
"setting": "light", "light": "on"},
},
"left_stove_off": {
"command": {"electronic_control_version": 2, "type": "b7", "b7_work_burner_control": 1,
"b7_function_control": 1},
@@ -84,7 +76,166 @@ DEVICE_MAPPING = {
"extreme": {"gear": 4},
}
},
"light": {
"options": {
"off": {"light": "off"},
"on": {"light": "on"}
},
"command": {
"electronic_control_version": 2,
"type": "b6",
"b6_action": "setting",
"setting": "light"
}
}
},
}
},
"730007H8": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": ["lightness"],
"calculate": {
"get": [
{
"lvalue": "[b7_vbattery]",
"rvalue": "float([b7_vbatt] / 1000.0)"
},
{
"lvalue": "[total_energy_consumption]",
"rvalue": "float([total_working_time] / 60 * 0.14)"
}
],
},
"entities": {
Platform.SWITCH: {
"power": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.SENSOR: {
"b7_left_status": {
"device_class": SensorDeviceClass.ENUM,
"translation_key": "left_status",
},
"b7_right_status": {
"device_class": SensorDeviceClass.ENUM,
"translation_key": "right_status",
},
"b7_vbattery":{
"device_class": SensorDeviceClass.VOLTAGE,
"unit_of_measurement": UnitOfElectricPotential.VOLT,
"state_class": SensorStateClass.MEASUREMENT,
"translation_key": "battery_voltage",
},
"total_working_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.TOTAL_INCREASING,
},
"total_energy_consumption": {
"device_class": SensorDeviceClass.ENERGY,
"unit_of_measurement": "kWh",
"state_class": SensorStateClass.TOTAL_INCREASING,
}
},
Platform.BUTTON: {
"left_stove_off": {
"command": {"electronic_control_version": 2, "type": "b7", "b7_work_burner_control": 1,
"b7_function_control": 1},
},
"right_stove_off": {
"command": {"electronic_control_version": 2, "type": "b7", "b7_work_burner_control": 2,
"b7_function_control": 1},
}
},
Platform.NUMBER: {
"lightness": {
"min": 10,
"max": 100,
"step": 5,
"command": {
"electronic_control_version": 2,
"type": "b6",
"b6_action": "setting",
"setting": "light",
"lightness": "{value}"
}
}
},
Platform.SELECT: {
"gear": {
"options": {
"off": {"gear": 0},
"low": {"gear": 1},
"medium": {"gear": 2},
"high": {"gear": 3},
"extreme": {"gear": 4},
}
},
"gesture": {
"options": {
"off": {"gesture": "off"},
"on": {"gesture": "on"}
},
"command": {
"electronic_control_version": 2,
"type": "b6",
"b6_action": "setting",
"setting": "gesture"
}
},
"gesture_value": {
"options": {
"开关机": {"gesture_value": 1},
"调风速": {"gesture_value": 2},
"开关灯": {"gesture_value": 3},
"开关机+调风速": {"gesture_value": 4}
},
"command": {
"electronic_control_version": 2,
"type": "b6",
"b6_action": "setting",
"setting": "gesture"
}
},
"gesture_sensitivity_value": {
"options": {
"low": {"gesture_sensitivity_value": 1},
"medium": {"gesture_sensitivity_value": 2},
"high": {"gesture_sensitivity_value": 3}
},
"command": {
"electronic_control_version": 2,
"type": "b6",
"b6_action": "setting",
"setting": "gesture"
}
},
"inverter": {
"options": {
"off": {"inverter": "off"},
"on": {"inverter": "on"}
},
"command": {
"electronic_control_version": 2,
"type": "b6",
"b6_action": "control"
}
},
"light": {
"options": {
"off": {"light": "off"},
"on": {"light": "on"}
},
"command": {
"electronic_control_version": 2,
"type": "b6",
"b6_action": "setting",
"setting": "light"
}
}
}
}
}
}

View File

@@ -117,5 +117,94 @@ DEVICE_MAPPING = {
}
}
}
},
"750004AT": {
"rationale": ["off", "on"],
"queries": [
{"query_type": "work"}
],
"centralized": ["work_status", "battery_percent", "sweep_mop_mode", "mop", "sub_work_status"],
"entities": {
Platform.SELECT: {
"work_status": {
"options": {
"charge": {"work_status": "charge"},
"charge_pause": {"work_status": "charge_pause"},
"charge_continue": {"work_status": "charge_continue"},
"auto_clean": {"work_status": "auto_clean"},
"auto_clean_pause": {"work_status": "auto_clean_pause"},
"auto_clean_continue": {"work_status": "auto_clean_continue"},
"pause": {"work_status": "pause"},
"stop": {"work_status": "stop"},
"work": {"work_status": "work"}
}
},
"fan_level": {
"options": {
"soft": {"fan_setting": {"level": "soft"}},
"normal": {"fan_setting": {"level": "normal"}},
"high": {"fan_setting": {"level": "high"}}
}
},
"sweep_mop_mode": {
"options": {
"sweep_and_mop": {"work_mode_setting": {"work_mode": "sweep_and_mop"}},
"sweep": {"work_mode_setting": {"work_mode": "sweep"}},
"mop": {"work_mode_setting": {"work_mode": "mop"}},
"sweep_then_mop": {"work_mode_setting": {"work_mode": "sweep_then_mop"}}
}
}
},
Platform.BINARY_SENSOR: {
"is_charging": {
"device_class": BinarySensorDeviceClass.BATTERY_CHARGING,
"on_value": ["charging"],
"off_value": ["work", "stop", "pause", "on_base"]
}
},
Platform.SENSOR: {
"battery_percent": {
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
},
"voice_level": {
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
},
"area": {
"device_class": SensorDeviceClass.AREA,
"unit_of_measurement": UnitOfArea.SQUARE_METERS,
"state_class": SensorStateClass.MEASUREMENT
},
"work_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"dust_count": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
},
"sweep_then_mop_mode_progress": {
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
},
"sub_work_status": {
"device_class": SensorDeviceClass.ENUM,
},
"mop": {
"device_class": SensorDeviceClass.ENUM,
},
"sweep_mop_mode": {
"device_class": SensorDeviceClass.ENUM,
},
"work_status": {
"device_class": SensorDeviceClass.ENUM,
}
}
}
}
}

View File

@@ -84,6 +84,11 @@ DEVICE_MAPPING = {
"off": {"power": "off"},
"heat": {"power": "on"}
},
"preset_modes": {
"left_warm": {"gear": 1},
"right_warm": {"gear": 2},
"full_on": {"gear": 3}
},
"target_temperature": "temperature",
"current_temperature": "cur_temperature",
"min_temp": 5,
@@ -92,20 +97,16 @@ DEVICE_MAPPING = {
"precision": PRECISION_WHOLE,
}
},
Platform.SELECT: {
"gear": {
"options": {
"left_warm": {"gear": 1},
"right_warm": {"gear": 2},
"full_on": {"gear": 3}
}
}
},
Platform.SENSOR: {
"power_statistics": {
"device_class": SensorDeviceClass.POWER,
"unit_of_measurement": UnitOfPower.WATT,
"state_class": SensorStateClass.MEASUREMENT
},
"cur_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
}
}
}

View File

@@ -152,6 +152,10 @@ DEVICE_MAPPING = {
}
},
Platform.SENSOR: {
"deep_filter_percent": {
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"temperature_feedback": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,

View File

@@ -216,6 +216,11 @@ DEVICE_MAPPING = {
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"cur_humidity": {
"device_class": SensorDeviceClass.HUMIDITY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"air_dry_left_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,

View File

@@ -107,6 +107,18 @@ class MideaNumberEntity(MideaEntity, NumberEntity):
"""Set the value of the number entity."""
# 确保值在有效范围内
value = max(self._min_value, min(self._max_value, value))
# 首先尝试使用command字段如果存在
command = self._config.get("command")
if command and isinstance(command, dict):
# 替换{value}模板
import copy
merged_command = copy.deepcopy(command)
for key, val in merged_command.items():
if isinstance(val, str) and "{value}" in val:
merged_command[key] = val.replace("{value}", str(int(value)))
await self.async_set_attributes(merged_command)
return
# Use attribute from config if available, otherwise fall back to entity_key
attribute = self._config.get("attribute", self._entity_key)

View File

@@ -79,7 +79,15 @@ class MideaSelectEntity(MideaEntity, SelectEntity):
async def async_select_option(self, option: str):
new_status = self._key_options.get(option)
if new_status:
await self.async_set_attributes(new_status)
# 优先使用command字段
command = self._config.get("command")
if command and isinstance(command, dict):
# 合并选项值到命令
merged_command = {**command, **new_status}
await self.async_set_attributes(merged_command)
else:
# 原有逻辑(向后兼容)
await self.async_set_attributes(new_status)
def update_state(self, status):
try:

View File

@@ -396,7 +396,16 @@
"name": "Water Heater"
},
"electric_heater": {
"name": "Electric Heater"
"name": "Electric Heater",
"state_attributes": {
"preset_mode": {
"state": {
"left_warm": "Left Warm",
"right_warm": "Right Warm",
"full_on": "Full On"
}
}
}
},
"heating": {
"name": "Heating"
@@ -570,6 +579,21 @@
"gesture_function_type": {
"name": "Gesture Function Type"
},
"gesture": {
"name": "Gesture"
},
"gesture_value": {
"name": "Gesture Value"
},
"gesture_sensitivity_value": {
"name": "Gesture Sensitivity Value"
},
"inverter": {
"name": "Inverter"
},
"light": {
"name": "Light"
},
"humidity_mode": {
"name": "Humidity Mode",
"state": {
@@ -868,10 +892,7 @@
"state": {
"low": "Low",
"medium": "Medium",
"high": "High",
"left_warm": "Left Warm",
"right_warm": "Right Warm",
"full_on": "Full On"
"high": "High"
}
},
"ptc": {
@@ -1031,6 +1052,9 @@
}
},
"sensor": {
"deep_filter_percent": {
"name": "Filter Life Remaining"
},
"fresh_air_temp": {
"name": "Fresh Air Temp"
},
@@ -2052,6 +2076,12 @@
}
},
"number": {
"custom_timing": {
"name": "Light Off Timer"
},
"radar_induction_closing_time": {
"name": "Night Light Timer"
},
"keep_warm_time": {
"name": "Keep Warm Time"
},

View File

@@ -396,7 +396,16 @@
"name": "热水器"
},
"electric_heater": {
"name": "取暖器"
"name": "取暖器",
"state_attributes": {
"preset_mode": {
"state": {
"left_warm": "左暖",
"right_warm": "右暖",
"full_on": "全开"
}
}
}
},
"heating": {
"name": "采暖"
@@ -679,6 +688,38 @@
"gesture_function_type": {
"name": "手势功能类型"
},
"gesture": {
"name": "手势功能",
"state": {
"off": "关闭",
"on": "开启"
}
},
"gesture_value": {
"name": "手势操作"
},
"gesture_sensitivity_value": {
"name": "手势灵敏度",
"state": {
"low": "低",
"medium": "中",
"high": "高"
}
},
"inverter": {
"name": "变频巡航",
"state": {
"off": "关闭",
"on": "开启"
}
},
"light": {
"name": "照明",
"state": {
"off": "关闭",
"on": "开启"
}
},
"humidity_mode": {
"name": "湿度模式",
"state": {
@@ -960,7 +1001,32 @@
"power_on": "开机",
"cancel": "取消",
"pause": "暂停",
"resume": "继续"
"resume": "继续",
"charge": "开始回充",
"charge_pause": "回充暂停",
"charge_continue": "继续回充",
"auto_clean": "自动清扫",
"auto_clean_pause": "清扫暂停",
"auto_clean_continue": "继续清扫",
"stop": "停止",
"work": "清扫"
}
},
"fan_level": {
"name": "吸力",
"state": {
"soft": "轻柔",
"normal": "标准",
"high": "强力"
}
},
"sweep_mop_mode": {
"name": "清洁模式",
"state": {
"sweep_and_mop": "扫拖一体",
"sweep": "仅扫地",
"mop": "仅拖地",
"sweep_then_mop": "先扫后拖"
}
},
"voice": {
@@ -981,12 +1047,11 @@
"gear": {
"name": "档位",
"state": {
"off":"关闭",
"low": "低",
"medium": "中",
"high": "高",
"left_warm": "左暖",
"right_warm": "右暖",
"full_on": "全开"
"extreme": "爆炒"
}
},
"ptc": {
@@ -1164,6 +1229,9 @@
}
},
"sensor": {
"deep_filter_percent": {
"name": "滤芯寿命"
},
"fresh_air_temp": {
"name": "新风温度"
},
@@ -1177,16 +1245,65 @@
"name": "风扇档位"
},
"mop": {
"name": "拖布模式"
"name": "拖布状态",
"state": {
"yes": "已安装",
"no": "未安装",
"lack_water": "缺水"
}
},
"move_direction": {
"name": "移动方向"
},
"work_status": {
"name": "工作状态"
"name": "当前工作状态",
"state": {
"power_off": "关机",
"power_on": "开机",
"cancel": "取消",
"pause": "暂停",
"resume": "继续",
"charge": "开始回充",
"charge_pause": "回充暂停",
"charge_continue": "继续回充",
"auto_clean": "自动清扫",
"auto_clean_pause": "清扫暂停",
"auto_clean_continue": "继续清扫",
"clean_pause": "清扫暂停",
"clean_continue": "继续清扫",
"stop": "停止",
"work": "清扫",
"error": "错误",
"sleep": "休眠",
"relocate": "重定位",
"map_searching": "建图中",
"clean_mop": "清洗拖布",
"back_clean_mop": "返回清洗拖布",
"clean_mop_pause": "清洗拖布暂停",
"manual_control": "手动控制",
"on_base": "在基站",
"video_cruise": "视频巡航",
"video_cruise_pause": "视频巡航暂停",
"map_searching_pause": "建图暂停"
}
},
"sub_work_status": {
"name": "子工作状态"
"name": "子工作状态",
"state": {
"free": "空闲",
"charging": "充电",
"inject_water": "注水",
"clean_mop": "清洗拖布",
"dry_mop": "风干拖布",
"hot_dry_mop": "热风烘干",
"water_station_error": "基站错误",
"charge_finish": "充电完成",
"erp_mode": "节能模式",
"auto_clean": "自动清洁",
"dust_collect": "集尘",
"cut_hair": "基站自清洁",
"map_change": "地图管理"
}
},
"mode": {
"name": "运行模式"
@@ -1204,7 +1321,7 @@
"name": "预约时间"
},
"area": {
"name": "面积"
"name": "清扫面积"
},
"auto_max_set_temp": {
"name": "自动最大设定温度"
@@ -1234,7 +1351,7 @@
"name": "浴缸水位"
},
"battery_percent": {
"name": "电池百分比"
"name": "当前电量"
},
"battery_voltage": {
"name": "电池电压"
@@ -1399,7 +1516,7 @@
"name": "烘干机"
},
"dust_count": {
"name": "灰尘计数"
"name": "自动集尘频率"
},
"error": {
"name": "错误"
@@ -1671,6 +1788,15 @@
"sweep_then_mop_mode_progress": {
"name": "先扫后拖模式进度"
},
"sweep_mop_mode": {
"name": "当前清洁模式",
"state": {
"sweep_and_mop": "扫拖一体",
"sweep": "仅扫地",
"mop": "仅拖地",
"sweep_then_mop": "先扫后拖"
}
},
"switch_status": {
"name": "开关状态"
},
@@ -2185,6 +2311,15 @@
}
},
"number": {
"lightness": {
"name": "照明亮度"
},
"custom_timing": {
"name": "延时关灯"
},
"radar_induction_closing_time": {
"name": "夜灯延时关闭"
},
"keep_warm_time": {
"name": "保温时间"
},