Skip to content

Conversation

@moehrem
Copy link
Owner

@moehrem moehrem commented Nov 3, 2025

Changes to be committed:
modified: custom_components/diveracontrol/init.py

Changes to be committed:
	modified:   custom_components/diveracontrol/__init__.py
Copilot AI review requested due to automatic review settings November 3, 2025 12:14
Copy link

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 config entry migration logic to use a stored integration version string rather than checking version constants, and consolidates the base API URL to use a constant instead of a hardcoded string.

  • Replaced version constant checks with integrated_version string comparisons
  • Added BASE_API_URL constant import and usage
  • Updated migration comments for clarity
Comments suppressed due to low confidence (1)

custom_components/diveracontrol/init.py:214

  • The migration logic updates D_BASE_API_URL but doesn't update D_INTEGRATION_VERSION to reflect the new version. After this migration runs, integrated_version will still be '1.2.0', which could cause the migration to run again on the next restart. Add D_INTEGRATION_VERSION to the data dictionary with value f'{VERSION}.{MINOR_VERSION}.{PATCH_VERSION}' similar to the v1.2.0 migration block.
    if integrated_version == "1.2.0":
        _LOGGER.info(
            "Migrating config entry to version %s.%s.%s",
            VERSION,
            MINOR_VERSION,
            PATCH_VERSION,
        )

        if D_BASE_API_URL not in config_entry.data:
            _LOGGER.info("Adding base_url to existing config entry")

            hass.config_entries.async_update_entry(
                config_entry,
                data={
                    **config_entry.data,
                    D_BASE_API_URL: BASE_API_URL,
                },
                version=VERSION,
                minor_version=MINOR_VERSION,
            )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

data={
**config_entry.data,
D_BASE_API_URL: "https://api.divera247.com",
D_BASE_API_URL: BASE_API_URL,
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The BASE_API_URL constant ('https://app.divera247.com/') differs from the hardcoded value it replaces ('https://api.divera247.com'). The subdomain changed from 'api' to 'app' and a trailing slash was added. This will cause existing users migrating to v1.2.1 to have a different base URL than intended, potentially breaking API functionality. Use the original URL 'https://api.divera247.com' or verify that 'app.divera247.com' is the correct migration target.

Suggested change
D_BASE_API_URL: BASE_API_URL,
D_BASE_API_URL: "https://api.divera247.com",

Copilot uses AI. Check for mistakes.
@moehrem moehrem merged commit cfe0fb5 into main Nov 3, 2025
13 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