api: refactor ccujack state keeping
This commit is contained in:
parent
07c72c752f
commit
b623082c4a
5 changed files with 22 additions and 36 deletions
|
|
@ -55,13 +55,17 @@ class CCUValue(BaseModel):
|
|||
v: Any
|
||||
|
||||
|
||||
LockData = List[Tuple[CCUDeviceInfo, List[Tuple[CCUChannelInfo, List[CCUParamInfo]]]]]
|
||||
|
||||
class CCUJackClient:
|
||||
base_uri: str
|
||||
locks: LockData
|
||||
|
||||
def __init__(self, base_uri: str, auth: BasicAuth):
|
||||
self.http = ClientSession(base_url=base_uri, auth=auth, raise_for_status=True, connector=TCPConnector(ssl=False))
|
||||
self.locks = None
|
||||
|
||||
async def find_locks(self) -> List[Tuple[CCUDeviceInfo, List[Tuple[CCUChannelInfo, List[CCUParamInfo]]]]]:
|
||||
async def find_locks(self):
|
||||
logger.debug("Inspecting lock devices present in CCUJack")
|
||||
async with self.http.get("/device") as resp:
|
||||
devices = CCUDeviceList.model_validate(await resp.json())
|
||||
|
|
@ -72,7 +76,7 @@ class CCUJackClient:
|
|||
if i.rel == "device"
|
||||
])
|
||||
|
||||
return [
|
||||
self.locks = [
|
||||
i
|
||||
for i in device_infos
|
||||
if i[0].type == DEVICE_TYPE_LOCK
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue