Skip to content

Add pump switch for Midea dehumidifiers - #181257

Draft
mattrossman wants to merge 6 commits into
home-assistant:devfrom
mattrossman:feature/midea-a1-water-pump-dev
Draft

Add pump switch for Midea dehumidifiers#181257
mattrossman wants to merge 6 commits into
home-assistant:devfrom
mattrossman:feature/midea-a1-water-pump-dev

Conversation

@mattrossman

@mattrossman mattrossman commented Sep 4, 2026

Copy link
Copy Markdown

Proposed change

Add support for the pump switch exposed by Midea A1 dehumidifiers.

The current Home Assistant base includes midea-local 11.0.1, which exposes device capabilities. This change creates the Home Assistant pump switch only when an A1 device reports pump support. Supported devices can then be controlled with switch.turn_on and switch.turn_off.

Device verification

Verified with a Midea Cube 50-Pint Dehumidifier with Pump, model MAD50PS1QWT-A.

dashboard overview with pump tile visible

I turned the pump off and back on from Home Assistant and confirmed both state changes in the Midea smart-home app, verifying communication with the physical device.

Testing

  • Added coverage for creating the pump switch on a pump-capable A1 device.
  • Added coverage for omitting the pump switch when an A1 device does not report pump support.
  • Added coverage for turning the supported pump on and off.
  • Added the corresponding A1 entity and state snapshot.

Related

The capability support is provided by midea-local 11.0.1.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running: python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI balanced review requested due to automatic review settings September 4, 2026 03:57

@home-assistant home-assistant Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @mattrossman

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant

home-assistant Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Hey there @chemelli74, @rokam, @caibinqing, mind taking a look at this pull request as it has been labeled with an integration (midea) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of midea can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign midea Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The description omits mandatory sections from the repository’s pull-request template.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a controllable pump switch for Midea A1 dehumidifiers.

Changes:

  • Adds the A1 pump switch with translation and icon metadata.
  • Adds service-call tests and entity snapshots.
File summaries
File Description
homeassistant/components/midea/switch.py Defines the A1 pump switch.
homeassistant/components/midea/strings.json Adds the pump name.
homeassistant/components/midea/icons.json Adds the pump icon.
tests/components/midea/test_switch.py Tests pump state and services.
tests/components/midea/snapshots/test_switch.ambr Captures pump entity state.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread homeassistant/components/midea/switch.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The switch is exposed on all A1 devices even when they lack the pump capability.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

MideaSwitchEntityDescription(
key="pump",
translation_key="pump",
models=[DeviceType.A1],
@mattrossman

Copy link
Copy Markdown
Author

Hmm sounds like this might be benefit from a companion PR in the midea-local library to expose pump support detection. Will look into that.

@rokam

rokam commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Hmm sounds like this might be benefit from a companion PR in the midea-local library to expose pump support detection. Will look into that.

You can get some inspiration from this PR: midea-lan/midea-local#746

@mattrossman

Copy link
Copy Markdown
Author

Appreciate the reference @rokam, I've opened an upstream PR midea-lan/midea-local#754

rokam pushed a commit to midea-lan/midea-local that referenced this pull request Sep 4, 2026
## Summary

Expose A1 device capabilities through a public capability map.

The A1 protocol already provides a `pump_enable` capability bit
separately from the current `pump` state. This change exposes that
existing signal through `device.capabilities["pump"]`, following the
capability-reporting pattern used by other device implementations.

This supports [Home Assistant core PR
#181257](home-assistant/core#181257), which
needs to create the A1 pump switch only for devices that report pump
support.

## Testing

Added focused A1 device coverage verifying that the capability map
reflects both supported and unsupported pump capability states reported
by the device.

## Notes

Reference implementation: [midea-local PR
#746](#746)
Copilot AI review requested due to automatic review settings September 5, 2026 13:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The dependency upgrade introduces unhandled cloud exceptions, and the A1 snapshot case currently creates no pump entity.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread homeassistant/components/midea/manifest.json Outdated
Comment thread tests/components/midea/test_switch.py Outdated
@rokam

rokam commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

The version bump should be made in a different PR

@mattrossman

mattrossman commented Sep 7, 2026

Copy link
Copy Markdown
Author

Looks like the version bump will be handled by #181405, once that's merged I'll update this PR to focus back on the pump capability side.

@mattrossman
mattrossman force-pushed the feature/midea-a1-water-pump-dev branch from 860afcc to 8307656 Compare September 8, 2026 21:45
Copilot AI review requested due to automatic review settings September 8, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The feature is narrowly scoped, capability-gated, and includes targeted tests plus updated snapshots for the new switch behavior.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread homeassistant/components/midea/switch.py
Copilot AI review requested due to automatic review settings September 8, 2026 22:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The capability-gated implementation is consistent with the dependency API and has focused coverage for supported and unsupported devices.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings September 8, 2026 22:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The capability-gated pump switch is implemented consistently with existing switch patterns and is covered by targeted tests and updated snapshots.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants