Skip to content

Improve code and bug fix#230

Merged
Jezza34000 merged 7 commits intoJezza34000:mainfrom
astrinh0:jveloso-improvepetkit
May 6, 2026
Merged

Improve code and bug fix#230
Jezza34000 merged 7 commits intoJezza34000:mainfrom
astrinh0:jveloso-improvepetkit

Conversation

@astrinh0
Copy link
Copy Markdown
Contributor

@astrinh0 astrinh0 commented May 5, 2026

📝 Proposed Change / Description

This PR fixes several stability and correctness issues in the Petkit Home Assistant integration.

It improves coordinator setup, config migration for older entries, stale-device cleanup, entity availability handling, and feeder/manual-feed controls. It also fixes a few unit and fallback-value issues that could make entities display incorrectly or behave unexpectedly.

Fixes: #---


🔖 Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🔧 Refactor / code cleanup (no functional change)
  • 📚 Documentation update
  • 🔒 Security fix
  • ⬆️ Dependency update

🐾 Affected devices

  • 🌐 All devices

Specific type:

  • Litter boxes : ()
  • Feeders : (single-hopper manual feed handling, including PETKIT FRESH ELEMENT SOLO)
  • Fountains : (coordinator/BLE setup robustness, including PETKIT EVERSWEET)
  • Purifiers : (fan preset fallback fix)

Specific category :

  • Cameras devices : ()
  • Non camera devices : (feeders, fountains, purifiers)
  • BLE only devices : (fountains using Bluetooth relay)

If your device is not listed, please specify it here:

PETKIT EVERSWEET, PETKIT FRESH ELEMENT SOLO


🧪 How has this been tested?

  • Tested locally with a real PetKit device
  • Tested with Home Assistant version:
  • No testing required (docs, CI config, etc.)

Device(s) tested on:

Not tested on a live Home Assistant instance in this environment.

Other devices you own when the test was done:

PETKIT EVERSWEET, PETKIT FRESH ELEMENT SOLO

Validation performed:

  • git diff --check
  • Parsed all translation JSON files successfully
  • Parsed manifest.json successfully

Full Python compile/lint was not run locally because only Python 3.9 is available in this environment, while the integration uses newer Python syntax.


✅ Checklist

  • Code follows project style : pre-commit run -a hooks and all checks pass
  • No new linting/type errors introduced
  • Documentation updated (if needed)
  • Branch is up-to-date with main

📸 Screenshots / Logs (optional)

N/A


ℹ️ Additional context

Main fixes included:

  • Store the correct media and Bluetooth coordinators in hass.data
  • Add safe defaults for older config entries missing media/Bluetooth option sections
  • Store config-flow region as a country code
  • Use valid translated config-flow error keys
  • Track stale devices by serial-number identifiers
  • Harden entity availability checks when coordinator data is temporarily missing
  • Fix single-hopper feeder manual-feed validation up to 400g
  • Add grams unit to manual-feed number entity
  • Fix T7 cleaning delay display from seconds-as-minutes to 20-60 min
  • Return None for unknown purifier fan preset mode instead of integer 0

⚠️ Breaking Changes

  • No breaking changes.
  • Warning: This PR introduces breaking changes.

Description of changes:

None.


Thanks for the helping paw! 🐾

@astrinh0 astrinh0 requested a review from Jezza34000 as a code owner May 5, 2026 22:17
@Jezza34000
Copy link
Copy Markdown
Owner

Hi @astrinh0, thank you so much for all these corrections and improvements. I'm testing it in my test environment and will get back to you when it's finished.

The only thing that might conflict with the upcoming PR (#227) is the part concerning : "Store config-flow region as a country code"
I'll check that in detail...

@astrinh0
Copy link
Copy Markdown
Contributor Author

astrinh0 commented May 6, 2026

Hi @Jezza34000 no problem, do all the test since I don't test it 😊
If you need something tell me!

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@Jezza34000
Copy link
Copy Markdown
Owner

I've made some modification @astrinh0 it's Ok to merge

@Jezza34000 Jezza34000 merged commit e45e88c into Jezza34000:main May 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants