mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add typings to OVO Energy integration (#75944)
Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
f0e6f45e43
commit
26c419705e
@ -1,10 +1,16 @@
|
|||||||
"""Config flow to configure the OVO Energy integration."""
|
"""Config flow to configure the OVO Energy integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Mapping
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from ovoenergy.ovoenergy import OVOEnergy
|
from ovoenergy.ovoenergy import OVOEnergy
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
|
from homeassistant.data_entry_flow import FlowResult
|
||||||
|
|
||||||
from .const import CONF_ACCOUNT, DOMAIN
|
from .const import CONF_ACCOUNT, DOMAIN
|
||||||
|
|
||||||
@ -28,7 +34,10 @@ class OVOEnergyFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self.username = None
|
self.username = None
|
||||||
self.account = None
|
self.account = None
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None):
|
async def async_step_user(
|
||||||
|
self,
|
||||||
|
user_input: Mapping[str, Any] | None = None,
|
||||||
|
) -> FlowResult:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
errors = {}
|
errors = {}
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
@ -61,7 +70,10 @@ class OVOEnergyFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
step_id="user", data_schema=USER_SCHEMA, errors=errors
|
step_id="user", data_schema=USER_SCHEMA, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_reauth(self, user_input):
|
async def async_step_reauth(
|
||||||
|
self,
|
||||||
|
user_input: Mapping[str, Any],
|
||||||
|
) -> FlowResult:
|
||||||
"""Handle configuration by re-auth."""
|
"""Handle configuration by re-auth."""
|
||||||
errors = {}
|
errors = {}
|
||||||
|
|
||||||
@ -84,15 +96,15 @@ class OVOEnergyFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
else:
|
else:
|
||||||
if authenticated:
|
if authenticated:
|
||||||
entry = await self.async_set_unique_id(self.username)
|
entry = await self.async_set_unique_id(self.username)
|
||||||
self.hass.config_entries.async_update_entry(
|
if entry:
|
||||||
entry,
|
self.hass.config_entries.async_update_entry(
|
||||||
data={
|
entry,
|
||||||
CONF_USERNAME: self.username,
|
data={
|
||||||
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
CONF_USERNAME: self.username,
|
||||||
CONF_ACCOUNT: self.account,
|
CONF_PASSWORD: user_input[CONF_PASSWORD],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return self.async_abort(reason="reauth_successful")
|
return self.async_abort(reason="reauth_successful")
|
||||||
|
|
||||||
errors["base"] = "authorization_error"
|
errors["base"] = "authorization_error"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user