|
6 | 6 | import voluptuous as vol |
7 | 7 |
|
8 | 8 | from homeassistant import config_entries |
| 9 | +from homeassistant.config_entries import ConfigFlowResult |
9 | 10 | from homeassistant.core import callback |
10 | | -from homeassistant.data_entry_flow import FlowResult |
11 | | -from homeassistant.helpers import selector |
| 11 | +from homeassistant.helpers import entity_registry as er, selector |
12 | 12 |
|
13 | 13 | from .options import EffektGuardOptionsFlow |
14 | 14 | from .const import ( |
@@ -36,11 +36,16 @@ class EffektGuardConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): |
36 | 36 |
|
37 | 37 | VERSION = 1 |
38 | 38 |
|
39 | | - def __init__(self): |
| 39 | + def __init__(self) -> None: |
40 | 40 | """Initialize config flow.""" |
41 | 41 | self._data: dict[str, Any] = {} |
42 | 42 |
|
43 | | - async def async_step_user(self, user_input: dict[str, Any] | None = None) -> FlowResult: |
| 43 | + def is_matching(self, other_flow: "EffektGuardConfigFlow") -> bool: |
| 44 | + """Return True if this flow matches another flow in progress.""" |
| 45 | + # Only one EffektGuard instance is supported |
| 46 | + return True |
| 47 | + |
| 48 | + async def async_step_user(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult: |
44 | 49 | """Handle the initial step - NIBE integration selection.""" |
45 | 50 | errors = {} |
46 | 51 |
|
@@ -87,7 +92,7 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Flo |
87 | 92 | }, |
88 | 93 | ) |
89 | 94 |
|
90 | | - async def async_step_gespot(self, user_input: dict[str, Any] | None = None) -> FlowResult: |
| 95 | + async def async_step_gespot(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult: |
91 | 96 | """Configure spot price integration.""" |
92 | 97 | errors = {} |
93 | 98 |
|
@@ -154,7 +159,7 @@ async def async_step_gespot(self, user_input: dict[str, Any] | None = None) -> F |
154 | 159 | }, |
155 | 160 | ) |
156 | 161 |
|
157 | | - async def async_step_model(self, user_input: dict[str, Any] | None = None) -> FlowResult: |
| 162 | + async def async_step_model(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult: |
158 | 163 | """Handle heat pump model selection.""" |
159 | 164 | errors = {} |
160 | 165 |
|
@@ -185,7 +190,9 @@ async def async_step_model(self, user_input: dict[str, Any] | None = None) -> Fl |
185 | 190 | }, |
186 | 191 | ) |
187 | 192 |
|
188 | | - async def async_step_optional(self, user_input: dict[str, Any] | None = None) -> FlowResult: |
| 193 | + async def async_step_optional( |
| 194 | + self, user_input: dict[str, Any] | None = None |
| 195 | + ) -> ConfigFlowResult: |
189 | 196 | """Configure optional features.""" |
190 | 197 | if user_input is not None: |
191 | 198 | # Store optional settings |
@@ -219,7 +226,7 @@ async def async_step_optional(self, user_input: dict[str, Any] | None = None) -> |
219 | 226 |
|
220 | 227 | async def async_step_optional_sensors( |
221 | 228 | self, user_input: dict[str, Any] | None = None |
222 | | - ) -> FlowResult: |
| 229 | + ) -> ConfigFlowResult: |
223 | 230 | """Configure optional sensors (degree minutes, power meter, extra temp sensors).""" |
224 | 231 | if user_input is not None: |
225 | 232 | # Store optional sensor settings |
@@ -346,8 +353,6 @@ def _discover_nibe_entities(self) -> list[str]: |
346 | 353 | - OR number.* entities with 'offset' in name AND 'nibe' in entity_id |
347 | 354 | - Excludes entities with translation errors |
348 | 355 | """ |
349 | | - from homeassistant.helpers import entity_registry as er |
350 | | - |
351 | 356 | entities = [] |
352 | 357 | ent_reg = er.async_get(self.hass) |
353 | 358 |
|
@@ -528,8 +533,6 @@ def _discover_temp_lux_entities(self) -> list[str]: |
528 | 533 | - switch.*50004* (NIBE parameter ID) |
529 | 534 | - Related to NIBE/MyUplink integration |
530 | 535 | """ |
531 | | - from homeassistant.helpers import entity_registry as er |
532 | | - |
533 | 536 | entities = [] |
534 | 537 | ent_reg = er.async_get(self.hass) |
535 | 538 |
|
@@ -566,7 +569,9 @@ def _discover_temp_lux_entities(self) -> list[str]: |
566 | 569 |
|
567 | 570 | return entities |
568 | 571 |
|
569 | | - async def async_step_reconfigure(self, user_input: dict[str, Any] | None = None) -> FlowResult: |
| 572 | + async def async_step_reconfigure( |
| 573 | + self, user_input: dict[str, Any] | None = None |
| 574 | + ) -> ConfigFlowResult: |
570 | 575 | """Handle reconfiguration of entity selections. |
571 | 576 |
|
572 | 577 | Allows users to change entity selections (weather, power sensor, etc.) |
|
0 commit comments