Fix Hive authentication (#72929)
This commit is contained in:
parent
9fbde245d0
commit
a4c3585448
6 changed files with 21 additions and 10 deletions
|
@ -75,14 +75,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Hive from a config entry."""
|
"""Set up Hive from a config entry."""
|
||||||
|
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
web_session = aiohttp_client.async_get_clientsession(hass)
|
||||||
hive_config = dict(entry.data)
|
hive_config = dict(entry.data)
|
||||||
hive = Hive(
|
hive = Hive(web_session)
|
||||||
websession,
|
|
||||||
deviceGroupKey=hive_config["device_data"][0],
|
|
||||||
deviceKey=hive_config["device_data"][1],
|
|
||||||
devicePassword=hive_config["device_data"][2],
|
|
||||||
)
|
|
||||||
|
|
||||||
hive_config["options"] = {}
|
hive_config["options"] = {}
|
||||||
hive_config["options"].update(
|
hive_config["options"].update(
|
||||||
|
|
|
@ -102,6 +102,7 @@ class HiveFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
raise UnknownHiveError
|
raise UnknownHiveError
|
||||||
|
|
||||||
# Setup the config entry
|
# Setup the config entry
|
||||||
|
await self.hive_auth.device_registration("Home Assistant")
|
||||||
self.data["tokens"] = self.tokens
|
self.data["tokens"] = self.tokens
|
||||||
self.data["device_data"] = await self.hive_auth.getDeviceData()
|
self.data["device_data"] = await self.hive_auth.getDeviceData()
|
||||||
if self.context["source"] == config_entries.SOURCE_REAUTH:
|
if self.context["source"] == config_entries.SOURCE_REAUTH:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "Hive",
|
"name": "Hive",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/hive",
|
"documentation": "https://www.home-assistant.io/integrations/hive",
|
||||||
"requirements": ["pyhiveapi==0.5.4"],
|
"requirements": ["pyhiveapi==0.5.5"],
|
||||||
"codeowners": ["@Rendili", "@KJonline"],
|
"codeowners": ["@Rendili", "@KJonline"],
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["apyhiveapi"]
|
"loggers": ["apyhiveapi"]
|
||||||
|
|
|
@ -1538,7 +1538,7 @@ pyheos==0.7.2
|
||||||
pyhik==0.3.0
|
pyhik==0.3.0
|
||||||
|
|
||||||
# homeassistant.components.hive
|
# homeassistant.components.hive
|
||||||
pyhiveapi==0.5.4
|
pyhiveapi==0.5.5
|
||||||
|
|
||||||
# homeassistant.components.homematic
|
# homeassistant.components.homematic
|
||||||
pyhomematic==0.1.77
|
pyhomematic==0.1.77
|
||||||
|
|
|
@ -1029,7 +1029,7 @@ pyhaversion==22.4.1
|
||||||
pyheos==0.7.2
|
pyheos==0.7.2
|
||||||
|
|
||||||
# homeassistant.components.hive
|
# homeassistant.components.hive
|
||||||
pyhiveapi==0.5.4
|
pyhiveapi==0.5.5
|
||||||
|
|
||||||
# homeassistant.components.homematic
|
# homeassistant.components.homematic
|
||||||
pyhomematic==0.1.77
|
pyhomematic==0.1.77
|
||||||
|
|
|
@ -33,6 +33,9 @@ async def test_import_flow(hass):
|
||||||
"AccessToken": "mock-access-token",
|
"AccessToken": "mock-access-token",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.hive.config_flow.Auth.device_registration",
|
||||||
|
return_value=True,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
|
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
|
||||||
return_value=[
|
return_value=[
|
||||||
|
@ -93,6 +96,9 @@ async def test_user_flow(hass):
|
||||||
"AccessToken": "mock-access-token",
|
"AccessToken": "mock-access-token",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.hive.config_flow.Auth.device_registration",
|
||||||
|
return_value=True,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
|
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
|
||||||
return_value=[
|
return_value=[
|
||||||
|
@ -172,6 +178,9 @@ async def test_user_flow_2fa(hass):
|
||||||
"AccessToken": "mock-access-token",
|
"AccessToken": "mock-access-token",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.hive.config_flow.Auth.device_registration",
|
||||||
|
return_value=True,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
|
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
|
||||||
return_value=[
|
return_value=[
|
||||||
|
@ -256,6 +265,9 @@ async def test_reauth_flow(hass):
|
||||||
"AccessToken": "mock-access-token",
|
"AccessToken": "mock-access-token",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.hive.config_flow.Auth.device_registration",
|
||||||
|
return_value=True,
|
||||||
):
|
):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
|
@ -361,6 +373,9 @@ async def test_user_flow_2fa_send_new_code(hass):
|
||||||
"AccessToken": "mock-access-token",
|
"AccessToken": "mock-access-token",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.hive.config_flow.Auth.device_registration",
|
||||||
|
return_value=True,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
|
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
|
||||||
return_value=[
|
return_value=[
|
||||||
|
|
Loading…
Add table
Reference in a new issue