mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +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 homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from .const import DOMAIN, PLATFORMS
|
||||
from .onewirehub import CannotConnect, OneWireHub
|
||||
from .onewirehub import CannotConnect, OneWireConfigEntry, OneWireHub
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
type OneWireConfigEntry = ConfigEntry[OneWireHub]
|
||||
|
||||
|
||||
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.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 .entity import OneWireEntity, OneWireEntityDescription
|
||||
from .onewirehub import OneWireHub
|
||||
from .onewirehub import OneWireConfigEntry, OneWireHub
|
||||
|
||||
PARALLEL_UPDATES = 1
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
@ -7,12 +7,7 @@ from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import (
|
||||
ConfigEntry,
|
||||
ConfigFlow,
|
||||
ConfigFlowResult,
|
||||
OptionsFlow,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
@ -29,7 +24,7 @@ from .const import (
|
||||
OPTION_ENTRY_SENSOR_PRECISION,
|
||||
PRECISION_MAPPING_FAMILY_28,
|
||||
)
|
||||
from .onewirehub import CannotConnect, OneWireHub
|
||||
from .onewirehub import CannotConnect, OneWireConfigEntry, OneWireHub
|
||||
|
||||
DATA_SCHEMA = vol.Schema(
|
||||
{
|
||||
@ -107,7 +102,7 @@ class OneWireFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: ConfigEntry,
|
||||
config_entry: OneWireConfigEntry,
|
||||
) -> OnewireOptionsFlowHandler:
|
||||
"""Get the options flow for this handler."""
|
||||
return OnewireOptionsFlowHandler(config_entry)
|
||||
@ -131,7 +126,7 @@ class OnewireOptionsFlowHandler(OptionsFlow):
|
||||
current_device: str
|
||||
"""Friendly name of the currently selected device."""
|
||||
|
||||
def __init__(self, config_entry: ConfigEntry) -> None:
|
||||
def __init__(self, config_entry: OneWireConfigEntry) -> None:
|
||||
"""Initialize options flow."""
|
||||
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.core import HomeAssistant
|
||||
|
||||
from . import OneWireConfigEntry
|
||||
from .onewirehub import OneWireConfigEntry
|
||||
|
||||
TO_REDACT = {CONF_HOST}
|
||||
|
||||
|
@ -44,6 +44,8 @@ DEVICE_MANUFACTURER = {
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
type OneWireConfigEntry = ConfigEntry[OneWireHub]
|
||||
|
||||
|
||||
def _is_known_device(device_family: str, device_type: str | None) -> bool:
|
||||
"""Check if device family/type is known to the library."""
|
||||
@ -70,7 +72,7 @@ class OneWireHub:
|
||||
except protocol.ConnError as 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."""
|
||||
host = config_entry.data[CONF_HOST]
|
||||
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.typing import StateType
|
||||
|
||||
from . import OneWireConfigEntry
|
||||
from .const import (
|
||||
DEVICE_KEYS_0_3,
|
||||
DEVICE_KEYS_A_B,
|
||||
@ -40,7 +39,7 @@ from .const import (
|
||||
READ_MODE_INT,
|
||||
)
|
||||
from .entity import OneWireEntity, OneWireEntityDescription
|
||||
from .onewirehub import OneWireHub
|
||||
from .onewirehub import OneWireConfigEntry, OneWireHub
|
||||
|
||||
PARALLEL_UPDATES = 1
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
@ -12,10 +12,9 @@ from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
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 .entity import OneWireEntity, OneWireEntityDescription
|
||||
from .onewirehub import OneWireHub
|
||||
from .onewirehub import OneWireConfigEntry, OneWireHub
|
||||
|
||||
PARALLEL_UPDATES = 1
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
Loading…
x
Reference in New Issue
Block a user