@@ -134,13 +134,22 @@ async def _get_config(
134
134
self ._token_manager ._clear_access_token ()
135
135
self ._user_info = await self .auth .get (url , schema = SCH_USER_ACCOUNT ) # type: ignore[assignment]
136
136
137
- assert self ._user_info is not None # mypy
137
+ assert self ._user_info is not None # mypy
138
138
139
139
if self ._user_locs is None :
140
- url = f"location/installationInfo?userId={ self ._user_info [SZ_USER_ID ]} &includeTemperatureControlSystems=True"
141
- self ._user_locs = await self .auth .get (url , schema = SCH_USER_LOCATIONS ) # type: ignore[assignment]
140
+ try :
141
+ user_id = self ._user_info [SZ_USER_ID ]
142
+ except (KeyError , TypeError ) as err :
143
+ raise exc .BadApiResponseError (
144
+ f"User info is invalid: { err !r} , user_info={ self ._user_info } "
145
+ ) from err
142
146
143
- assert self ._user_locs is not None # mypy
147
+ self ._user_locs = await self .auth .get (
148
+ f"location/installationInfo?userId={ user_id } &includeTemperatureControlSystems=True" ,
149
+ schema = SCH_USER_LOCATIONS ,
150
+ ) # type: ignore[assignment]
151
+
152
+ assert self ._user_locs is not None # mypy
144
153
145
154
if self ._locations is None :
146
155
self ._locations = []
@@ -166,7 +175,7 @@ def user_account(self) -> EvoUsrConfigResponseT:
166
175
167
176
if not self ._user_info :
168
177
raise exc .InvalidConfigError (
169
- f" { self } : The account information is not (yet) available"
178
+ " The account information is not (yet) available"
170
179
)
171
180
172
181
return self ._user_info
@@ -177,7 +186,7 @@ def locations(self) -> list[Location]:
177
186
178
187
if not self ._user_locs :
179
188
raise exc .InvalidConfigError (
180
- f" { self } : The installation information is not (yet) available"
189
+ " The installation information is not (yet) available"
181
190
)
182
191
183
192
return self ._locations # type: ignore[return-value]
@@ -188,7 +197,7 @@ def location_by_id(self) -> dict[str, Location]:
188
197
189
198
if not self ._user_locs :
190
199
raise exc .InvalidConfigError (
191
- f" { self } : The installation information is not (yet) available"
200
+ " The installation information is not (yet) available"
192
201
)
193
202
194
203
return self ._location_by_id # type: ignore[return-value]
@@ -203,17 +212,17 @@ def tcs(self) -> ControlSystem:
203
212
204
213
if not (locs := self .locations ) or len (locs ) != 1 :
205
214
raise exc .NoSingleTcsError (
206
- f" { self } : There is not a single location (only) for this account"
215
+ " There is not a single location (only) for this account"
207
216
)
208
217
209
218
if not (gwys := locs [0 ].gateways ) or len (gwys ) != 1 :
210
219
raise exc .NoSingleTcsError (
211
- f" { self } : There is not a single gateway (only) for this account/location"
220
+ " There is not a single gateway (only) for this account/location"
212
221
)
213
222
214
223
if not (tcss := gwys [0 ].systems ) or len (tcss ) != 1 :
215
224
raise exc .NoSingleTcsError (
216
- f" { self } : There is not a single TCS (only) for this account/location/gateway"
225
+ " There is not a single TCS (only) for this account/location/gateway"
217
226
)
218
227
219
228
return tcss [0 ]
0 commit comments