3
3
# SPDX-License-Identifier: MIT
4
4
# -----------------------------------------------------------
5
5
6
+ import asyncio
6
7
import collections
7
8
import json
8
9
import threading
14
15
from .auth import Domains , Session
15
16
from .countries import get_country_code , get_region_by_country
16
17
from .consts import (
17
- APP_VERSION_CODE , APP_VERSION_NAME , PROJECT_TYPE ,
18
- PROTOCOL_VERSION , REGION_URLS , ROBOT_PROPERTIES , TENANT_ID ,
18
+ APP_VERSION_CODE , APP_VERSION_NAME , PROJECT_TYPE , PROTOCOL_VERSION ,
19
+ REGION_URLS , ROBOT_PROPERTIES , SSL_CERTIFICATE_THUMBPRINT , TENANT_ID ,
19
20
Language , Region
20
21
)
21
22
from .device import Device , DeviceProperties
@@ -32,7 +33,11 @@ class KarcherHome:
32
33
"""Main class to access Karcher Home Robots API"""
33
34
34
35
@classmethod
35
- async def create (cls , country : str = 'GB' , language : Language = Language .EN , session : aiohttp .ClientSession = None ):
36
+ async def create (
37
+ cls ,
38
+ country : str = 'GB' ,
39
+ language : Language = Language .EN ,
40
+ session : aiohttp .ClientSession = None ):
36
41
"""Create Karcher Home Robots API instance"""
37
42
38
43
self = KarcherHome ()
@@ -65,11 +70,13 @@ def __init__(self):
65
70
self ._mqtt = None
66
71
self ._device_props = {}
67
72
self ._wait_events = {}
73
+ self ._http = None
74
+ self ._http_external = False
68
75
69
76
def __del__ (self ):
70
77
"""Destructor"""
71
78
72
- self .close ()
79
+ asyncio . run ( self .close () )
73
80
74
81
async def close (self ):
75
82
"""Close underlying connections"""
@@ -133,8 +140,7 @@ async def _request(self, method: str, url: str, **kwargs) -> aiohttp.ClientRespo
133
140
headers ['nonce' ] = nonce
134
141
135
142
kwargs ['headers' ] = headers
136
- # TODO: Fix SSL
137
- kwargs ['verify_ssl' ] = False
143
+ kwargs ['ssl' ] = aiohttp .Fingerprint (SSL_CERTIFICATE_THUMBPRINT )
138
144
return await self ._http .request (method , self ._base_url + url , ** kwargs )
139
145
140
146
async def _download (self , url ) -> bytes :
0 commit comments