Skip to content

Commit

Permalink
Move OneWireConfigEntry type definition (#135004)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Jan 7, 2025
1 parent 42532e9 commit 3b13c5b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 20 deletions.
4 changes: 1 addition & 3 deletions homeassistant/components/onewire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@

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:
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/onewire/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
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)
Expand Down
13 changes: 4 additions & 9 deletions homeassistant/components/onewire/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@

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
Expand All @@ -29,7 +24,7 @@
OPTION_ENTRY_SENSOR_PRECISION,
PRECISION_MAPPING_FAMILY_28,
)
from .onewirehub import CannotConnect, OneWireHub
from .onewirehub import CannotConnect, OneWireConfigEntry, OneWireHub

DATA_SCHEMA = vol.Schema(
{
Expand Down Expand Up @@ -107,7 +102,7 @@ async def async_step_reconfigure(
@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)
Expand All @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/onewire/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant

from . import OneWireConfigEntry
from .onewirehub import OneWireConfigEntry

TO_REDACT = {CONF_HOST}

Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/onewire/onewirehub.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

_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."""
Expand All @@ -70,7 +72,7 @@ async def connect(self, host: str, port: int) -> None:
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]
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/onewire/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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,
Expand All @@ -40,7 +39,7 @@
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)
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/onewire/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
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)
Expand Down

0 comments on commit 3b13c5b

Please sign in to comment.