mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +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):
|
||||
"""Initialise growatt server flow."""
|
||||
self.api = growattServer.GrowattApi()
|
||||
self.api = None
|
||||
self.user_id = None
|
||||
self.data = {}
|
||||
|
||||
@ -46,6 +46,10 @@ class GrowattServerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if not user_input:
|
||||
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]
|
||||
login_response = await self.hass.async_add_executor_job(
|
||||
self.api.login, user_input[CONF_USERNAME], user_input[CONF_PASSWORD]
|
||||
|
@ -80,14 +80,8 @@ async def async_setup_entry(
|
||||
config[CONF_URL] = url
|
||||
hass.config_entries.async_update_entry(config_entry, data=config)
|
||||
|
||||
# Initialise the library with a random user 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=(
|
||||
f"{growattServer.GrowattApi.agent_identifier} - home-assistant"
|
||||
),
|
||||
)
|
||||
# Initialise the library with the username & a random id each time it is started
|
||||
api = growattServer.GrowattApi(add_random_user_id=True, agent_identifier=username)
|
||||
api.server_url = url
|
||||
|
||||
devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config)
|
||||
|
Loading…
x
Reference in New Issue
Block a user