From 3283965b45229aa76c1f33672905865dd2cb0bf0 Mon Sep 17 00:00:00 2001 From: Duco Sebel <74970928+DCSBL@users.noreply.github.com> Date: Mon, 16 Jun 2025 14:11:35 +0200 Subject: [PATCH] Re-enable v2 API support for HomeWizard P1 Meter (#146927) --- .../components/homewizard/__init__.py | 7 ++--- tests/components/homewizard/test_init.py | 31 ------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/homeassistant/components/homewizard/__init__.py b/homeassistant/components/homewizard/__init__.py index 3831146aed8..6c9530db72c 100644 --- a/homeassistant/components/homewizard/__init__.py +++ b/homeassistant/components/homewizard/__init__.py @@ -23,9 +23,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: HomeWizardConfigEntry) - api: HomeWizardEnergy - is_battery = entry.unique_id.startswith("HWE-BAT") if entry.unique_id else False - - if (token := entry.data.get(CONF_TOKEN)) and is_battery: + if token := entry.data.get(CONF_TOKEN): api = HomeWizardEnergyV2( entry.data[CONF_IP_ADDRESS], token=token, @@ -37,8 +35,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: HomeWizardConfigEntry) - clientsession=async_get_clientsession(hass), ) - if is_battery: - await async_check_v2_support_and_create_issue(hass, entry) + await async_check_v2_support_and_create_issue(hass, entry) coordinator = HWEnergyDeviceUpdateCoordinator(hass, entry, api) try: diff --git a/tests/components/homewizard/test_init.py b/tests/components/homewizard/test_init.py index 9139ef80d12..be811355e1d 100644 --- a/tests/components/homewizard/test_init.py +++ b/tests/components/homewizard/test_init.py @@ -10,7 +10,6 @@ import pytest from homeassistant.components.homewizard.const import DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState -from homeassistant.const import CONF_IP_ADDRESS, CONF_TOKEN from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry, async_fire_time_changed @@ -58,36 +57,6 @@ async def test_load_unload_v2( assert mock_config_entry_v2.state is ConfigEntryState.NOT_LOADED -async def test_load_unload_v2_as_v1( - hass: HomeAssistant, - mock_homewizardenergy: MagicMock, -) -> None: - """Test loading and unloading of integration with v2 config, but without using it.""" - - # Simulate v2 config but as a P1 Meter - mock_config_entry = MockConfigEntry( - title="Device", - domain=DOMAIN, - data={ - CONF_IP_ADDRESS: "127.0.0.1", - CONF_TOKEN: "00112233445566778899ABCDEFABCDEF", - }, - unique_id="HWE-P1_5c2fafabcdef", - ) - - mock_config_entry.add_to_hass(hass) - await hass.config_entries.async_setup(mock_config_entry.entry_id) - await hass.async_block_till_done() - - assert mock_config_entry.state is ConfigEntryState.LOADED - assert len(mock_homewizardenergy.combined.mock_calls) == 1 - - await hass.config_entries.async_unload(mock_config_entry.entry_id) - await hass.async_block_till_done() - - assert mock_config_entry.state is ConfigEntryState.NOT_LOADED - - async def test_load_failed_host_unavailable( hass: HomeAssistant, mock_config_entry: MockConfigEntry,