Skip to content

Add Xiaomi Pet Fountain 2 support to xiaomi_miio - #166815

Closed
JanOstrowka wants to merge 7 commits into
home-assistant:devfrom
JanOstrowka:codex/pet-fountain-core-pr
Closed

JanOstrowka wants to merge 7 commits into
home-assistant:devfrom
JanOstrowka:codex/pet-fountain-core-pr

Conversation

@JanOstrowka

@JanOstrowka JanOstrowka commented Mar 29, 2026

Copy link
Copy Markdown

Summary

This PR adds dedicated xiaomi_miio support for the Xiaomi Smart Pet Fountain 2 (xiaomi.pet_waterer.70m2).

The implementation uses a focused local helper for this model instead of a broader MIOT refactor so the integration can expose a polished Home Assistant entity model without waiting on a separate library migration.

Companion docs PR is open and green on lint checks: home-assistant/home-assistant.io#44381

What changed

  • add xiaomi.pet_waterer.70m2 to the supported xiaomi_miio device models
  • add a dedicated pet fountain helper with MIOT property and action mappings
  • add pet fountain entities across:
    • sensor
    • binary_sensor
    • select
    • number
    • switch
    • time
    • button
  • expose user-facing names and enum states through strings.json
  • set a default config entry title of Xiaomi Smart Pet Fountain 2
  • add focused tests for:
    • manual config-flow setup
    • entity creation
    • disabled-by-default fault entities
    • main controls and actions

Entity model

The pet fountain is modeled with:

  • Status
  • Water shortage
  • Pump blocked
  • Water mode
  • Water interval
  • Do not disturb
  • Do not disturb start
  • Do not disturb end
  • Child lock
  • Reset filter
  • Filter life remaining
  • Filter time remaining
  • Battery level
  • Low battery
  • Charging state
  • USB power

The generic Fault and Fault code entities are included but disabled by default to keep the default device page focused on the more useful fountain-specific state.

Why

xiaomi_miio currently does not support this model in the official integration, even though the device exposes a practical set of MIOT properties and actions that map well to Home Assistant entities.

This patch keeps the scope reviewable:

  • no generic MIOT refactor
  • no dependency bump for a new python-miio release
  • a dedicated path for one well-tested device family

Validation

  • python3 -m py_compile on the modified integration and test files
  • python3 -m json.tool on strings.json
  • the equivalent custom-component implementation was tested against a real xiaomi.pet_waterer.70m2 device on a Home Assistant instance

I was not able to run the full Home Assistant pytest suite in this environment because the local checkout does not have the full dev dependencies installed.

Copilot AI review requested due to automatic review settings March 29, 2026 19:26

@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 @JanOstrowka

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

Copy link
Copy Markdown
Contributor

Hey there @rytilahti, @syssi, @starkillerOG, mind taking a look at this pull request as it has been labeled with an integration (xiaomi_miio) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of xiaomi_miio can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign xiaomi_miio Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @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.

Pull request overview

Adds first-class xiaomi_miio support for the Xiaomi Smart Pet Fountain 2 (xiaomi.pet_waterer.70m2) by introducing a dedicated MIOT-backed device helper, exposing a full entity set (sensors/controls), and extending config flow defaults and test coverage.

Changes:

  • Add a dedicated XiaomiPetFountain MIOT helper and register the new model across platforms (sensor/binary_sensor/select/number/switch/time/button).
  • Improve config flow default naming for this model and extend translations for new entities/states.
  • Add focused tests covering manual config flow, entity creation, disabled-by-default fault entities, and main controls/actions.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
homeassistant/components/xiaomi_miio/__init__.py Routes the new model to its platform set and instantiates the new MIOT device class.
homeassistant/components/xiaomi_miio/const.py Adds the pet fountain model constant and includes it in supported model lists.
homeassistant/components/xiaomi_miio/pet_fountain_miot.py Introduces a local MIOT device + status wrapper with property/action mappings for the fountain.
homeassistant/components/xiaomi_miio/sensor.py Adds pet fountain diagnostic/status sensors (incl. disabled-by-default fault code).
homeassistant/components/xiaomi_miio/binary_sensor.py Adds pet fountain binary sensors (incl. disabled-by-default fault).
homeassistant/components/xiaomi_miio/select.py Adds a select entity for water mode using PetFountainMode.
homeassistant/components/xiaomi_miio/number.py Adds a number entity for water interval with min/max/step.
homeassistant/components/xiaomi_miio/switch.py Adds do-not-disturb and reuses child-lock via coordinated switch entities.
homeassistant/components/xiaomi_miio/time.py Adds time entities for DND start/end for the pet fountain model.
homeassistant/components/xiaomi_miio/button.py Adds a reset-filter button mapping for the pet fountain model.
homeassistant/components/xiaomi_miio/config_flow.py Sets a friendlier default entry title for the pet fountain model.
homeassistant/components/xiaomi_miio/strings.json Adds translations for new pet fountain entities and enum states.
tests/components/xiaomi_miio/test_config_flow.py Adds config flow test asserting the new default entry title/data for manual setup.
tests/components/xiaomi_miio/test_pet_fountain.py Adds integration tests for entity creation, disabled entities, and main controls/actions.

Comment thread homeassistant/components/xiaomi_miio/pet_fountain_miot.py Outdated
Comment thread homeassistant/components/xiaomi_miio/switch.py
Comment thread homeassistant/components/xiaomi_miio/pet_fountain_miot.py Outdated
Comment thread homeassistant/components/xiaomi_miio/pet_fountain_miot.py Outdated
Comment thread homeassistant/components/xiaomi_miio/pet_fountain_miot.py Outdated
Comment thread homeassistant/components/xiaomi_miio/pet_fountain_miot.py Outdated
Comment thread homeassistant/components/xiaomi_miio/pet_fountain_miot.py Outdated
Comment thread homeassistant/components/xiaomi_miio/pet_fountain_miot.py Outdated
Copilot AI review requested due to automatic review settings March 29, 2026 20:05

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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/xiaomi_miio/pet_fountain_miot.py Outdated
Copilot AI review requested due to automatic review settings March 29, 2026 20: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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment thread tests/components/xiaomi_miio/test_pet_fountain.py Outdated
Comment thread tests/components/xiaomi_miio/test_pet_fountain.py
Comment thread tests/components/xiaomi_miio/test_pet_fountain.py

Copy link
Copy Markdown
Author

Update from my side:

At this point, the remaining red checks on this PR appear to be process-only:

  • docs-missing
  • required-labels

If this change should be categorized as a new-feature, could a maintainer please add the required label?

@JanOstrowka
JanOstrowka marked this pull request as ready for review March 29, 2026 21:21
Copilot AI review requested due to automatic review settings March 29, 2026 21:21

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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/xiaomi_miio/select.py

@joostlek joostlek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So shouldn't pet_fountain_miot be merged to the library used by the integration instead like other devices?

@home-assistant
home-assistant Bot marked this pull request as draft March 30, 2026 14:35
@home-assistant

Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Copy link
Copy Markdown
Author

Thanks, I agree with that direction.

I have extracted the pet fountain implementation into a separate python-miio PR first:

I also fixed the remaining concrete Core-side select initialization issue in the meantime (mode=None on the first refresh).

I’ll keep this PR in draft and rework it to consume the library implementation instead of carrying pet_fountain_miot.py locally.

@JanOstrowka

JanOstrowka commented Mar 30, 2026

Copy link
Copy Markdown
Author

Thanks @joostlek, I agree that the library-first shape is cleaner, and I have already reworked this locally to consume python-miio instead of carrying pet_fountain_miot.py in Core. I also tested that library-based version successfully in Home Assistant.

The concern I have is timing rather than implementation. The python-miio repository is not abandoned, but it appears to move slowly: the last merged change I could find was on August 19, 2025 (#2037), and the last stable release still appears to be 0.5.12 from July 18, 2022. There are also a number of open PRs there, including my pet fountain support PR and a separate RTD cleanup PR.

So while I understand the preferred architecture, I do not currently have a clear expectation for when a reviewed and released library version would actually be available for Core to depend on.

Would you consider a narrow exception here and allow the minimal pet fountain helper to remain in Core for now, so the device can be supported without waiting indefinitely on an external library release? If python-miio support is reviewed and released later, I would be happy to follow up and switch this PR over to the shared library implementation.

@JanOstrowka
JanOstrowka marked this pull request as ready for review March 30, 2026 19:29
Copilot AI review requested due to automatic review settings March 30, 2026 19:29
@home-assistant
home-assistant Bot requested a review from joostlek March 30, 2026 19:29

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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

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.

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment on lines 165 to 172
class XiaomiGenericCoordinatedButton(
XiaomiCoordinatedMiioEntity[DataUpdateCoordinator[Any]], ButtonEntity
):
"""A button implementation for Xiaomi."""

entity_description: XiaomiMiioButtonDescription

_attr_device_class = ButtonDeviceClass.RESTART

def __init__(

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

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

The removal of _attr_device_class = ButtonDeviceClass.RESTART appears unintended and unrelated to the pet fountain changes. This removal should be reverted to maintain the device class designation for buttons, which affects how they're displayed and handled in the UI.

Copilot uses AI. Check for mistakes.
@joostlek

joostlek commented Apr 1, 2026

Copy link
Copy Markdown
Member

I will try to reach out to the maintainers

@issue-triage-workflows

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants