Skip to content

Commit

Permalink
Merge pull request #148 from tijsverkoyen/145-empty-data
Browse files Browse the repository at this point in the history
Don't update if there is no data
  • Loading branch information
tijsverkoyen authored Feb 7, 2024
2 parents c0efd98 + f46396a commit 1fb8436
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions custom_components/fusion_solar/device_real_kpi_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ async def _async_update_data(self):
except FusionSolarOpenApiError as error:
raise UpdateFailed(f'OpenAPI Error: {error}')

# When there is no data we can't update.
if response is None:
_LOGGER.warning(
f'getDevRealKpi returned a data object with no data. Check if you have sufficient permissions.'
)
return False

for response_data in response:
key = f'{DOMAIN}-{response_data[ATTR_DEVICE_REAL_KPI_DEV_ID]}'
data[key] = response_data[ATTR_DEVICE_REAL_KPI_DATA_ITEM_MAP]
Expand Down

0 comments on commit 1fb8436

Please sign in to comment.