diff --git a/pyhilo/api.py b/pyhilo/api.py index 942b769..93dcbd9 100755 --- a/pyhilo/api.py +++ b/pyhilo/api.py @@ -65,11 +65,12 @@ def __init__( oauth_session: OAuth2Session, request_retries: int = REQUEST_RETRY, log_traces: bool = False, + state_yaml: str = DEFAULT_STATE_FILE, ) -> None: """Initialize""" self._backoff_refresh_lock_api = asyncio.Lock() self._request_retries = request_retries - self._state_yaml: str = DEFAULT_STATE_FILE + self._state_yaml: str = state_yaml self.state: StateDict = {} self.async_request = self._wrap_request_method(self._request_retries) self.device_attributes = get_device_attributes() @@ -92,6 +93,7 @@ async def async_create( oauth_session: OAuth2Session, request_retries: int = REQUEST_RETRY, log_traces: bool = False, + state_yaml: str = DEFAULT_STATE_FILE, ) -> API: """Get an authenticated API object. :param session: The ``aiohttp`` ``ClientSession`` session used for all HTTP requests @@ -100,6 +102,7 @@ async def async_create( :type oauth_session: ``config_entry_oauth2_flow.OAuth2Session`` :param request_retries: The default number of request retries to use :type request_retries: ``int`` + :param state_yaml: Path of the file where the API state (tokens, etc.) is saved. :rtype: :meth:`pyhilo.api.API` """ api = cls( @@ -107,6 +110,7 @@ async def async_create( oauth_session=oauth_session, request_retries=request_retries, log_traces=log_traces, + state_yaml=state_yaml, ) # Test token before post init await api.async_get_access_token()