Small fixes, Add checks

This commit is contained in:
Andre Basche
2023-04-09 23:47:33 +02:00
parent 8dc6cd71cd
commit e8531f3faf
6 changed files with 58 additions and 15 deletions

View File

@ -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
View 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))

View File

@ -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):

View File

@ -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()