mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Fix growatt identification issue (#84628)
Fixes https://github.com/home-assistant/core/issues/84600 fixes undefined
This commit is contained in:
parent
a9be2adf06
commit
eba64f84ef
@ -22,7 +22,7 @@ class GrowattServerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialise growatt server flow."""
|
"""Initialise growatt server flow."""
|
||||||
self.api = growattServer.GrowattApi()
|
self.api = None
|
||||||
self.user_id = None
|
self.user_id = None
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
|
||||||
@ -46,6 +46,10 @@ class GrowattServerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if not user_input:
|
if not user_input:
|
||||||
return self._async_show_user_form()
|
return self._async_show_user_form()
|
||||||
|
|
||||||
|
# Initialise the library with the username & a random id each time it is started
|
||||||
|
self.api = growattServer.GrowattApi(
|
||||||
|
add_random_user_id=True, agent_identifier=user_input[CONF_USERNAME]
|
||||||
|
)
|
||||||
self.api.server_url = user_input[CONF_URL]
|
self.api.server_url = user_input[CONF_URL]
|
||||||
login_response = await self.hass.async_add_executor_job(
|
login_response = await self.hass.async_add_executor_job(
|
||||||
self.api.login, user_input[CONF_USERNAME], user_input[CONF_PASSWORD]
|
self.api.login, user_input[CONF_USERNAME], user_input[CONF_PASSWORD]
|
||||||
|
@ -80,14 +80,8 @@ async def async_setup_entry(
|
|||||||
config[CONF_URL] = url
|
config[CONF_URL] = url
|
||||||
hass.config_entries.async_update_entry(config_entry, data=config)
|
hass.config_entries.async_update_entry(config_entry, data=config)
|
||||||
|
|
||||||
# Initialise the library with a random user id each time it is started,
|
# Initialise the library with the username & a random id each time it is started
|
||||||
# also extend the library's default identifier to include 'home-assistant'
|
api = growattServer.GrowattApi(add_random_user_id=True, agent_identifier=username)
|
||||||
api = growattServer.GrowattApi(
|
|
||||||
add_random_user_id=True,
|
|
||||||
agent_identifier=(
|
|
||||||
f"{growattServer.GrowattApi.agent_identifier} - home-assistant"
|
|
||||||
),
|
|
||||||
)
|
|
||||||
api.server_url = url
|
api.server_url = url
|
||||||
|
|
||||||
devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config)
|
devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user