Skip to content

devices: support Home Assistant 2026.8 ownership model - #168

Open
cabberley wants to merge 1 commit into
mainfrom
feature/home-assistant-2026.8-device-management
Open

devices: support Home Assistant 2026.8 ownership model#168
cabberley wants to merge 1 commit into
mainfrom
feature/home-assistant-2026.8-device-management

Conversation

@cabberley

@cabberley cabberley commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace deprecated implicit DeviceInfo linking with direct entity-to-source-device links
  • migrate legacy helper-owned and duplicated devices to Home Assistant's single-config-entry ownership model
  • preserve source rename, move, removal, and options-change behavior
  • raise the minimum supported Home Assistant version to 2026.8.0
  • expand device lifecycle and migration coverage and add tests/formatting to CI
  • refresh compatibility and contributor documentation

Why

Home Assistant 2026.8 changes devices to have a single config-entry owner. The previous helper APIs are deprecated and no longer provide the ownership/linking behavior this integration relied on.

Validation

  • 93 tests passed against the exact Home Assistant 2026.8.0 source tag
  • 7 focused device-management tests passed
  • Ruff lint and formatting checks passed
  • Python compilation, JSON/YAML parsing, and Git whitespace checks passed

Reviewer notes

The original request referenced Home Assistant 2028.8.0, but that release/tag does not exist. This PR targets the released 2026.8.0 version containing the relevant device-management changes.

Summary by Sourcery

Adopt Home Assistant 2026.8’s single-owner device model by linking helper entities directly to their source devices, updating migrations, and tightening config/flow handling.

New Features:

  • Add comprehensive device-management tests to validate helper entity linking, relinking, and detachment behavior across config and migration scenarios.
  • Introduce project-level pytest configuration and shared fixtures for running Home Assistant custom component tests.

Bug Fixes:

  • Ensure helper entities no longer take ownership of source devices, instead attaching to existing devices while preserving the source integration as sole owner.
  • Fix calibration and migration logic so legacy entries correctly initialize and preserve both meter and calculation calibration defaults without data loss.
  • Prevent duplicate config-entry reloads when source entities are renamed by tightening source change handling.

Enhancements:

  • Refine config flow schemas and options handling, including minor versioning, to better support multi-step and multi-meter configurations.
  • Rework config entry migration to a versioned, idempotent pipeline that also cleans up legacy helper-owned devices and relinks entities to their source devices.
  • Align select and sensor entities with the new device model by replacing DeviceInfo-based linking with direct device references from source entities.
  • Update diagnostics, selectors, and various helpers to use pytest-homeassistant-custom-component utilities and Home Assistant’s current helper APIs.
  • Apply Ruff-based formatting and style cleanups across schemas, config flow, sensors, constants, and tests for consistency.

Build:

  • Raise the minimum supported Home Assistant version to 2026.8.0 and bump the integration manifest version to 2026.8.0.
  • Extend CI to run Ruff formatting checks and execute the pytest suite with pytest-homeassistant-custom-component and cronsim installed.

Documentation:

  • Document the new Home Assistant compatibility requirements, device linking behavior, and contributor workflow using Ruff and pytest in README and CONTRIBUTING.

Adopt single-config-entry device ownership, migrate legacy helper devices, and link helper entities directly to source devices. Expand lifecycle and migration coverage, refresh documentation, and add test and formatting checks to CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sourcery-ai

sourcery-ai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates the Utility Meter Next Gen custom integration to comply with Home Assistant 2026.8’s single-owner device model by replacing implicit helper-based device links with direct entity-to-device associations, refactoring config-entry migration and config flow versions, tightening typing and formatting, and adding CI-backed tests using pytest-homeassistant-custom-component.

Sequence diagram for config entry migration to single-owner device model

sequenceDiagram
    participant HA as HomeAssistant
    participant CE as ConfigEntries
    participant UM as async_migrate_entry
    participant DR as async_entity_id_to_device_id
    participant HD as async_remove_helper_devices

    HA->>CE: trigger migration for config_entry
    CE->>UM: async_migrate_entry(config_entry)
    UM->>UM: normalize options and version
    alt minor_version < 2
        UM->>DR: async_entity_id_to_device_id(hass, options[CONF_SOURCE_SENSOR])
        DR-->>UM: source_device_id
        UM->>HD: async_remove_helper_devices(hass, helper_config_entry_id, source_device_id, remove_all_devices=True)
        HD-->>UM: helper devices removed
    end
    UM->>CE: async_update_entry(config_entry, options, version=8, minor_version=2)
    CE-->>HA: migration complete
Loading

File-Level Changes

Change Details Files
Reformat configuration schemas and refactor config flow for improved structure, typing, and versioning.
  • Apply Ruff-style formatting and clearer defaults in schemas, consolidating common option-building helpers.
  • Introduce MINOR_VERSION and use more precise type hints and comments in the config flow.
  • Normalize data initialization and entry creation across cron, predefined, and multi-step flows.
custom_components/utility_meter_next_gen/schemas.py
custom_components/utility_meter_next_gen/config_flow.py
Align device ownership and entity-device linking with Home Assistant’s 2026.8 device model.
  • Remove legacy async_remove_stale_devices_links_keep_entity_device usage and rely on async_handle_source_entity_changes and async_remove_helper_devices.
  • Stop registering the helper config entry as an owner of the source device; instead link helper entities directly to the source device using async_entity_id_to_device.
  • Update select and sensor entities to store DeviceEntry references instead of DeviceInfo-based device_info and adjust tariff/select behavior accordingly.
custom_components/utility_meter_next_gen/__init__.py
custom_components/utility_meter_next_gen/sensor.py
custom_components/utility_meter_next_gen/select.py
Refactor config entry migration logic to be version/minor-version aware and perform device cleanup for legacy entries.
  • Replace chained version-specific migration blocks with a sequential version variable and options dict, ensuring both calibration defaults are set correctly.
  • Add minor-version based migration that removes helper-owned legacy devices via async_remove_helper_devices and relinks entities to the source device.
  • Increase integration VERSION and MINOR_VERSION values and ensure migrations log and abort on unsupported versions.
custom_components/utility_meter_next_gen/__init__.py
custom_components/utility_meter_next_gen/config_flow.py
tests/components/utility_meter_evolved/test_device_management.py
Update tests to use pytest-homeassistant-custom-component and extend coverage for device management behavior.
  • Switch test utilities and diagnostics imports from tests.common to pytest_homeassistant_custom_component equivalents.
  • Add a dedicated test_device_management suite that covers linking, relinking, detaching, and migrating helper entities and devices.
  • Adjust existing tests to assert the new non-owning helper behavior and entity-device relationships.
tests/components/utility_meter_evolved/test_init.py
tests/components/utility_meter_evolved/test_config_flow.py
tests/components/utility_meter_evolved/test_diagnostics.py
tests/components/utility_meter_evolved/test_select.py
tests/components/utility_meter_evolved/test_sensor.py
tests/components/utility_meter_evolved/test_device_management.py
tests/conftest.py
tests/__init__.py
Tighten tooling, dependencies, and documentation to the new minimum Home Assistant and Ruff-based workflow.
  • Raise the minimum Home Assistant version to 2026.8.0 and bump manifest version to 2026.8.0.
  • Add a GitHub Actions test job using pytest-homeassistant-custom-component and cronsim, plus Ruff formatting checks.
  • Document new lint/format/test commands, device-management test requirements, and note compatibility with Home Assistant 2026.8’s ownership model; update Ruff config to ignore PLR0917.
  • Normalize constants and comments in const.py and clean up README/CONTRIBUTING guidance.
requirements.txt
custom_components/utility_meter_next_gen/manifest.json
.github/workflows/lint.yml
CONTRIBUTING.md
README.md
.ruff.toml
custom_components/utility_meter_next_gen/const.py
pytest.ini

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cabberley cabberley added the enhancement New feature or request label Aug 5, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 6 issues, and left some high level feedback:

  • The lint/test GitHub workflow is configured to use Python 3.14.6, which doesn’t currently exist; consider switching to a supported version (e.g., 3.12.x) that matches Home Assistant’s supported runtime so CI can actually run.
  • In async_migrate_entry, the call to async_entity_id_to_device_id(hass, options[CONF_SOURCE_SENSOR]) assumes the CONF_SOURCE_SENSOR option is always present and non-null; you may want to guard this with a get or early return to avoid migration failures on older or malformed entries.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The lint/test GitHub workflow is configured to use Python `3.14.6`, which doesn’t currently exist; consider switching to a supported version (e.g., `3.12.x`) that matches Home Assistant’s supported runtime so CI can actually run.
- In `async_migrate_entry`, the call to `async_entity_id_to_device_id(hass, options[CONF_SOURCE_SENSOR])` assumes the `CONF_SOURCE_SENSOR` option is always present and non-null; you may want to guard this with a `get` or early return to avoid migration failures on older or malformed entries.

## Individual Comments

### Comment 1
<location path="custom_components/utility_meter_next_gen/config_flow.py" line_range="287-289" />
<code_context>
     def __init__(self, config_entry: ConfigEntry) -> None:
         """Initialize the options flow handler."""
-        self.options_schema =None
+        self.options_schema = None
         self.config_type = None
-        self.data = config_entry.options.copy()  #noqa: PGH003 # type: ignore
+        self.data = config_entry.options.copy()  # noqa: PGH003 # type: ignore
         _LOGGER.debug("async Option init self.data: %s", self.data)
         if config_entry.options["config_type"] == CONF_CONFIG_CRON:
</code_context>
<issue_to_address>
**issue (bug_risk):** Store the config_entry on the OptionsFlowHandler instance to avoid AttributeError later.

`async_step_init` and `async_multi_option_step_2` access `self.config_entry.title`, but `config_entry` is only passed into `__init__` and never stored on `self`, so these calls will raise an `AttributeError`. Please store it (e.g. `self.config_entry = config_entry` in `__init__`) and use that attribute in the later methods.
</issue_to_address>

### Comment 2
<location path="custom_components/utility_meter_next_gen/sensor.py" line_range="148-149" />
<code_context>
     unique_id = config_entry.entry_id

-    device_info = async_device_info_to_link_from_entity(
+    device = async_entity_id_to_device(
         hass,
         config_entry.options[CONF_SOURCE_SENSOR],
     )
</code_context>
<issue_to_address>
**issue (bug_risk):** Using DeviceEntry directly does not attach the sensor to a device; map it to a DeviceInfo and expose it via device_info.

`async_device_info_to_link_from_entity` previously set `_attr_device_info`, which HA uses to link entities to devices. After switching to `async_entity_id_to_device`, you store the `DeviceEntry` on `self.device_entry`, but HA doesn’t use that attribute, so these sensors may no longer be linked to any device in the UI/registry.

Please either keep `_attr_device_info` populated (e.g. by building a `DeviceInfo` from the `DeviceEntry`) or expose it via a `device_info` property that constructs and returns a `DeviceInfo`. The same issue exists in `UtilityMeterSensor.__init__`, where `device_info` was replaced with `device: DeviceEntry | None` and stored only as `self.device_entry`.
</issue_to_address>

### Comment 3
<location path="custom_components/utility_meter_next_gen/select.py" line_range="34-36" />
<code_context>
     unique_id = config_entry.entry_id

-    device_info = async_device_info_to_link_from_entity(
+    device = async_entity_id_to_device(
         hass,
         config_entry.options[CONF_SOURCE_SENSOR],
     )
</code_context>
<issue_to_address>
**issue (bug_risk):** Tariff select entity is no longer linked to a device after switching to DeviceEntry.

Previously the select set `_attr_device_info` from `async_device_info_to_link_from_entity`, so HA could link it to the source device. Now it only stores a `DeviceEntry` on `self.device_entry` and never exposes a `DeviceInfo`, so the UI device association will be lost. Please mirror the sensor approach by either keeping `_attr_device_info` set or adding a `device_info` property that derives a `DeviceInfo` from the `DeviceEntry`.
</issue_to_address>

### Comment 4
<location path=".github/workflows/lint.yml" line_range="46" />
<code_context>
+      - name: Set up Python
+        uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+        with:
+          python-version: "3.14.6"
+          cache: "pip"
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Configured Python version 3.14.6 is invalid and will break CI.

`python-version: "3.14.6"` is not a valid release (current stable is 3.12), so this workflow will fail before tests run. Please pin to a supported version (e.g., 3.11 or 3.12) that aligns with Home Assistant and pytest-homeassistant-custom-component requirements.
</issue_to_address>

### Comment 5
<location path="tests/components/utility_meter_evolved/test_select.py" line_range="11-8" />
<code_context>
+from pytest_homeassistant_custom_component.common import MockConfigEntry


 async def test_select_entity_name_config_entry(
</code_context>
<issue_to_address>
**suggestion (testing):** Add a test to verify that the select entity filters out the 'total' tariff case-insensitively

The current changes rely on `TariffSelect.options` filtering out the "total" tariff via a case-insensitive regex, but there’s no test explicitly covering this (including mixed-case values like "Total"/"TOTAL").

Please add a test similar to the example below to ensure case-insensitive filtering of "total" is enforced and to guard against regressions:

```python
async def test_select_options_filters_total_case_insensitive(
    hass: HomeAssistant,
    entity_registry: er.EntityRegistry,
    device_registry: dr.DeviceRegistry,
) -> None:
    source_entry = MockConfigEntry(domain="test")
    source_entry.add_to_hass(hass)
    source_device = device_registry.async_get_or_create(
        config_entry_id=source_entry.entry_id,
        identifiers={("test", "source")},
    )
    source_entity = entity_registry.async_get_or_create(
        "sensor", "test", "source",
        config_entry=source_entry,
        device_id=source_device.id,
    )

    config_entry = MockConfigEntry(
        domain=DOMAIN,
        options={
            CONF_NAME: "Energy",
            CONF_TARIFFS: ["Peak", "Total", "OFFPEAK"],
            CONF_SOURCE_SENSOR: source_entity.entity_id,
        },
    )
    config_entry.add_to_hass(hass)

    assert await async_setup_component(hass, DOMAIN, {})
    assert await hass.config_entries.async_setup(config_entry.entry_id)
    await hass.async_block_till_done()

    state = hass.states.get("select.energy")
    assert state is not None
    assert set(state.attributes["options"]) == {"Peak", "OFFPEAK"}
```

Suggested implementation:

```python
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.setup import async_setup_component

from pytest_homeassistant_custom_component.common import MockConfigEntry


async def test_select_options_filters_total_case_insensitive(
    hass,
    entity_registry,
    device_registry,
) -> None:
    source_entry = MockConfigEntry(domain="test")
    source_entry.add_to_hass(hass)
    source_device = device_registry.async_get_or_create(
        config_entry_id=source_entry.entry_id,
        identifiers={("test", "source")},
    )
    source_entity = entity_registry.async_get_or_create(
        "sensor",
        "test",
        "source",
        config_entry=source_entry,
        device_id=source_device.id,
    )

    config_entry = MockConfigEntry(
        domain=DOMAIN,
        options={
            CONF_NAME: "Energy",
            CONF_TARIFFS: ["Peak", "Total", "OFFPEAK"],
            CONF_SOURCE_SENSOR: source_entity.entity_id,
        },
    )
    config_entry.add_to_hass(hass)

    assert await async_setup_component(hass, DOMAIN, {})
    assert await hass.config_entries.async_setup(config_entry.entry_id)
    await hass.async_block_till_done()

    state = hass.states.get("select.energy")
    assert state is not None
    assert set(state.attributes["options"]) == {"Peak", "OFFPEAK"}


async def test_select_entity_name_config_entry(

```

This new test relies on the constants `DOMAIN`, `CONF_NAME`, `CONF_TARIFFS`, and `CONF_SOURCE_SENSOR` being imported elsewhere in the file (as is typical for this test module). If they are not already imported, you should add the appropriate imports at the top of the file, e.g.:

- `from homeassistant.components.utility_meter_evolved.const import DOMAIN`
- `from homeassistant.const import CONF_NAME`
- `from custom_components.utility_meter_evolved.const import CONF_TARIFFS, CONF_SOURCE_SENSOR`

Adjust the import paths to match how they are defined in your integration.
</issue_to_address>

### Comment 6
<location path="README.md" line_range="32" />
<code_context>

+## Compatibility
+
+Release 2026.8.0 and newer require Home Assistant 2026.8.0 or later. Utility
+Meter Next Gen entities link directly to their source device while the source
+integration remains the device's sole owner, matching Home Assistant's current
</code_context>
<issue_to_address>
**issue (typo):** Fix subject–verb agreement in the compatibility sentence.

Consider either "Release 2026.8.0 and newer requires Home Assistant 2026.8.0 or later" or "Releases 2026.8.0 and newer require Home Assistant 2026.8.0 or later" to match the singular/plural subject with the verb.

```suggestion
Releases 2026.8.0 and newer require Home Assistant 2026.8.0 or later. Utility
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +287 to +289
self.options_schema = None
self.config_type = None
self.data = config_entry.options.copy() #noqa: PGH003 # type: ignore
self.data = config_entry.options.copy() # noqa: PGH003 # type: ignore

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Store the config_entry on the OptionsFlowHandler instance to avoid AttributeError later.

async_step_init and async_multi_option_step_2 access self.config_entry.title, but config_entry is only passed into __init__ and never stored on self, so these calls will raise an AttributeError. Please store it (e.g. self.config_entry = config_entry in __init__) and use that attribute in the later methods.

Comment on lines +148 to 149
device = async_entity_id_to_device(
hass,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Using DeviceEntry directly does not attach the sensor to a device; map it to a DeviceInfo and expose it via device_info.

async_device_info_to_link_from_entity previously set _attr_device_info, which HA uses to link entities to devices. After switching to async_entity_id_to_device, you store the DeviceEntry on self.device_entry, but HA doesn’t use that attribute, so these sensors may no longer be linked to any device in the UI/registry.

Please either keep _attr_device_info populated (e.g. by building a DeviceInfo from the DeviceEntry) or expose it via a device_info property that constructs and returns a DeviceInfo. The same issue exists in UtilityMeterSensor.__init__, where device_info was replaced with device: DeviceEntry | None and stored only as self.device_entry.

Comment on lines +34 to 36
device = async_entity_id_to_device(
hass,
config_entry.options[CONF_SOURCE_SENSOR],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Tariff select entity is no longer linked to a device after switching to DeviceEntry.

Previously the select set _attr_device_info from async_device_info_to_link_from_entity, so HA could link it to the source device. Now it only stores a DeviceEntry on self.device_entry and never exposes a DeviceInfo, so the UI device association will be lost. Please mirror the sensor approach by either keeping _attr_device_info set or adding a device_info property that derives a DeviceInfo from the DeviceEntry.

- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.14.6"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Configured Python version 3.14.6 is invalid and will break CI.

python-version: "3.14.6" is not a valid release (current stable is 3.12), so this workflow will fail before tests run. Please pin to a supported version (e.g., 3.11 or 3.12) that aligns with Home Assistant and pytest-homeassistant-custom-component requirements.

from homeassistant.setup import async_setup_component

from tests.common import MockConfigEntry
from pytest_homeassistant_custom_component.common import MockConfigEntry

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (testing): Add a test to verify that the select entity filters out the 'total' tariff case-insensitively

The current changes rely on TariffSelect.options filtering out the "total" tariff via a case-insensitive regex, but there’s no test explicitly covering this (including mixed-case values like "Total"/"TOTAL").

Please add a test similar to the example below to ensure case-insensitive filtering of "total" is enforced and to guard against regressions:

async def test_select_options_filters_total_case_insensitive(
    hass: HomeAssistant,
    entity_registry: er.EntityRegistry,
    device_registry: dr.DeviceRegistry,
) -> None:
    source_entry = MockConfigEntry(domain="test")
    source_entry.add_to_hass(hass)
    source_device = device_registry.async_get_or_create(
        config_entry_id=source_entry.entry_id,
        identifiers={("test", "source")},
    )
    source_entity = entity_registry.async_get_or_create(
        "sensor", "test", "source",
        config_entry=source_entry,
        device_id=source_device.id,
    )

    config_entry = MockConfigEntry(
        domain=DOMAIN,
        options={
            CONF_NAME: "Energy",
            CONF_TARIFFS: ["Peak", "Total", "OFFPEAK"],
            CONF_SOURCE_SENSOR: source_entity.entity_id,
        },
    )
    config_entry.add_to_hass(hass)

    assert await async_setup_component(hass, DOMAIN, {})
    assert await hass.config_entries.async_setup(config_entry.entry_id)
    await hass.async_block_till_done()

    state = hass.states.get("select.energy")
    assert state is not None
    assert set(state.attributes["options"]) == {"Peak", "OFFPEAK"}

Suggested implementation:

from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.setup import async_setup_component

from pytest_homeassistant_custom_component.common import MockConfigEntry


async def test_select_options_filters_total_case_insensitive(
    hass,
    entity_registry,
    device_registry,
) -> None:
    source_entry = MockConfigEntry(domain="test")
    source_entry.add_to_hass(hass)
    source_device = device_registry.async_get_or_create(
        config_entry_id=source_entry.entry_id,
        identifiers={("test", "source")},
    )
    source_entity = entity_registry.async_get_or_create(
        "sensor",
        "test",
        "source",
        config_entry=source_entry,
        device_id=source_device.id,
    )

    config_entry = MockConfigEntry(
        domain=DOMAIN,
        options={
            CONF_NAME: "Energy",
            CONF_TARIFFS: ["Peak", "Total", "OFFPEAK"],
            CONF_SOURCE_SENSOR: source_entity.entity_id,
        },
    )
    config_entry.add_to_hass(hass)

    assert await async_setup_component(hass, DOMAIN, {})
    assert await hass.config_entries.async_setup(config_entry.entry_id)
    await hass.async_block_till_done()

    state = hass.states.get("select.energy")
    assert state is not None
    assert set(state.attributes["options"]) == {"Peak", "OFFPEAK"}


async def test_select_entity_name_config_entry(

This new test relies on the constants DOMAIN, CONF_NAME, CONF_TARIFFS, and CONF_SOURCE_SENSOR being imported elsewhere in the file (as is typical for this test module). If they are not already imported, you should add the appropriate imports at the top of the file, e.g.:

  • from homeassistant.components.utility_meter_evolved.const import DOMAIN
  • from homeassistant.const import CONF_NAME
  • from custom_components.utility_meter_evolved.const import CONF_TARIFFS, CONF_SOURCE_SENSOR

Adjust the import paths to match how they are defined in your integration.

Comment thread README.md

## Compatibility

Release 2026.8.0 and newer require Home Assistant 2026.8.0 or later. Utility

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (typo): Fix subject–verb agreement in the compatibility sentence.

Consider either "Release 2026.8.0 and newer requires Home Assistant 2026.8.0 or later" or "Releases 2026.8.0 and newer require Home Assistant 2026.8.0 or later" to match the singular/plural subject with the verb.

Suggested change
Release 2026.8.0 and newer require Home Assistant 2026.8.0 or later. Utility
Releases 2026.8.0 and newer require Home Assistant 2026.8.0 or later. Utility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant