Skip to content

Refactor indevolt integration to remove magic number constants#169337

Merged
elupus merged 6 commits into
home-assistant:devfrom
Xirt:refactor-indevolt-integration
Apr 28, 2026
Merged

Refactor indevolt integration to remove magic number constants#169337
elupus merged 6 commits into
home-assistant:devfrom
Xirt:refactor-indevolt-integration

Conversation

@Xirt
Copy link
Copy Markdown
Contributor

@Xirt Xirt commented Apr 27, 2026

Proposed change

Refactored code base to remove magic number constants from the core integration: they will now come from the updated external library.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

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:

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

This PR refactors the Indevolt integration to replace hard-coded numeric read/write keys with constants provided by the updated indevolt-api library.

Changes:

  • Bump indevolt-api dependency to 1.6.3 and update integration imports accordingly.
  • Replace magic key strings across platforms (sensor/select/number/switch/coordinator/diagnostics) with indevolt_api constants.
  • Update Indevolt tests to use the same upstream constants and enums.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/components/indevolt/test_switch.py Switch tests updated to use IndevoltConfig constants for read/write keys.
tests/components/indevolt/test_services.py Service tests updated to use IndevoltConfig + IndevoltEnergyMode instead of integration constants.
tests/components/indevolt/test_select.py Select tests updated to use upstream energy mode enum/constants.
tests/components/indevolt/test_number.py Number tests updated to use IndevoltConfig constants for read/write keys.
tests/components/indevolt/test_button.py Button tests updated to use upstream constants/enums for energy-mode interactions.
requirements_test_all.txt Pin indevolt-api==1.6.3 for test environment.
requirements_all.txt Pin indevolt-api==1.6.3 for runtime environment.
homeassistant/components/indevolt/switch.py Switch entity descriptions refactored to use upstream read/write key constants.
homeassistant/components/indevolt/sensor.py Sensor keys and battery-pack key groupings refactored to upstream constants.
homeassistant/components/indevolt/select.py Select mapping refactored to use IndevoltEnergyMode + upstream config keys.
homeassistant/components/indevolt/number.py Number entity descriptions refactored to use upstream read/write key constants.
homeassistant/components/indevolt/manifest.json Integration requirement bumped to indevolt-api==1.6.3.
homeassistant/components/indevolt/diagnostics.py Diagnostics redaction keys refactored to upstream constants.
homeassistant/components/indevolt/coordinator.py Energy-mode switching refactored to use upstream keys/enums; discharge-limit access updated.
homeassistant/components/indevolt/const.py Polling key lists refactored to upstream constants.

Comment thread homeassistant/components/indevolt/const.py Outdated
Comment thread homeassistant/components/indevolt/const.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 27, 2026 21:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.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

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

@Xirt Xirt marked this pull request as ready for review April 27, 2026 22:39
Copilot AI review requested due to automatic review settings April 27, 2026 22: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 12 out of 12 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Contributor

@elupus elupus left a comment

Choose a reason for hiding this comment

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

Nice!

@elupus elupus merged commit 308cb68 into home-assistant:dev Apr 28, 2026
36 of 37 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 29, 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.

3 participants