diff --git a/pyhilo/__init__.py b/pyhilo/__init__.py index 7320aa2..c09325e 100644 --- a/pyhilo/__init__.py +++ b/pyhilo/__init__.py @@ -6,7 +6,6 @@ from pyhilo.devices import Devices from pyhilo.event import Event from pyhilo.exceptions import HiloError, InvalidCredentialsError, WebsocketError -from pyhilo.oauth2 import AuthCodeWithPKCEImplementation from pyhilo.util import from_utc_timestamp, time_diff from pyhilo.websocket import WebsocketEvent @@ -18,7 +17,6 @@ "HiloError", "InvalidCredentialsError", "WebsocketError", - "AuthCodeWithPKCEImplementation", "from_utc_timestamp", "time_diff", "WebsocketEvent", diff --git a/pyhilo/devices.py b/pyhilo/devices.py index f9257d8..e558646 100644 --- a/pyhilo/devices.py +++ b/pyhilo/devices.py @@ -38,7 +38,7 @@ def attributes_list(self) -> list[Union[int, dict[int, list[str]]]]: ] def parse_values_received(self, values: list[dict[str, Any]]) -> list[HiloDevice]: - """Places value received in a dict while removing null attributes, + """Places value received in a dict while removing null attributes, this returns values to be mapped to devices. """ readings = [] @@ -110,7 +110,7 @@ async def update(self) -> None: async def update_devicelist_from_signalr( self, values: list[dict[str, Any]] ) -> list[HiloDevice]: - #ic-dev21 not sure if this is dead code? + # ic-dev21 not sure if this is dead code? new_devices = [] for raw_device in values: LOG.debug(f"Generating device {raw_device}") diff --git a/pyhilo/graphql.py b/pyhilo/graphql.py index 7344e01..8a8dace 100644 --- a/pyhilo/graphql.py +++ b/pyhilo/graphql.py @@ -574,7 +574,9 @@ async def subscribe_to_device_updated( await asyncio.sleep(5) try: await self.call_get_location_query(location_hilo_id) - LOG.debug("subscribe_to_device_updated, call_get_location_query success") + LOG.debug( + "subscribe_to_device_updated, call_get_location_query success" + ) except Exception as e2: LOG.error( diff --git a/pyhilo/oauth2.py b/pyhilo/oauth2.py deleted file mode 100644 index 04f8b6b..0000000 --- a/pyhilo/oauth2.py +++ /dev/null @@ -1,51 +0,0 @@ -"""Custom OAuth2 implementation.""" - -from typing import Any, cast - -from homeassistant.core import HomeAssistant -from homeassistant.helpers.config_entry_oauth2_flow import LocalOAuth2Implementation - -from pyhilo.const import AUTH_AUTHORIZE, AUTH_CLIENT_ID, AUTH_TOKEN, DOMAIN -from pyhilo.oauth2helper import OAuth2Helper - - -class AuthCodeWithPKCEImplementation(LocalOAuth2Implementation): # type: ignore[misc] - """Custom OAuth2 implementation.""" - - def __init__( - self, - hass: HomeAssistant, - ) -> None: - """Initialize AuthCodeWithPKCEImplementation.""" - super().__init__( - hass, - DOMAIN, - AUTH_CLIENT_ID, - "", - AUTH_AUTHORIZE, - AUTH_TOKEN, - ) - - self.oauth_helper = OAuth2Helper() - - # ... Override AbstractOAuth2Implementation details - @property - def name(self) -> str: - """Name of the implementation.""" - return "Hilo" - - @property - def extra_authorize_data(self) -> dict: - """Extra data that needs to be appended to the authorize url.""" - return self.oauth_helper.get_authorize_parameters() - - async def async_resolve_external_data(self, external_data: Any) -> dict: - """Resolve the authorization code to tokens.""" - return cast( - dict, - await self._token_request( - self.oauth_helper.get_token_request_parameters( - external_data["code"], external_data["state"]["redirect_uri"] - ) - ), - )