Add Xiaomi Pet Fountain 2 support to xiaomi_miio#166815
Conversation
There was a problem hiding this comment.
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!
|
Hey there @rytilahti, @syssi, @starkillerOG, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
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
XiaomiPetFountainMIOT 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. |
|
Companion docs PR is open: home-assistant/home-assistant.io#44381 That should cover the |
|
Update from my side:
At this point, the remaining red checks on this PR appear to be process-only:
If this change should be categorized as a |
joostlek
left a comment
There was a problem hiding this comment.
So shouldn't pet_fountain_miot be merged to the library used by the integration instead like other devices?
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Thanks, I agree with that direction. I have extracted the pet fountain implementation into a separate I also fixed the remaining concrete Core-side select initialization issue in the meantime ( I’ll keep this PR in draft and rework it to consume the library implementation instead of carrying |
|
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. |
| class XiaomiGenericCoordinatedButton( | ||
| XiaomiCoordinatedMiioEntity[DataUpdateCoordinator[Any]], ButtonEntity | ||
| ): | ||
| """A button implementation for Xiaomi.""" | ||
|
|
||
| entity_description: XiaomiMiioButtonDescription | ||
|
|
||
| _attr_device_class = ButtonDeviceClass.RESTART | ||
|
|
||
| def __init__( |
There was a problem hiding this comment.
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.
|
I will try to reach out to the maintainers |
Summary
This PR adds dedicated
xiaomi_miiosupport 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
xiaomi.pet_waterer.70m2to the supportedxiaomi_miiodevice modelssensorbinary_sensorselectnumberswitchtimebuttonstrings.jsonXiaomi Smart Pet Fountain 2Entity model
The pet fountain is modeled with:
StatusWater shortagePump blockedWater modeWater intervalDo not disturbDo not disturb startDo not disturb endChild lockReset filterFilter life remainingFilter time remainingBattery levelLow batteryCharging stateUSB powerThe generic
FaultandFault codeentities are included but disabled by default to keep the default device page focused on the more useful fountain-specific state.Why
xiaomi_miiocurrently 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:
python-miioreleaseValidation
python3 -m py_compileon the modified integration and test filespython3 -m json.toolonstrings.jsonxiaomi.pet_waterer.70m2device on a Home Assistant instanceI 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.