Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Oct 5, 2024
1 parent 9f17ac9 commit fba4d0a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions homeassistant/components/tesla_fleet/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ async def async_config_entry_first_refresh(self) -> None:
async def _async_update_data(self) -> dict[str, Any]:
"""Update energy site history data using Tesla Fleet API."""

self.update_interval = ENERGY_INTERVAL
try:
data = (await self.api.energy_history(TeslaEnergyPeriod.DAY))["response"]
except RateLimited as e:
Expand All @@ -236,10 +235,9 @@ async def _async_update_data(self) -> dict[str, Any]:

# Add all time periods together
output = {key: 0 for key in ENERGY_HISTORY_FIELDS}
if isinstance(data, dict):
for period in data.get("time_series", []):
for key in ENERGY_HISTORY_FIELDS:
output[key] += period.get(key, 0)
for period in data.get("time_series", []):
for key in ENERGY_HISTORY_FIELDS:
output[key] += period.get(key, 0)

return output

Expand Down

0 comments on commit fba4d0a

Please sign in to comment.