2
2
from __future__ import annotations
3
3
4
4
import asyncio
5
+ from copy import deepcopy
5
6
from datetime import timedelta
6
7
import time
7
8
from typing import Any
8
- from copy import deepcopy
9
9
10
10
from aiohttp import ClientSession
11
11
from homeassistant import config_entries
@@ -103,7 +103,7 @@ def __init__(self) -> None:
103
103
self .start_time : float = ConfigFlow .init_start_time
104
104
105
105
async def async_step_user (
106
- self , user_input : dict [str , Any ] | None = None
106
+ self , user_input : dict [str , Any ] | None = None
107
107
) -> FlowResult :
108
108
"""Handle the initial step."""
109
109
errors : dict [str , Any ] = {}
@@ -145,7 +145,7 @@ async def async_step_user(
145
145
)
146
146
147
147
async def async_step_devices (
148
- self , user_input : dict [str , Any ] | None = None
148
+ self , user_input : dict [str , Any ] | None = None
149
149
) -> FlowResult :
150
150
"""Step for setup devices."""
151
151
errors : dict [str , Any ] = {}
@@ -203,14 +203,17 @@ async def async_step_devices(
203
203
else :
204
204
errors ["base" ] = "unknown"
205
205
_LOGGER .exception ("Unexpected exception: %s" , err )
206
+ break
206
207
except RateLimitError :
207
208
errors ["base" ] = "rate_limit"
209
+ break
208
210
except InvalidDeviceError :
209
211
errors ["base" ] = "invalid_device"
210
212
_LOGGER .warning ("Invalid device: %s" , dev .id )
211
213
except Exception as err : # pylint: disable=broad-except
212
214
_LOGGER .exception ("Unexpected exception: %s" , err )
213
215
errors ["base" ] = "unknown"
216
+ break
214
217
else :
215
218
devices_list [dev .id ] = str (dev )
216
219
@@ -232,7 +235,7 @@ def _generate_channel_types(self) -> list[str]:
232
235
return [x .title () for x in DEVICE_TYPE_STRING_MAP .values ()]
233
236
234
237
async def async_step_channel (
235
- self , user_input : dict [str , Any ] | None = None
238
+ self , user_input : dict [str , Any ] | None = None
236
239
) -> FlowResult :
237
240
"""Step for setup channels."""
238
241
@@ -294,7 +297,7 @@ async def async_step_finish(self) -> FlowResult:
294
297
@staticmethod
295
298
@callback
296
299
def async_get_options_flow (
297
- config_entry : config_entries .ConfigEntry ,
300
+ config_entry : config_entries .ConfigEntry ,
298
301
) -> OptionsFlowHandler :
299
302
"""Get the options flow for this handler."""
300
303
return OptionsFlowHandler (config_entry )
@@ -327,7 +330,7 @@ def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
327
330
self .data = dict (self .config_entry .data )
328
331
329
332
async def async_step_init (
330
- self , user_input : dict [str , Any ] | None = None
333
+ self , user_input : dict [str , Any ] | None = None
331
334
) -> FlowResult :
332
335
"""Handle options flow."""
333
336
@@ -343,9 +346,7 @@ async def async_step_init(
343
346
try :
344
347
tmp = deepcopy (self .data )
345
348
tmp [CONF_HOST ] = user_input [CONF_HOST ]
346
- await validate_login (
347
- tmp , async_get_clientsession (self .hass )
348
- )
349
+ await validate_login (tmp , async_get_clientsession (self .hass ))
349
350
except CannotConnect :
350
351
errors ["base" ] = "cannot_connect"
351
352
except InvalidAuth :
0 commit comments