Skip to content

feat: support MGH20VE5PRO washer dryer - #44

Closed
jndxhuxiehang wants to merge 4 commits into
Cyborg2017:stagingfrom
jndxhuxiehang:agent/d9-dual-drum-dryer-support
Closed

feat: support MGH20VE5PRO washer dryer#44
jndxhuxiehang wants to merge 4 commits into
Cyborg2017:stagingfrom
jndxhuxiehang:agent/d9-dual-drum-dryer-support

Conversation

@jndxhuxiehang

@jndxhuxiehang jndxhuxiehang commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add SN8-specific support for the upper-dryer/lower-washer D9 design used by 38208002 and 38209227
  • query the independent db and dc data types once during initialization, then rely on device reports instead of alternate polling
  • derive the command bucket from the active property and attach the matching drum location
  • expose complete lower-washer and upper-dryer controls and status entities, with English and Simplified Chinese names and icons
  • normalize powered-off drum state so stale running, remaining-time, and drying-stage values are cleared

Review feedback addressed

  1. Existing D9 mappings retain alternate left/right db polling. The two independent db/dc SN8 mappings set alternate_polling to false and issue only the initialization queries.
  2. D9 controls now derive db, dc, or da from the active property, while the SN8 mapping supplies db_location=2 and dc_location=1 defaults.
  3. The shared mapping structure is unchanged. Both affected devices use one dedicated SN8 tuple mapping with its own polling mode.
  4. The mapping now includes lower-drum power, start/stop, program, temperature, detergent, spin speed, rinse count, child lock, detergent warning, and status; upper-drum power, start/stop, program, drying intensity, child lock, sterilization, anti-wrinkle, and status are also included.

Root cause

The upper drum reports and accepts controls through the dc data type at location 1, while the lower drum uses db at location 2. Treating this design as a legacy left/right D9 caused unnecessary alternating polls, discarded independent reports, and routed upper-drum controls through the lower-drum bucket.

User impact

Owners of both known SN8 variants can monitor and control the lower washer and upper dryer independently. Existing D9 devices keep their current alternate-polling behavior.

Validation

  • python3 scripts/format_code.py --check
  • python3 scripts/sort_translations.py --check
  • Python compilation, JSON parsing, translation/icon coverage, and git diff --check
  • targeted behavior checks for mapping selection, polling mode isolation, 03db/03dc merging, legacy _l/_r behavior, command bucket/location generation, and power-off state normalization
  • Lua control-frame verification for db/location 2 and dc/location 1 using the device Lua file
  • real MGH20VE5PRO validation on Home Assistant 2026.7.4: lower and upper controls/status, configuration check, restart, clean integration logs, and powered-off standby/idle/unknown-time state

Add model-specific wash and dry program mappings with separate lower and upper drum controls. Route D9 commands and dryer status updates through their matching protocol buckets.
@Cyborg2017

Cyborg2017 commented Jul 29, 2026 via email

Copy link
Copy Markdown
Owner

@Cyborg2017 Cyborg2017 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1、device_mapping中 程序 定义内联到 options 中以符合项目规范的,这个必须修正;
2、由于不清楚是否还存在其他双筒数据结构,因此暂时请与项目保持一致,即:上下筒请以原程序名+位置来做translation_key,例如 dc_program_t,db_program_b (top / bottom,分别代表上下桶缩写)
而翻译则使用后缀的形式区分,例如 洗涤程序(上筒)、洗涤程序(下筒)、剩余时间(下筒)等等区分;

以下是简要修正点:

  1. 程序定义修正:将所有程序选项直接内联到 options 字典中,不允许存在 MGH20VE5PRO_PROGRAMS

  2. 命名规范修正:所有实体键名使用后缀形式

    • 下筒:db_power_b, db_program_b, db_remain_time_b, etc.
    • 上筒:dc_power_t, dc_program_t, dc_remain_time_t, etc.
  3. 翻译规范修正:使用后缀区分

    • "db_program_b": {"name": "洗涤程序(下筒)"}
    • "dc_program_t": {"name": "洗涤程序(上筒)"}
  4. 图标映射修正:icons.json 中的键名同步修改为 _b/_t 后缀

  5. 另外 "default_values": {
    "db_location": 2,
    "dc_location": 1,
    }, 是什么用?

@jndxhuxiehang

Copy link
Copy Markdown
Contributor Author

已按 review 意见在 471058a 中完成修正:

  • 洗涤和烘干程序已分别内联到 options
  • 型号专属实体、translation key 和 icons key 已统一改为 _b / _t 后缀
  • 中文名称已改为 名称(下筒) / 名称(上筒) 的后缀形式
  • 实体键与设备协议属性通过 attribute 分离,因此 Home Assistant 实体使用 db_power_b 等名称时,实际状态读取和控制仍使用设备协议中的 db_power,不会改变控制报文

关于 default_values:MGH20VE5PRO 的下筒使用 db_location=2,上筒使用 dc_location=1,但设备的部分状态上报不包含 location。这里的默认值会在状态缺少对应字段时补入设备当前数据;发送控制时,prepare_control_data() 根据当前控制属性提取 db / dc bucket,再自动附带相应的 location。这样每条上下筒控制命令都会带正确的位置标识,也避免在每个实体的 command 中重复配置 location。这两个值来自 MGH20VE5PRO 实机报文和控制验证。

@Cyborg2017

Cyborg2017 commented Jul 30, 2026 via email

Copy link
Copy Markdown
Owner

@Cyborg2017

Copy link
Copy Markdown
Owner

这里有一个改动参考,看看是否有效:https://github.com/Cyborg2017/midea_smart_home/commits/D9-test/

@jndxhuxiehang

Copy link
Copy Markdown
Contributor Author

已参考 D9-test9626755 / 8d64d79,在 3eeb9a6 中完成调整:

  • D9 通过 initial_query 中的数据前缀数量区分传统交替轮询设备和独立 db / dc 上报设备;MGH20VE5PRO 初始化查询一次后依赖设备上报
  • 移除了本 PR 新增的 attributealternate_polling 和型号级 default_values 用法;实体键恢复协议原名,仅用 translation_key_b / _t 区分上下筒
  • 控制 bucket 按 da_location / dc_location / db_location 选择,location 放回各可控实体的 command
  • 保留了现有 PR 对异步 03dc 不消耗待匹配 03db poll location 的处理

另外验证参考映射时发现,db_power / dc_power 没有 location command 的情况下,prepare_control_data({"dc_power": "on"}, {}) 会落到默认 db bucket。因此本提交给上下筒的 power 实体也分别补了 db_location=2dc_location=1,并检查了所有可控实体都带对应 location。

同时调整了 push 设备关机状态处理顺序,先把运行状态归一为 standby,再计算 control status / progress / remain time,避免关机后仍显示 start 和非 idle 进度。

已通过格式、翻译排序、Python/JSON 静态校验,以及 push/poll 隔离、03db/03dc 合并和 bucket/location 的定向测试。此版本尚未重新在实机上回归。

@Cyborg2017

Copy link
Copy Markdown
Owner

直接在我提供的参考基础上,指出哪里与实际有出入的地方,我会调整合并。

@jndxhuxiehang

Copy link
Copy Markdown
Contributor Author

可以,后续以你提供的 D9-test 为基础统一调整即可。我们这边结合 MGH20VE5PRO 实机报文和现有定向验证,确认有以下差异:

  1. 上下筒控制必须带对应 location

    • 下筒:db_location=2
    • 上筒:dc_location=1
    • 参考映射中的其他可控实体已经带了 location,但 db_power / dc_power 没有。按当前 prepare_control_data()prepare_control_data({"dc_power": "on"}, {}) 会落到默认 db bucket,所以两个 power 实体也需要分别加 command: {"db_location": 2} / command: {"dc_location": 1}
  2. 设备会独立异步上报 03dc
    03dc 可能在等待传统 D9 的 03db 轮询响应期间到达。_pending_poll_location 应只在收到 03db 时取出并清空;如果任意状态包都清空,先到的 03dc 会消耗它,后续 03dbpoll_location=None 被丢弃。

  3. 关机帧可能保留旧运行状态
    实机在 db_power/dc_power=off 时,包内仍可能保留上一次的 running_status=start、progress 或 dry status。需要先把关机筒归一为 running_status=standby(上筒同时 dry_status=idle),再计算 control status、progress 和 remain time;否则 Home Assistant 会出现已关机但 control status 仍为 start、进度仍非 idle 的矛盾状态。

另外是展示层缺项,不涉及协议控制:参考分支目前缺少 db_detergent_needed_b 的英文翻译和图标,中文缺少 db_error_code_bdb_progress_bdb_remain_time_b,并且 db_progress_bdb_running_status_bdc_dry_status_tdc_running_status_t 的中英文 state 翻译未补齐。

其余 SN8 映射、20 个洗涤程序、16 个烘干/护理程序以及上下筒实体范围与实机适配一致。

@Cyborg2017

Cyborg2017 commented Jul 31, 2026 via email

Copy link
Copy Markdown
Owner

@Cyborg2017

Copy link
Copy Markdown
Owner

03dc目前看只是看push数据就好了啊,跟轮询有什么关系? 关于power off的处理逻辑顺序问题,可以实际测一下,至少目前看原有排序对于轮询设备是可行的; 另外原d9设备的两个桶都是洗烘一体的,所以针对新T0xD9的洗衣桶、烘干桶需要你自己去调试,列出全部的progress对应映射。

---- Replied Message ---- | From | @.> | | Date | 7/31/2026 00:08 | | To | @.> | | Cc | Yang @.>, @.> | | Subject | Re: [Cyborg2017/midea_smart_home] feat: support MGH20VE5PRO washer dryer (PR #44) | jndxhuxiehang left a comment (Cyborg2017/midea_smart_home#44) 可以,后续以你提供的 D9-test 为基础统一调整即可。我们这边结合 MGH20VE5PRO 实机报文和现有定向验证,确认有以下差异: 上下筒控制必须带对应 location 下筒:db_location=2 上筒:dc_location=1 参考映射中的其他可控实体已经带了 location,但 db_power / dc_power 没有。按当前 prepare_control_data(),prepare_control_data({"dc_power": "on"}, {}) 会落到默认 db bucket,所以两个 power 实体也需要分别加 command: {"db_location": 2} / command: {"dc_location": 1}。 设备会独立异步上报 03dc 03dc 可能在等待传统 D9 的 03db 轮询响应期间到达。_pending_poll_location 应只在收到 03db 时取出并清空;如果任意状态包都清空,先到的 03dc 会消耗它,后续 03db 因 poll_location=None 被丢弃。 关机帧可能保留旧运行状态 实机在 db_power/dc_power=off 时,包内仍可能保留上一次的 running_status=start、progress 或 dry status。需要先把关机筒归一为 running_status=standby(上筒同时 dry_status=idle),再计算 control status、progress 和 remain time;否则 Home Assistant 会出现已关机但 control status 仍为 start、进度仍非 idle 的矛盾状态。 另外是展示层缺项,不涉及协议控制:参考分支目前缺少 db_detergent_needed_b 的英文翻译和图标,中文缺少 db_error_code_b、db_progress_b、db_remain_time_b,并且 db_progress_b、db_running_status_b、dc_dry_status_t、dc_running_status_t 的中英文 state 翻译未补齐。 其余 SN8 映射、20 个洗涤程序、16 个烘干/护理程序以及上下筒实体范围与实机适配一致。 — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today! You are receiving this because you commented.Message ID: @.***>

如上回复,b3d4cac
中的dc_dry_status我预估和TxDC干衣机设备应该是一致的,需要你测试后确认或补充。

@Cyborg2017

Copy link
Copy Markdown
Owner

长时间未回复,PR关闭

@Cyborg2017 Cyborg2017 closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants