Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform a single request to acquire device _and_ inverter data #157

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions custom_components/omnik_inverter/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def async_step_setup(
host=user_input[CONF_HOST],
source_type=self.source_type,
) as client:
await client.inverter()
await client.perform_request()
except OmnikInverterError:
LOGGER.exception("Failed to connect to the Omnik")
errors["base"] = "cannot_connect"
Expand Down Expand Up @@ -183,7 +183,7 @@ async def async_step_setup_html(
username=user_input[CONF_USERNAME],
password=user_input[CONF_PASSWORD],
) as client:
await client.inverter()
await client.perform_request()
except OmnikInverterError:
LOGGER.exception("Failed to connect to the Omnik")
errors["base"] = "cannot_connect"
Expand Down Expand Up @@ -237,7 +237,7 @@ async def async_step_setup_tcp(
source_type=self.source_type,
serial_number=user_input[CONF_SERIAL],
) as client:
await client.inverter()
await client.perform_request()
except OmnikInverterError:
LOGGER.exception("Failed to connect to the Omnik")
errors["base"] = "cannot_connect"
Expand Down
5 changes: 3 additions & 2 deletions custom_components/omnik_inverter/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ async def _async_update_data(self) -> OmnikInverterData:
UpdateFailed: An error occurred when updating the data.
"""
try:
request = await self.omnikinverter.perform_request()
data: OmnikInverterData = {
SERVICE_INVERTER: await self.omnikinverter.inverter(),
SERVICE_DEVICE: await self.omnikinverter.device(),
SERVICE_INVERTER: request.inverter(),
SERVICE_DEVICE: request.device(),
}
return data
except OmnikInverterAuthError as error:
Expand Down