Add OptionsFlow helper class (#82531)
* Add OptionsFlow helper classes * More integrations * Adjust SchemaOptionsFlowHandler * Use single class * Simplify access to options * Reduce PR * Make _options private * Add test
This commit is contained in:
@@ -5,6 +5,7 @@ import asyncio
|
||||
from collections import ChainMap
|
||||
from collections.abc import Callable, Coroutine, Generator, Iterable, Mapping
|
||||
from contextvars import ContextVar
|
||||
from copy import deepcopy
|
||||
from enum import Enum
|
||||
import functools
|
||||
import logging
|
||||
@@ -1672,11 +1673,20 @@ class OptionsFlowManager(data_entry_flow.FlowManager):
|
||||
|
||||
|
||||
class OptionsFlow(data_entry_flow.FlowHandler):
|
||||
"""Base class for config option flows."""
|
||||
"""Base class for config options flows."""
|
||||
|
||||
handler: str
|
||||
|
||||
|
||||
class OptionsFlowWithConfigEntry(OptionsFlow):
|
||||
"""Base class for options flows with config entry and options."""
|
||||
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
self.config_entry = config_entry
|
||||
self._options = deepcopy(dict(config_entry.options))
|
||||
|
||||
|
||||
class EntityRegistryDisabledHandler:
|
||||
"""Handler to handle when entities related to config entries updating disabled_by."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user