diff --git a/homeassistant/components/hive/config_flow.py b/homeassistant/components/hive/config_flow.py index c713a3011f4981..90c78aefcbd1ab 100644 --- a/homeassistant/components/hive/config_flow.py +++ b/homeassistant/components/hive/config_flow.py @@ -27,6 +27,7 @@ def __init__(self): self.data = {} self.tokens = {} self.entry = None + self.device_registration = False async def async_step_user(self, user_input=None): """Prompt user input. Create or edit entry.""" @@ -88,6 +89,7 @@ async def async_step_2fa(self, user_input=None): if not errors: try: + self.device_registration = True return await self.async_setup_hive_entry() except UnknownHiveError: errors["base"] = "unknown" @@ -102,9 +104,10 @@ async def async_setup_hive_entry(self): raise UnknownHiveError # Setup the config entry - await self.hive_auth.device_registration("Home Assistant") + if self.device_registration: + await self.hive_auth.device_registration("Home Assistant") + self.data["device_data"] = await self.hive_auth.getDeviceData() self.data["tokens"] = self.tokens - self.data["device_data"] = await self.hive_auth.getDeviceData() if self.context["source"] == config_entries.SOURCE_REAUTH: self.hass.config_entries.async_update_entry( self.entry, title=self.data["username"], data=self.data diff --git a/homeassistant/components/hive/manifest.json b/homeassistant/components/hive/manifest.json index d8cd56abe0bc64..e0faa9e0f2096b 100644 --- a/homeassistant/components/hive/manifest.json +++ b/homeassistant/components/hive/manifest.json @@ -3,7 +3,7 @@ "name": "Hive", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/hive", - "requirements": ["pyhiveapi==0.5.5"], + "requirements": ["pyhiveapi==0.5.9"], "codeowners": ["@Rendili", "@KJonline"], "iot_class": "cloud_polling", "loggers": ["apyhiveapi"] diff --git a/requirements_all.txt b/requirements_all.txt index 866615632f37eb..7666712468d8b0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1541,7 +1541,7 @@ pyheos==0.7.2 pyhik==0.3.0 # homeassistant.components.hive -pyhiveapi==0.5.5 +pyhiveapi==0.5.9 # homeassistant.components.homematic pyhomematic==0.1.77 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index fd396ce2564500..096ca4d6d0b002 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1032,7 +1032,7 @@ pyhaversion==22.4.1 pyheos==0.7.2 # homeassistant.components.hive -pyhiveapi==0.5.5 +pyhiveapi==0.5.9 # homeassistant.components.homematic pyhomematic==0.1.77 diff --git a/tests/components/hive/test_config_flow.py b/tests/components/hive/test_config_flow.py index 51ceec43ad2181..35e20e8eee3f1e 100644 --- a/tests/components/hive/test_config_flow.py +++ b/tests/components/hive/test_config_flow.py @@ -33,16 +33,6 @@ async def test_import_flow(hass): "AccessToken": "mock-access-token", }, }, - ), patch( - "homeassistant.components.hive.config_flow.Auth.device_registration", - return_value=True, - ), patch( - "homeassistant.components.hive.config_flow.Auth.getDeviceData", - return_value=[ - "mock-device-group-key", - "mock-device-key", - "mock-device-password", - ], ), patch( "homeassistant.components.hive.async_setup", return_value=True ) as mock_setup, patch( @@ -67,11 +57,6 @@ async def test_import_flow(hass): }, "ChallengeName": "SUCCESS", }, - "device_data": [ - "mock-device-group-key", - "mock-device-key", - "mock-device-password", - ], } assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(mock_setup.mock_calls) == 1 @@ -96,16 +81,6 @@ async def test_user_flow(hass): "AccessToken": "mock-access-token", }, }, - ), patch( - "homeassistant.components.hive.config_flow.Auth.device_registration", - return_value=True, - ), patch( - "homeassistant.components.hive.config_flow.Auth.getDeviceData", - return_value=[ - "mock-device-group-key", - "mock-device-key", - "mock-device-password", - ], ), patch( "homeassistant.components.hive.async_setup", return_value=True ) as mock_setup, patch( @@ -130,11 +105,6 @@ async def test_user_flow(hass): }, "ChallengeName": "SUCCESS", }, - "device_data": [ - "mock-device-group-key", - "mock-device-key", - "mock-device-password", - ], } assert len(mock_setup.mock_calls) == 1