6
6
from aiohttp import ClientSession
7
7
from aiohttp .client_exceptions import ClientError
8
8
9
- from .device import MyQDevice
10
9
from .errors import MyQError , RequestError , UnsupportedBrandError
11
10
12
11
_LOGGER = logging .getLogger (__name__ )
@@ -109,18 +108,18 @@ async def _request(
109
108
type_exception , endpoint , err ))
110
109
111
110
_LOGGER .warning ('%s for %s; retrying: %s' ,
112
- type_exception , endpoint , err )
111
+ type_exception , endpoint , err )
113
112
await asyncio .sleep (5 )
114
113
115
114
_LOGGER .debug ('Request to %s completed' , url )
116
115
117
- async def _update_device_state (self ):
116
+ async def _update_device_state (self ) -> None :
118
117
async with self ._update_lock :
119
118
if datetime .utcnow () - self ._last_update > \
120
119
MIN_TIME_BETWEEN_UPDATES :
121
120
await self ._get_device_states ()
122
121
123
- async def _get_device_states (self ):
122
+ async def _get_device_states (self ) -> bool :
124
123
_LOGGER .debug ('Retrieving new device states' )
125
124
try :
126
125
devices_resp = await self ._request ('get' , DEVICE_LIST_ENDPOINT )
@@ -136,8 +135,9 @@ async def _get_device_states(self):
136
135
137
136
self ._store_device_states (devices_resp .get ('Devices' , []))
138
137
_LOGGER .debug ('New device states retrieved' )
138
+ return True
139
139
140
- def _store_device_states (self , devices ) :
140
+ def _store_device_states (self , devices : dict ) -> None :
141
141
for device in self ._devices :
142
142
myq_device = next (
143
143
(element for element in devices
@@ -168,6 +168,8 @@ async def authenticate(self, username: str, password: str) -> None:
168
168
169
169
async def get_devices (self , covers_only : bool = True ) -> list :
170
170
"""Get a list of all devices associated with the account."""
171
+ from .device import MyQDevice
172
+
171
173
_LOGGER .debug ('Retrieving list of devices' )
172
174
devices_resp = await self ._request ('get' , DEVICE_LIST_ENDPOINT )
173
175
# print(json.dumps(devices_resp, indent=4))
0 commit comments