Skip to content

Add CatGenie integration#169533

Draft
kclif9 wants to merge 11 commits intohome-assistant:devfrom
kclif9:Add-CatGenie-AI-Integration
Draft

Add CatGenie integration#169533
kclif9 wants to merge 11 commits intohome-assistant:devfrom
kclif9:Add-CatGenie-AI-Integration

Conversation

@kclif9
Copy link
Copy Markdown
Contributor

@kclif9 kclif9 commented Apr 30, 2026

Proposed change

Add the CatGenie integration to home assistant. The first platform to be added is the sensor platform as this allows users to run a fan when the CatGenie device is running.

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:

Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new CatGenie integration to Home Assistant core, including config flow, runtime setup, and an initial sensor platform intended to expose device state for automations.

Changes:

  • Introduces homeassistant.components.catgenie with config flow, coordinator/entity base, and sensor entities.
  • Adds a new test suite under tests/components/catgenie/ covering config flow, setup/unload, sensors, and diagnostics.
  • Registers the integration in generated/metadata files and pins the catgenie dependency.

Reviewed changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
homeassistant/components/catgenie/__init__.py Sets up auth/client, creates per-device coordinators, forwards platforms, and unloads platforms.
homeassistant/components/catgenie/config_flow.py Implements SMS-based login + reauth config flow.
homeassistant/components/catgenie/coordinator.py Per-device DataUpdateCoordinator fetching device state and handling token refresh.
homeassistant/components/catgenie/entity.py Base coordinator entity + DeviceInfo wiring.
homeassistant/components/catgenie/sensor.py Defines sensor entity descriptions and entity implementation.
homeassistant/components/catgenie/strings.json Adds config flow text, sensor names/states, and exception translations.
homeassistant/components/catgenie/manifest.json Declares integration metadata and dependency pin.
homeassistant/components/catgenie/quality_scale.yaml Declares quality scale rule statuses for the new integration.
homeassistant/components/catgenie/const.py Adds DOMAIN and logger constant.
tests/components/catgenie/conftest.py Provides fixtures/mocks for auth/client and sample device data.
tests/components/catgenie/test_config_flow.py Tests user + reauth flows and error handling.
tests/components/catgenie/test_init.py Tests setup/unload and coordinator refresh error scenarios.
tests/components/catgenie/test_sensor.py Tests expected sensor entities and states.
tests/components/catgenie/test_diagnostics.py Tests config entry diagnostics output contract.
tests/components/catgenie/__init__.py Marks test package for the integration.
requirements_all.txt Adds catgenie==0.1.3 to runtime requirements list.
requirements_test_all.txt Adds catgenie==0.1.3 to test requirements list.
mypy.ini Enables strict-ish mypy settings for homeassistant.components.catgenie.*.
.strict-typing Registers the integration as strict-typing.
homeassistant/generated/integrations.json Registers the integration metadata (generated).
homeassistant/generated/config_flows.py Registers integration as having a config flow (generated).
CODEOWNERS Assigns code ownership for the new integration and tests.

Comment thread homeassistant/components/catgenie/entity.py Outdated
Comment thread tests/components/catgenie/test_sensor.py Outdated
Comment thread tests/components/catgenie/test_diagnostics.py Outdated
Comment thread homeassistant/components/catgenie/sensor.py
Comment thread homeassistant/components/catgenie/__init__.py Outdated
Comment thread homeassistant/components/catgenie/__init__.py Outdated
Comment thread homeassistant/components/catgenie/__init__.py Outdated
Comment thread homeassistant/components/catgenie/coordinator.py Outdated
Comment thread homeassistant/components/catgenie/coordinator.py
Comment thread homeassistant/components/catgenie/__init__.py
…device management and update entity handling

Co-authored-by: Copilot <copilot@github.com>
… CatGenieException

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 11:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 19 out of 21 changed files in this pull request and generated 5 comments.

Comment thread homeassistant/components/catgenie/coordinator.py Outdated
Comment thread homeassistant/components/catgenie/__init__.py Outdated
CatGenieSensorDescription(
key="sani_solution",
translation_key="sani_solution",
state_class=SensorStateClass.TOTAL,
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

Use SensorStateClass.MEASUREMENT with a percentage unit (and avoid TOTAL) for a “remaining” value, since TOTAL implies a monotonically increasing counter and will produce incorrect long-term statistics.

Suggested change
state_class=SensorStateClass.TOTAL,
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is not a percentage but an int decreasing as the remaining sanitiser solution is used. I.e. each cartridge has either 120 or 240 uses depending on the users' settings (automatic mode extends the life of the cartridge).

Percentage and measurement would be misleading. TOTAL appears to be the correct unit.

Comment thread tests/components/catgenie/test_init.py Outdated
Comment thread homeassistant/components/catgenie/coordinator.py Outdated
kclif9 and others added 2 commits April 30, 2026 11:54
Copilot AI review requested due to automatic review settings April 30, 2026 12:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 19 out of 21 changed files in this pull request and generated 2 comments.

Comment thread homeassistant/components/catgenie/config_flow.py Outdated
Comment thread homeassistant/components/catgenie/entity.py Outdated
kclif9 and others added 2 commits April 30, 2026 22:44
…ce data access

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 23:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 19 out of 21 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/catgenie/coordinator.py
@kclif9 kclif9 marked this pull request as ready for review May 1, 2026 02:45
Copilot AI review requested due to automatic review settings May 1, 2026 02:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 19 out of 21 changed files in this pull request and generated 1 comment.

Comment on lines +63 to +69
entry.runtime_data = CatGenieRuntimeData(
stack=stack,
coordinator=coordinator,
)

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

Ensure AsyncExitStack is closed if forwarding platform setups fails (e.g., async_forward_entry_setups raises), to avoid leaking open client/auth contexts; wrap the forward call in try/except (or set runtime_data only after successful forwarding) and close the stack on failure.

Suggested change
entry.runtime_data = CatGenieRuntimeData(
stack=stack,
coordinator=coordinator,
)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
try:
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
except Exception:
await stack.aclose()
raise
entry.runtime_data = CatGenieRuntimeData(
stack=stack,
coordinator=coordinator,
)

Copilot uses AI. Check for mistakes.
…ity functions

Co-authored-by: Copilot <copilot@github.com>
Comment thread homeassistant/components/catgenie/__init__.py Outdated
Comment thread homeassistant/components/catgenie/config_flow.py Outdated

import logging

DOMAIN = "catgenie"
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.

how do they advertise it? cat_genie? catgenie? No preference, just want to throw it on the table

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They advertise as "CatGenie" with the G uppercase and no space.

Comment thread homeassistant/components/catgenie/entity.py Outdated
Comment thread homeassistant/components/catgenie/sensor.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft May 4, 2026 20:34
@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented May 4, 2026

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.

Comment thread homeassistant/components/catgenie/strings.json
Comment thread tests/components/catgenie/conftest.py Outdated
Comment thread tests/components/catgenie/conftest.py Outdated
Comment thread tests/components/catgenie/test_init.py Outdated
Comment thread tests/components/catgenie/test_init.py Outdated
Comment thread tests/components/catgenie/test_sensor.py Outdated
Copilot AI review requested due to automatic review settings May 6, 2026 07:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 20 out of 22 changed files in this pull request and generated 8 comments.

Comment thread homeassistant/components/catgenie/config_flow.py
Comment thread homeassistant/components/catgenie/config_flow.py
Comment thread homeassistant/components/catgenie/strings.json
Comment thread homeassistant/components/catgenie/__init__.py
Comment on lines +137 to +140
state = hass.states.get("sensor.catgenie_litter_box_status")
assert state is not None
assert state.state == "cleaning"

Comment on lines +195 to +197
state = hass.states.get("sensor.catgenie_litter_box_status")
assert state is not None
assert state.state == "unavailable"
Comment on lines +249 to +252
state = hass.states.get("sensor.catgenie_litter_box_status")
assert state is not None
assert state.state == "unavailable"

Comment on lines +277 to +279
state = hass.states.get("sensor.catgenie_litter_box_status")
assert state is not None
assert state.state == "unavailable"
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.

3 participants