mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Move OneWireConfigEntry type definition (#135004)
This commit is contained in:
parent
42532e9695
commit
3b13c5bfdd
@ -4,16 +4,14 @@ import logging
|
|||||||
|
|
||||||
from pyownet import protocol
|
from pyownet import protocol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
|
|
||||||
from .const import DOMAIN, PLATFORMS
|
from .const import DOMAIN, PLATFORMS
|
||||||
from .onewirehub import CannotConnect, OneWireHub
|
from .onewirehub import CannotConnect, OneWireConfigEntry, OneWireHub
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
type OneWireConfigEntry = ConfigEntry[OneWireHub]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: OneWireConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: OneWireConfigEntry) -> bool:
|
||||||
|
@ -15,10 +15,9 @@ from homeassistant.const import EntityCategory
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import OneWireConfigEntry
|
|
||||||
from .const import DEVICE_KEYS_0_3, DEVICE_KEYS_0_7, DEVICE_KEYS_A_B, READ_MODE_BOOL
|
from .const import DEVICE_KEYS_0_3, DEVICE_KEYS_0_7, DEVICE_KEYS_A_B, READ_MODE_BOOL
|
||||||
from .entity import OneWireEntity, OneWireEntityDescription
|
from .entity import OneWireEntity, OneWireEntityDescription
|
||||||
from .onewirehub import OneWireHub
|
from .onewirehub import OneWireConfigEntry, OneWireHub
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
SCAN_INTERVAL = timedelta(seconds=30)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
@ -7,12 +7,7 @@ from typing import Any
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow
|
||||||
ConfigEntry,
|
|
||||||
ConfigFlow,
|
|
||||||
ConfigFlowResult,
|
|
||||||
OptionsFlow,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||||
@ -29,7 +24,7 @@ from .const import (
|
|||||||
OPTION_ENTRY_SENSOR_PRECISION,
|
OPTION_ENTRY_SENSOR_PRECISION,
|
||||||
PRECISION_MAPPING_FAMILY_28,
|
PRECISION_MAPPING_FAMILY_28,
|
||||||
)
|
)
|
||||||
from .onewirehub import CannotConnect, OneWireHub
|
from .onewirehub import CannotConnect, OneWireConfigEntry, OneWireHub
|
||||||
|
|
||||||
DATA_SCHEMA = vol.Schema(
|
DATA_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
@ -107,7 +102,7 @@ class OneWireFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
config_entry: ConfigEntry,
|
config_entry: OneWireConfigEntry,
|
||||||
) -> OnewireOptionsFlowHandler:
|
) -> OnewireOptionsFlowHandler:
|
||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return OnewireOptionsFlowHandler(config_entry)
|
return OnewireOptionsFlowHandler(config_entry)
|
||||||
@ -131,7 +126,7 @@ class OnewireOptionsFlowHandler(OptionsFlow):
|
|||||||
current_device: str
|
current_device: str
|
||||||
"""Friendly name of the currently selected device."""
|
"""Friendly name of the currently selected device."""
|
||||||
|
|
||||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
def __init__(self, config_entry: OneWireConfigEntry) -> None:
|
||||||
"""Initialize options flow."""
|
"""Initialize options flow."""
|
||||||
self.options = deepcopy(dict(config_entry.options))
|
self.options = deepcopy(dict(config_entry.options))
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from homeassistant.components.diagnostics import async_redact_data
|
|||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import OneWireConfigEntry
|
from .onewirehub import OneWireConfigEntry
|
||||||
|
|
||||||
TO_REDACT = {CONF_HOST}
|
TO_REDACT = {CONF_HOST}
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ DEVICE_MANUFACTURER = {
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
type OneWireConfigEntry = ConfigEntry[OneWireHub]
|
||||||
|
|
||||||
|
|
||||||
def _is_known_device(device_family: str, device_type: str | None) -> bool:
|
def _is_known_device(device_family: str, device_type: str | None) -> bool:
|
||||||
"""Check if device family/type is known to the library."""
|
"""Check if device family/type is known to the library."""
|
||||||
@ -70,7 +72,7 @@ class OneWireHub:
|
|||||||
except protocol.ConnError as exc:
|
except protocol.ConnError as exc:
|
||||||
raise CannotConnect from exc
|
raise CannotConnect from exc
|
||||||
|
|
||||||
async def initialize(self, config_entry: ConfigEntry) -> None:
|
async def initialize(self, config_entry: OneWireConfigEntry) -> None:
|
||||||
"""Initialize a config entry."""
|
"""Initialize a config entry."""
|
||||||
host = config_entry.data[CONF_HOST]
|
host = config_entry.data[CONF_HOST]
|
||||||
port = config_entry.data[CONF_PORT]
|
port = config_entry.data[CONF_PORT]
|
||||||
|
@ -29,7 +29,6 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import OneWireConfigEntry
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DEVICE_KEYS_0_3,
|
DEVICE_KEYS_0_3,
|
||||||
DEVICE_KEYS_A_B,
|
DEVICE_KEYS_A_B,
|
||||||
@ -40,7 +39,7 @@ from .const import (
|
|||||||
READ_MODE_INT,
|
READ_MODE_INT,
|
||||||
)
|
)
|
||||||
from .entity import OneWireEntity, OneWireEntityDescription
|
from .entity import OneWireEntity, OneWireEntityDescription
|
||||||
from .onewirehub import OneWireHub
|
from .onewirehub import OneWireConfigEntry, OneWireHub
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
SCAN_INTERVAL = timedelta(seconds=30)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
@ -12,10 +12,9 @@ from homeassistant.const import EntityCategory
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import OneWireConfigEntry
|
|
||||||
from .const import DEVICE_KEYS_0_3, DEVICE_KEYS_0_7, DEVICE_KEYS_A_B, READ_MODE_BOOL
|
from .const import DEVICE_KEYS_0_3, DEVICE_KEYS_0_7, DEVICE_KEYS_A_B, READ_MODE_BOOL
|
||||||
from .entity import OneWireEntity, OneWireEntityDescription
|
from .entity import OneWireEntity, OneWireEntityDescription
|
||||||
from .onewirehub import OneWireHub
|
from .onewirehub import OneWireConfigEntry, OneWireHub
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
SCAN_INTERVAL = timedelta(seconds=30)
|
SCAN_INTERVAL = timedelta(seconds=30)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user