Clean up Ondilo config flow (#116931)
parent
16d86e5d4c
commit
1559562c26
|
@ -5,7 +5,8 @@ from homeassistant.const import Platform
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from . import api, config_flow
|
||||
from .api import OndiloClient
|
||||
from .config_flow import OndiloIcoOAuth2FlowHandler
|
||||
from .const import DOMAIN
|
||||
from .coordinator import OndiloIcoCoordinator
|
||||
from .oauth_impl import OndiloOauth2Implementation
|
||||
|
@ -16,7 +17,7 @@ PLATFORMS = [Platform.SENSOR]
|
|||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Ondilo ICO from a config entry."""
|
||||
|
||||
config_flow.OAuth2FlowHandler.async_register_implementation(
|
||||
OndiloIcoOAuth2FlowHandler.async_register_implementation(
|
||||
hass,
|
||||
OndiloOauth2Implementation(hass),
|
||||
)
|
||||
|
@ -27,9 +28,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
)
|
||||
)
|
||||
|
||||
coordinator = OndiloIcoCoordinator(
|
||||
hass, api.OndiloClient(hass, entry, implementation)
|
||||
)
|
||||
coordinator = OndiloIcoCoordinator(hass, OndiloClient(hass, entry, implementation))
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
"""Config flow for Ondilo ICO."""
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
from homeassistant.config_entries import ConfigFlowResult
|
||||
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler
|
||||
|
||||
from .const import DOMAIN
|
||||
from .oauth_impl import OndiloOauth2Implementation
|
||||
|
||||
|
||||
class OAuth2FlowHandler(
|
||||
config_entry_oauth2_flow.AbstractOAuth2FlowHandler, domain=DOMAIN
|
||||
):
|
||||
class OndiloIcoOAuth2FlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
|
||||
"""Config flow to handle Ondilo ICO OAuth2 authentication."""
|
||||
|
||||
DOMAIN = DOMAIN
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
await self.async_set_unique_id(DOMAIN)
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ def mock_ondilo_client(
|
|||
"""Mock a Homeassistant Ondilo client."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.ondilo_ico.api.OndiloClient",
|
||||
"homeassistant.components.ondilo_ico.OndiloClient",
|
||||
autospec=True,
|
||||
) as mock_ondilo,
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue