6
6
from pyairnow .errors import AirNowError , EmptyResponseError , InvalidKeyError
7
7
import voluptuous as vol
8
8
9
- from homeassistant import config_entries , core , data_entry_flow , exceptions
9
+ from homeassistant import core
10
+ from homeassistant .config_entries import (
11
+ ConfigEntry ,
12
+ ConfigFlow ,
13
+ OptionsFlow ,
14
+ OptionsFlowWithConfigEntry ,
15
+ )
10
16
from homeassistant .const import CONF_API_KEY , CONF_LATITUDE , CONF_LONGITUDE , CONF_RADIUS
17
+ from homeassistant .core import HomeAssistant
18
+ from homeassistant .data_entry_flow import FlowResult
19
+ from homeassistant .exceptions import HomeAssistantError
11
20
from homeassistant .helpers .aiohttp_client import async_get_clientsession
12
21
import homeassistant .helpers .config_validation as cv
13
22
16
25
_LOGGER = logging .getLogger (__name__ )
17
26
18
27
19
- async def validate_input (hass : core . HomeAssistant , data ) :
28
+ async def validate_input (hass : HomeAssistant , data : dict [ str , Any ]) -> bool :
20
29
"""Validate the user input allows us to connect.
21
30
22
31
Data has the keys from DATA_SCHEMA with values provided by the user.
@@ -46,12 +55,14 @@ async def validate_input(hass: core.HomeAssistant, data):
46
55
return True
47
56
48
57
49
- class ConfigFlow ( config_entries . ConfigFlow , domain = DOMAIN ):
58
+ class AirNowConfigFlow ( ConfigFlow , domain = DOMAIN ):
50
59
"""Handle a config flow for AirNow."""
51
60
52
61
VERSION = 2
53
62
54
- async def async_step_user (self , user_input = None ):
63
+ async def async_step_user (
64
+ self , user_input : dict [str , Any ] | None = None
65
+ ) -> FlowResult :
55
66
"""Handle the initial step."""
56
67
errors = {}
57
68
if user_input is not None :
@@ -108,18 +119,18 @@ async def async_step_user(self, user_input=None):
108
119
@staticmethod
109
120
@core .callback
110
121
def async_get_options_flow (
111
- config_entry : config_entries . ConfigEntry ,
112
- ) -> config_entries . OptionsFlow :
122
+ config_entry : ConfigEntry ,
123
+ ) -> OptionsFlow :
113
124
"""Return the options flow."""
114
- return OptionsFlowHandler (config_entry )
125
+ return AirNowOptionsFlowHandler (config_entry )
115
126
116
127
117
- class OptionsFlowHandler ( config_entries . OptionsFlowWithConfigEntry ):
128
+ class AirNowOptionsFlowHandler ( OptionsFlowWithConfigEntry ):
118
129
"""Handle an options flow for AirNow."""
119
130
120
131
async def async_step_init (
121
132
self , user_input : dict [str , Any ] | None = None
122
- ) -> data_entry_flow . FlowResult :
133
+ ) -> FlowResult :
123
134
"""Manage the options."""
124
135
if user_input is not None :
125
136
return self .async_create_entry (data = user_input )
@@ -141,13 +152,13 @@ async def async_step_init(
141
152
)
142
153
143
154
144
- class CannotConnect (exceptions . HomeAssistantError ):
155
+ class CannotConnect (HomeAssistantError ):
145
156
"""Error to indicate we cannot connect."""
146
157
147
158
148
- class InvalidAuth (exceptions . HomeAssistantError ):
159
+ class InvalidAuth (HomeAssistantError ):
149
160
"""Error to indicate there is invalid auth."""
150
161
151
162
152
- class InvalidLocation (exceptions . HomeAssistantError ):
163
+ class InvalidLocation (HomeAssistantError ):
153
164
"""Error to indicate the location is invalid."""
0 commit comments