1
mirror of https://github.com/home-assistant/core synced 2024-10-04 07:58:43 +02:00
ha-core/homeassistant/components/fyta/config_flow.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

101 lines
3.1 KiB
Python
Raw Normal View History

Add Fyta integration (#110816) * Initial commit for fyta integration * Update __init__.py Delete BinarySensor for first PR * Update __init__.py Rewind wrongful deletion of comma * Delete homeassistant/components/fyta/binary_sensor.py Delete binary_sensor for first pr of integration * Update manifest.json Updated requirement to new version of fyta_cli 0.2.1, where bug in import of modules has been resolved. * Update requirements_test_all.txt adjust to updated manifest * Update requirements_all.txt adjust to updated manifest * Update test_config_flow.py * Update config_flow.py update file to correct error with _entry attribute * Fyta integration - update initial PR based on review in initial PR #110816 (#2) * adjustments to pass test for config_flow * backport of changes in intitial PR to dev * update text_config_flow * changes based on review in initial PR #110816 * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Adjustments based on PR-commet of Feb 19 (#3) * add test for config_flow.validate_input * update based on pr review * update based on pr review * further refinings based on PR review * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py Update tests based on PR comment * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add handling and test for duplicate entry * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py parametrize test for exceptions * Update config_flow.py Move _async_abort_entries_match, add arguments * Update coordinator.py * Update typing in coordinator.py * Update coordinator.py update typing * Update coordinator.py corrected typo * Update coordinator.py * Update entity.py * Update sensor.py * Update icons.json * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py * Update test_config_flow.py * Update config_flow.py (change FlowResult to ConfigFlowResult) * Update config_flow.py * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update coordinator.py * Update config_flow.py (typing FlowResult -> ConfigFlowResult) * Update config_flow.py * Aktualisieren von config_flow.py * remove coordinator entities * Update strings.json remove plant_number * Update icons.json remove plant_number * Update manifest.json Update requirement to latest fyta_cli version * Update requirements_all.txt * Update requirements_test_all.txt * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move test-helpers into conftest.py, adjust import of coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Robert Resch <robert@resch.dev>
2024-03-15 18:13:35 +01:00
"""Config flow for FYTA integration."""
Add Fyta integration (#110816) * Initial commit for fyta integration * Update __init__.py Delete BinarySensor for first PR * Update __init__.py Rewind wrongful deletion of comma * Delete homeassistant/components/fyta/binary_sensor.py Delete binary_sensor for first pr of integration * Update manifest.json Updated requirement to new version of fyta_cli 0.2.1, where bug in import of modules has been resolved. * Update requirements_test_all.txt adjust to updated manifest * Update requirements_all.txt adjust to updated manifest * Update test_config_flow.py * Update config_flow.py update file to correct error with _entry attribute * Fyta integration - update initial PR based on review in initial PR #110816 (#2) * adjustments to pass test for config_flow * backport of changes in intitial PR to dev * update text_config_flow * changes based on review in initial PR #110816 * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Adjustments based on PR-commet of Feb 19 (#3) * add test for config_flow.validate_input * update based on pr review * update based on pr review * further refinings based on PR review * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py Update tests based on PR comment * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add handling and test for duplicate entry * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py parametrize test for exceptions * Update config_flow.py Move _async_abort_entries_match, add arguments * Update coordinator.py * Update typing in coordinator.py * Update coordinator.py update typing * Update coordinator.py corrected typo * Update coordinator.py * Update entity.py * Update sensor.py * Update icons.json * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py * Update test_config_flow.py * Update config_flow.py (change FlowResult to ConfigFlowResult) * Update config_flow.py * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update coordinator.py * Update config_flow.py (typing FlowResult -> ConfigFlowResult) * Update config_flow.py * Aktualisieren von config_flow.py * remove coordinator entities * Update strings.json remove plant_number * Update icons.json remove plant_number * Update manifest.json Update requirement to latest fyta_cli version * Update requirements_all.txt * Update requirements_test_all.txt * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move test-helpers into conftest.py, adjust import of coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Robert Resch <robert@resch.dev>
2024-03-15 18:13:35 +01:00
from __future__ import annotations
from collections.abc import Mapping
Add Fyta integration (#110816) * Initial commit for fyta integration * Update __init__.py Delete BinarySensor for first PR * Update __init__.py Rewind wrongful deletion of comma * Delete homeassistant/components/fyta/binary_sensor.py Delete binary_sensor for first pr of integration * Update manifest.json Updated requirement to new version of fyta_cli 0.2.1, where bug in import of modules has been resolved. * Update requirements_test_all.txt adjust to updated manifest * Update requirements_all.txt adjust to updated manifest * Update test_config_flow.py * Update config_flow.py update file to correct error with _entry attribute * Fyta integration - update initial PR based on review in initial PR #110816 (#2) * adjustments to pass test for config_flow * backport of changes in intitial PR to dev * update text_config_flow * changes based on review in initial PR #110816 * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Adjustments based on PR-commet of Feb 19 (#3) * add test for config_flow.validate_input * update based on pr review * update based on pr review * further refinings based on PR review * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py Update tests based on PR comment * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add handling and test for duplicate entry * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py parametrize test for exceptions * Update config_flow.py Move _async_abort_entries_match, add arguments * Update coordinator.py * Update typing in coordinator.py * Update coordinator.py update typing * Update coordinator.py corrected typo * Update coordinator.py * Update entity.py * Update sensor.py * Update icons.json * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py * Update test_config_flow.py * Update config_flow.py (change FlowResult to ConfigFlowResult) * Update config_flow.py * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update coordinator.py * Update config_flow.py (typing FlowResult -> ConfigFlowResult) * Update config_flow.py * Aktualisieren von config_flow.py * remove coordinator entities * Update strings.json remove plant_number * Update icons.json remove plant_number * Update manifest.json Update requirement to latest fyta_cli version * Update requirements_all.txt * Update requirements_test_all.txt * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move test-helpers into conftest.py, adjust import of coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Robert Resch <robert@resch.dev>
2024-03-15 18:13:35 +01:00
import logging
from typing import Any
from fyta_cli.fyta_connector import FytaConnector
from fyta_cli.fyta_exceptions import (
FytaAuthentificationError,
FytaConnectionError,
FytaPasswordError,
)
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
Add Fyta integration (#110816) * Initial commit for fyta integration * Update __init__.py Delete BinarySensor for first PR * Update __init__.py Rewind wrongful deletion of comma * Delete homeassistant/components/fyta/binary_sensor.py Delete binary_sensor for first pr of integration * Update manifest.json Updated requirement to new version of fyta_cli 0.2.1, where bug in import of modules has been resolved. * Update requirements_test_all.txt adjust to updated manifest * Update requirements_all.txt adjust to updated manifest * Update test_config_flow.py * Update config_flow.py update file to correct error with _entry attribute * Fyta integration - update initial PR based on review in initial PR #110816 (#2) * adjustments to pass test for config_flow * backport of changes in intitial PR to dev * update text_config_flow * changes based on review in initial PR #110816 * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Adjustments based on PR-commet of Feb 19 (#3) * add test for config_flow.validate_input * update based on pr review * update based on pr review * further refinings based on PR review * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py Update tests based on PR comment * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add handling and test for duplicate entry * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py parametrize test for exceptions * Update config_flow.py Move _async_abort_entries_match, add arguments * Update coordinator.py * Update typing in coordinator.py * Update coordinator.py update typing * Update coordinator.py corrected typo * Update coordinator.py * Update entity.py * Update sensor.py * Update icons.json * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py * Update test_config_flow.py * Update config_flow.py (change FlowResult to ConfigFlowResult) * Update config_flow.py * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update coordinator.py * Update config_flow.py (typing FlowResult -> ConfigFlowResult) * Update config_flow.py * Aktualisieren von config_flow.py * remove coordinator entities * Update strings.json remove plant_number * Update icons.json remove plant_number * Update manifest.json Update requirement to latest fyta_cli version * Update requirements_all.txt * Update requirements_test_all.txt * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move test-helpers into conftest.py, adjust import of coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Robert Resch <robert@resch.dev>
2024-03-15 18:13:35 +01:00
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
DATA_SCHEMA = vol.Schema(
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
)
class FytaConfigFlow(ConfigFlow, domain=DOMAIN):
Add Fyta integration (#110816) * Initial commit for fyta integration * Update __init__.py Delete BinarySensor for first PR * Update __init__.py Rewind wrongful deletion of comma * Delete homeassistant/components/fyta/binary_sensor.py Delete binary_sensor for first pr of integration * Update manifest.json Updated requirement to new version of fyta_cli 0.2.1, where bug in import of modules has been resolved. * Update requirements_test_all.txt adjust to updated manifest * Update requirements_all.txt adjust to updated manifest * Update test_config_flow.py * Update config_flow.py update file to correct error with _entry attribute * Fyta integration - update initial PR based on review in initial PR #110816 (#2) * adjustments to pass test for config_flow * backport of changes in intitial PR to dev * update text_config_flow * changes based on review in initial PR #110816 * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Adjustments based on PR-commet of Feb 19 (#3) * add test for config_flow.validate_input * update based on pr review * update based on pr review * further refinings based on PR review * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py Update tests based on PR comment * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add handling and test for duplicate entry * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py parametrize test for exceptions * Update config_flow.py Move _async_abort_entries_match, add arguments * Update coordinator.py * Update typing in coordinator.py * Update coordinator.py update typing * Update coordinator.py corrected typo * Update coordinator.py * Update entity.py * Update sensor.py * Update icons.json * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py * Update test_config_flow.py * Update config_flow.py (change FlowResult to ConfigFlowResult) * Update config_flow.py * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update coordinator.py * Update config_flow.py (typing FlowResult -> ConfigFlowResult) * Update config_flow.py * Aktualisieren von config_flow.py * remove coordinator entities * Update strings.json remove plant_number * Update icons.json remove plant_number * Update manifest.json Update requirement to latest fyta_cli version * Update requirements_all.txt * Update requirements_test_all.txt * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move test-helpers into conftest.py, adjust import of coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Robert Resch <robert@resch.dev>
2024-03-15 18:13:35 +01:00
"""Handle a config flow for Fyta."""
VERSION = 1
_entry: ConfigEntry | None = None
async def async_auth(self, user_input: Mapping[str, Any]) -> dict[str, str]:
"""Reusable Auth Helper."""
fyta = FytaConnector(user_input[CONF_USERNAME], user_input[CONF_PASSWORD])
try:
await fyta.login()
except FytaConnectionError:
return {"base": "cannot_connect"}
except FytaAuthentificationError:
return {"base": "invalid_auth"}
except FytaPasswordError:
return {"base": "invalid_auth", CONF_PASSWORD: "password_error"}
except Exception as e: # pylint: disable=broad-except
_LOGGER.error(e)
return {"base": "unknown"}
finally:
await fyta.client.close()
return {}
Add Fyta integration (#110816) * Initial commit for fyta integration * Update __init__.py Delete BinarySensor for first PR * Update __init__.py Rewind wrongful deletion of comma * Delete homeassistant/components/fyta/binary_sensor.py Delete binary_sensor for first pr of integration * Update manifest.json Updated requirement to new version of fyta_cli 0.2.1, where bug in import of modules has been resolved. * Update requirements_test_all.txt adjust to updated manifest * Update requirements_all.txt adjust to updated manifest * Update test_config_flow.py * Update config_flow.py update file to correct error with _entry attribute * Fyta integration - update initial PR based on review in initial PR #110816 (#2) * adjustments to pass test for config_flow * backport of changes in intitial PR to dev * update text_config_flow * changes based on review in initial PR #110816 * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Adjustments based on PR-commet of Feb 19 (#3) * add test for config_flow.validate_input * update based on pr review * update based on pr review * further refinings based on PR review * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py Update tests based on PR comment * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add handling and test for duplicate entry * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py parametrize test for exceptions * Update config_flow.py Move _async_abort_entries_match, add arguments * Update coordinator.py * Update typing in coordinator.py * Update coordinator.py update typing * Update coordinator.py corrected typo * Update coordinator.py * Update entity.py * Update sensor.py * Update icons.json * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py * Update test_config_flow.py * Update config_flow.py (change FlowResult to ConfigFlowResult) * Update config_flow.py * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update coordinator.py * Update config_flow.py (typing FlowResult -> ConfigFlowResult) * Update config_flow.py * Aktualisieren von config_flow.py * remove coordinator entities * Update strings.json remove plant_number * Update icons.json remove plant_number * Update manifest.json Update requirement to latest fyta_cli version * Update requirements_all.txt * Update requirements_test_all.txt * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move test-helpers into conftest.py, adjust import of coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Robert Resch <robert@resch.dev>
2024-03-15 18:13:35 +01:00
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
Add Fyta integration (#110816) * Initial commit for fyta integration * Update __init__.py Delete BinarySensor for first PR * Update __init__.py Rewind wrongful deletion of comma * Delete homeassistant/components/fyta/binary_sensor.py Delete binary_sensor for first pr of integration * Update manifest.json Updated requirement to new version of fyta_cli 0.2.1, where bug in import of modules has been resolved. * Update requirements_test_all.txt adjust to updated manifest * Update requirements_all.txt adjust to updated manifest * Update test_config_flow.py * Update config_flow.py update file to correct error with _entry attribute * Fyta integration - update initial PR based on review in initial PR #110816 (#2) * adjustments to pass test for config_flow * backport of changes in intitial PR to dev * update text_config_flow * changes based on review in initial PR #110816 * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Adjustments based on PR-commet of Feb 19 (#3) * add test for config_flow.validate_input * update based on pr review * update based on pr review * further refinings based on PR review * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py Update tests based on PR comment * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add handling and test for duplicate entry * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py parametrize test for exceptions * Update config_flow.py Move _async_abort_entries_match, add arguments * Update coordinator.py * Update typing in coordinator.py * Update coordinator.py update typing * Update coordinator.py corrected typo * Update coordinator.py * Update entity.py * Update sensor.py * Update icons.json * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py * Update test_config_flow.py * Update config_flow.py (change FlowResult to ConfigFlowResult) * Update config_flow.py * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update coordinator.py * Update config_flow.py (typing FlowResult -> ConfigFlowResult) * Update config_flow.py * Aktualisieren von config_flow.py * remove coordinator entities * Update strings.json remove plant_number * Update icons.json remove plant_number * Update manifest.json Update requirement to latest fyta_cli version * Update requirements_all.txt * Update requirements_test_all.txt * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move test-helpers into conftest.py, adjust import of coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Robert Resch <robert@resch.dev>
2024-03-15 18:13:35 +01:00
"""Handle the initial step."""
errors = {}
if user_input:
self._async_abort_entries_match({CONF_USERNAME: user_input[CONF_USERNAME]})
if not (errors := await self.async_auth(user_input)):
Add Fyta integration (#110816) * Initial commit for fyta integration * Update __init__.py Delete BinarySensor for first PR * Update __init__.py Rewind wrongful deletion of comma * Delete homeassistant/components/fyta/binary_sensor.py Delete binary_sensor for first pr of integration * Update manifest.json Updated requirement to new version of fyta_cli 0.2.1, where bug in import of modules has been resolved. * Update requirements_test_all.txt adjust to updated manifest * Update requirements_all.txt adjust to updated manifest * Update test_config_flow.py * Update config_flow.py update file to correct error with _entry attribute * Fyta integration - update initial PR based on review in initial PR #110816 (#2) * adjustments to pass test for config_flow * backport of changes in intitial PR to dev * update text_config_flow * changes based on review in initial PR #110816 * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Update homeassistant/components/fyta/manifest.json Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> * Adjustments based on PR-commet of Feb 19 (#3) * add test for config_flow.validate_input * update based on pr review * update based on pr review * further refinings based on PR review * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py Update tests based on PR comment * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * add handling and test for duplicate entry * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update test_config_flow.py parametrize test for exceptions * Update config_flow.py Move _async_abort_entries_match, add arguments * Update coordinator.py * Update typing in coordinator.py * Update coordinator.py update typing * Update coordinator.py corrected typo * Update coordinator.py * Update entity.py * Update sensor.py * Update icons.json * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py * Update test_config_flow.py * Update config_flow.py (change FlowResult to ConfigFlowResult) * Update config_flow.py * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update coordinator.py * Update config_flow.py (typing FlowResult -> ConfigFlowResult) * Update config_flow.py * Aktualisieren von config_flow.py * remove coordinator entities * Update strings.json remove plant_number * Update icons.json remove plant_number * Update manifest.json Update requirement to latest fyta_cli version * Update requirements_all.txt * Update requirements_test_all.txt * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/sensor.py * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/fyta/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update tests/components/fyta/test_config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move test-helpers into conftest.py, adjust import of coordinator.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com> Co-authored-by: Robert Resch <robert@resch.dev>
2024-03-15 18:13:35 +01:00
return self.async_create_entry(
title=user_input[CONF_USERNAME], data=user_input
)
return self.async_show_form(
step_id="user", data_schema=DATA_SCHEMA, errors=errors
)
async def async_step_reauth(
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle flow upon an API authentication error."""
self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle reauthorization flow."""
errors = {}
assert self._entry is not None
if user_input and not (errors := await self.async_auth(user_input)):
return self.async_update_reload_and_abort(
self._entry, data={**self._entry.data, **user_input}
)
data_schema = self.add_suggested_values_to_schema(
DATA_SCHEMA,
{CONF_USERNAME: self._entry.data[CONF_USERNAME], **(user_input or {})},
)
return self.async_show_form(
step_id="reauth_confirm",
data_schema=data_schema,
errors=errors,
)