Skip to content

Commit

Permalink
fix: Removed duplicate logging of events
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave committed Jan 11, 2024
1 parent a13edef commit 1f4e3da
Show file tree
Hide file tree
Showing 16 changed files with 2 additions and 17 deletions.
1 change: 0 additions & 1 deletion custom_components/octopus_energy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ async def async_setup_dependencies(hass, config):
raise ConfigEntryNotReady(f"Failed to retrieve account information")
except Exception as e:
if isinstance(e, RequestException) == False:
_LOGGER.error(e)
raise

raise ConfigEntryNotReady(f"Failed to retrieve account information")
Expand Down
1 change: 0 additions & 1 deletion custom_components/octopus_energy/coordinators/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ async def async_refresh_account(
return AccountCoordinatorResult(current, 1, account_info)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

result = AccountCoordinatorResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async def async_get_live_consumption(
return CurrentConsumptionCoordinatorResult(current_date, 1, refresh_rate_in_minutes, result)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.exception(e)
raise

result: CurrentConsumptionCoordinatorResult = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ async def async_refresh_electricity_rates_data(
new_rates = await client.async_get_electricity_rates(tariff_code, is_smart_meter, period_from, period_to)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

_LOGGER.debug(f'Failed to retrieve electricity rates for {target_mpan}/{target_serial_number} ({tariff_code})')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ async def async_refresh_electricity_standing_charges_data(
_LOGGER.debug(f'Electricity standing charges retrieved for {target_mpan}/{target_serial_number} ({tariff_code})')
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

_LOGGER.debug(f'Failed to retrieve electricity standing charges for {target_mpan}/{target_serial_number} ({tariff_code})')
Expand Down
1 change: 0 additions & 1 deletion custom_components/octopus_energy/coordinators/gas_rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ async def async_refresh_gas_rates_data(
new_rates = await client.async_get_gas_rates(tariff_code, period_from, period_to)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

_LOGGER.debug(f'Failed to retrieve gas rates for {target_mprn}/{target_serial_number} ({tariff_code})')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ async def async_refresh_gas_standing_charges_data(
_LOGGER.debug(f'Gas standing charges retrieved for {target_mprn}/{target_serial_number} ({tariff_code})')
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

_LOGGER.debug(f'Failed to retrieve gas standing charges for {target_mprn}/{target_serial_number} ({tariff_code})')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ async def async_refresh_intelligent_dispatches(
_LOGGER.debug(f'Intelligent dispatches retrieved for account {account_id}')
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

_LOGGER.debug('Failed to retrieve intelligent dispatches for account {account_id}')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ async def async_refresh_intelligent_settings(
_LOGGER.debug(f'Intelligent settings retrieved for account {account_id}')
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

_LOGGER.debug('Failed to retrieve intelligent settings for account {account_id}')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ async def async_fetch_consumption_and_rates(
)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

result = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ async def async_refresh_saving_sessions(
return SavingSessionsCoordinatorResult(current, 1, available_events, result.joined_events)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

result = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ async def async_refresh_wheel_of_fortune_spins(
return WheelOfFortuneSpinsCoordinatorResult(current, 1, result)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

result = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def native_value(self):
self._attributes["last_evaluated"] = result.last_evaluated
self._attributes["data_last_retrieved"] = result.data_last_retrieved

return self._state

async def async_added_to_hass(self):
"""Call when entity about to be added to hass."""
# If not None, we got an initial value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ async def async_update(self):
self._next_refresh = calculate_next_refresh(current, self._request_attempts, REFRESH_RATE_IN_MINUTES_PREVIOUS_CONSUMPTION)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

self._request_attempts = self._request_attempts + 1
Expand All @@ -189,7 +188,6 @@ async def async_update(self):
self._request_attempts,
REFRESH_RATE_IN_MINUTES_PREVIOUS_CONSUMPTION
)
_LOGGER.error(e)
_LOGGER.warning(f'Failed to retrieve previous accumulative cost override data - using cached data. Next attempt at {self._next_refresh}')

if result is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ async def async_update(self):
self._next_refresh = calculate_next_refresh(current, self._request_attempts, REFRESH_RATE_IN_MINUTES_PREVIOUS_CONSUMPTION)
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise

self._request_attempts = self._request_attempts + 1
Expand All @@ -190,7 +189,6 @@ async def async_update(self):
self._request_attempts,
REFRESH_RATE_IN_MINUTES_PREVIOUS_CONSUMPTION
)
_LOGGER.error(e)
_LOGGER.warning(f'Failed to retrieve previous accumulative cost override data - using cached data. Next attempt at {self._next_refresh}')

if result is not None:
Expand Down
1 change: 0 additions & 1 deletion custom_components/octopus_energy/octoplus/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ async def async_update(self):
self._request_attempts = 1
except Exception as e:
if isinstance(e, ApiException) == False:
_LOGGER.error(e)
raise
_LOGGER.warning(f"Failed to retrieve octopoints")
self._request_attempts = self._request_attempts + 1
Expand Down

0 comments on commit 1f4e3da

Please sign in to comment.