diff --git a/homeassistant/components/homeassistant_connect_zbt2/config_flow.py b/homeassistant/components/homeassistant_connect_zbt2/config_flow.py index de5b868f077..0d01081afac 100644 --- a/homeassistant/components/homeassistant_connect_zbt2/config_flow.py +++ b/homeassistant/components/homeassistant_connect_zbt2/config_flow.py @@ -39,8 +39,6 @@ from .const import ( NABU_CASA_FIRMWARE_RELEASES_URL, PID, PRODUCT, - RADIO_TX_POWER_DBM_BY_COUNTRY, - RADIO_TX_POWER_DBM_DEFAULT, SERIAL_NUMBER, VID, ) @@ -114,21 +112,6 @@ class ZBT2FirmwareMixin(ConfigEntryBaseFlow, FirmwareInstallFlowProtocol): next_step_id="finish_thread_installation", ) - def _extra_zha_hardware_options(self) -> dict[str, Any]: - """Return extra ZHA hardware options.""" - country = self.hass.config.country - - if country is None: - tx_power = RADIO_TX_POWER_DBM_DEFAULT - else: - tx_power = RADIO_TX_POWER_DBM_BY_COUNTRY.get( - country, RADIO_TX_POWER_DBM_DEFAULT - ) - - return { - "tx_power": tx_power, - } - class HomeAssistantConnectZBT2ConfigFlow( ZBT2FirmwareMixin, diff --git a/homeassistant/components/homeassistant_connect_zbt2/const.py b/homeassistant/components/homeassistant_connect_zbt2/const.py index c66c6a6574b..556c2a5b80d 100644 --- a/homeassistant/components/homeassistant_connect_zbt2/const.py +++ b/homeassistant/components/homeassistant_connect_zbt2/const.py @@ -1,7 +1,5 @@ """Constants for the Home Assistant Connect ZBT-2 integration.""" -from homeassistant.generated.countries import COUNTRIES - DOMAIN = "homeassistant_connect_zbt2" NABU_CASA_FIRMWARE_RELEASES_URL = ( @@ -19,59 +17,3 @@ VID = "vid" DEVICE = "device" HARDWARE_NAME = "Home Assistant Connect ZBT-2" - -RADIO_TX_POWER_DBM_DEFAULT = 8 -RADIO_TX_POWER_DBM_BY_COUNTRY = { - # EU Member States - "AT": 10, - "BE": 10, - "BG": 10, - "HR": 10, - "CY": 10, - "CZ": 10, - "DK": 10, - "EE": 10, - "FI": 10, - "FR": 10, - "DE": 10, - "GR": 10, - "HU": 10, - "IE": 10, - "IT": 10, - "LV": 10, - "LT": 10, - "LU": 10, - "MT": 10, - "NL": 10, - "PL": 10, - "PT": 10, - "RO": 10, - "SK": 10, - "SI": 10, - "ES": 10, - "SE": 10, - # EEA Members - "IS": 10, - "LI": 10, - "NO": 10, - # Standards harmonized with RED or ETSI - "CH": 10, - "GB": 10, - "TR": 10, - "AL": 10, - "BA": 10, - "GE": 10, - "MD": 10, - "ME": 10, - "MK": 10, - "RS": 10, - "UA": 10, - # Other CEPT nations - "AD": 10, - "AZ": 10, - "MC": 10, - "SM": 10, - "VA": 10, -} - -assert set(RADIO_TX_POWER_DBM_BY_COUNTRY) <= COUNTRIES diff --git a/homeassistant/components/homeassistant_hardware/firmware_config_flow.py b/homeassistant/components/homeassistant_hardware/firmware_config_flow.py index b75c018728f..f61a3532c1a 100644 --- a/homeassistant/components/homeassistant_hardware/firmware_config_flow.py +++ b/homeassistant/components/homeassistant_hardware/firmware_config_flow.py @@ -457,10 +457,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC): # This step is necessary to prevent `user_input` from being passed through return await self.async_step_continue_zigbee() - def _extra_zha_hardware_options(self) -> dict[str, Any]: - """Return extra ZHA hardware options.""" - return {} - async def async_step_continue_zigbee( self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: @@ -483,7 +479,6 @@ class BaseFirmwareInstallFlow(ConfigEntryBaseFlow, ABC): }, "radio_type": "ezsp", "flow_strategy": self._zigbee_flow_strategy, - **self._extra_zha_hardware_options(), }, ) return self._continue_zha_flow(result) diff --git a/homeassistant/components/zha/config_flow.py b/homeassistant/components/zha/config_flow.py index c7d25298ecd..4a941a9ab2a 100644 --- a/homeassistant/components/zha/config_flow.py +++ b/homeassistant/components/zha/config_flow.py @@ -15,7 +15,7 @@ from typing import Any import voluptuous as vol from zha.application.const import RadioType import zigpy.backups -from zigpy.config import CONF_DEVICE, CONF_DEVICE_PATH, CONF_NWK_TX_POWER +from zigpy.config import CONF_DEVICE, CONF_DEVICE_PATH from zigpy.exceptions import CannotWriteNetworkSettings, DestructiveWriteNetworkSettings from homeassistant.components import onboarding, usb @@ -196,7 +196,6 @@ class BaseZhaFlow(ConfigEntryBaseFlow): self._restore_backup_task: asyncio.Task[None] | None = None self._reset_old_radio_task: asyncio.Task[None] | None = None self._form_network_task: asyncio.Task[None] | None = None - self._extra_network_config: dict[str, Any] = {} # Progress flow steps cannot abort so we need to store the abort reason and then # re-raise it in a dedicated step @@ -658,7 +657,7 @@ class BaseZhaFlow(ConfigEntryBaseFlow): async def _async_form_new_network(self) -> None: """Do the work of forming a new network.""" - await self._radio_mgr.async_form_network(config=self._extra_network_config) + await self._radio_mgr.async_form_network() # Load the newly formed network settings to get the network info await self._radio_mgr.async_load_network_settings() @@ -1068,9 +1067,6 @@ class ZhaConfigFlowHandler(BaseZhaFlow, ConfigFlow, domain=DOMAIN): device_path = device_settings[CONF_DEVICE_PATH] self._flow_strategy = discovery_data.get("flow_strategy") - if "tx_power" in discovery_data: - self._extra_network_config[CONF_NWK_TX_POWER] = discovery_data["tx_power"] - await self._set_unique_id_and_update_ignored_flow( unique_id=f"{name}_{radio_type.name}_{device_path}", device_path=device_path, diff --git a/homeassistant/components/zha/radio_manager.py b/homeassistant/components/zha/radio_manager.py index 4f58ae33245..fe491c19f6d 100644 --- a/homeassistant/components/zha/radio_manager.py +++ b/homeassistant/components/zha/radio_manager.py @@ -323,7 +323,7 @@ class ZhaRadioManager: return backup - async def async_form_network(self, config: dict[str, Any] | None) -> None: + async def async_form_network(self) -> None: """Form a brand-new network.""" # When forming a new network, we delete the ZHA database to prevent old devices @@ -332,7 +332,7 @@ class ZhaRadioManager: await self.hass.async_add_executor_job(os.remove, self.zigpy_database_path) async with self.create_zigpy_app() as app: - await app.form_network(config=config) + await app.form_network() async def async_reset_adapter(self) -> None: """Reset the current adapter.""" diff --git a/tests/components/homeassistant_connect_zbt2/test_config_flow.py b/tests/components/homeassistant_connect_zbt2/test_config_flow.py index ecf165461e2..d50d02172f1 100644 --- a/tests/components/homeassistant_connect_zbt2/test_config_flow.py +++ b/tests/components/homeassistant_connect_zbt2/test_config_flow.py @@ -50,23 +50,8 @@ def setup_entry_fixture() -> Generator[AsyncMock]: yield mock_setup_entry -@pytest.mark.parametrize( - ("country", "expected_tx_power"), - [ - ("US", 8), - ("NL", 10), - ("JP", 8), - ("DE", 10), - ], -) -async def test_config_flow_zigbee( - hass: HomeAssistant, - country: str, - expected_tx_power: int, -) -> None: +async def test_config_flow_zigbee(hass: HomeAssistant) -> None: """Test Zigbee config flow for Connect ZBT-2.""" - hass.config.country = country - fw_type = ApplicationType.EZSP fw_version = "7.4.4.0 build 0" model = "Home Assistant Connect ZBT-2" @@ -160,7 +145,6 @@ async def test_config_flow_zigbee( "flow_control": "hardware", }, "radio_type": fw_type.value, - "tx_power": expected_tx_power, } @@ -400,7 +384,6 @@ async def test_options_flow( "flow_control": "hardware", }, "radio_type": "ezsp", - "tx_power": 8, } diff --git a/tests/components/zha/test_config_flow.py b/tests/components/zha/test_config_flow.py index 3f24da8a0c6..83aaadc0d92 100644 --- a/tests/components/zha/test_config_flow.py +++ b/tests/components/zha/test_config_flow.py @@ -19,6 +19,7 @@ import uuid import pytest from serial.tools.list_ports_common import ListPortInfo from zha.application.const import RadioType +from zigpy.application import ControllerApplication from zigpy.backups import BackupManager import zigpy.config from zigpy.config import CONF_DEVICE, CONF_DEVICE_PATH, SCHEMA_DEVICE @@ -97,9 +98,11 @@ def mock_multipan_platform(): @pytest.fixture(autouse=True) def mock_app() -> Generator[AsyncMock]: """Mock zigpy app interface.""" - mock_app = AsyncMock() + mock_app = create_autospec(ControllerApplication, instance=True) mock_app.backups = create_autospec(BackupManager, instance=True) mock_app.backups.backups = [] + + mock_app.state = MagicMock() mock_app.state.network_info.extended_pan_id = zigpy.types.EUI64.convert( "AABBCCDDEE000000" )