Small fixes, Add checks
This commit is contained in:
@ -1,2 +1,4 @@
|
||||
from .connection.api import HonAPI
|
||||
from hon import Hon
|
||||
from .hon import Hon
|
||||
|
||||
__all__ = ["Hon", "HonAPI"]
|
||||
|
1
pyhon/__main__.py
Normal file → Executable file
1
pyhon/__main__.py
Normal file → Executable file
@ -6,7 +6,6 @@ import logging
|
||||
import sys
|
||||
from getpass import getpass
|
||||
from pathlib import Path
|
||||
from pprint import pprint
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
@ -10,12 +10,13 @@ _LOGGER = logging.getLogger()
|
||||
|
||||
|
||||
class HonAPI:
|
||||
def __init__(self, email="", password="") -> None:
|
||||
def __init__(self, email="", password="", anonymous=False) -> None:
|
||||
super().__init__()
|
||||
self._email = email
|
||||
self._password = password
|
||||
self._anonymous = anonymous
|
||||
self._hon = None
|
||||
self._hon_anonymous = HonAnonymousConnectionHandler()
|
||||
self._hon_anonymous = None
|
||||
|
||||
async def __aenter__(self):
|
||||
return await self.create()
|
||||
@ -24,7 +25,9 @@ class HonAPI:
|
||||
await self._hon.close()
|
||||
|
||||
async def create(self):
|
||||
self._hon = await HonConnectionHandler(self._email, self._password).create()
|
||||
self._hon_anonymous = HonAnonymousConnectionHandler()
|
||||
if not self._anonymous:
|
||||
self._hon = await HonConnectionHandler(self._email, self._password).create()
|
||||
return self
|
||||
|
||||
async def load_appliances(self):
|
||||
|
@ -27,11 +27,11 @@ class HonBaseConnectionHandler:
|
||||
|
||||
@asynccontextmanager
|
||||
async def get(self, *args, **kwargs):
|
||||
raise NotImplemented
|
||||
raise NotImplementedError
|
||||
|
||||
@asynccontextmanager
|
||||
async def post(self, *args, **kwargs):
|
||||
raise NotImplemented
|
||||
raise NotImplementedError
|
||||
|
||||
async def close(self):
|
||||
await self._session.close()
|
||||
|
Reference in New Issue
Block a user