mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Move OneWire PLATFORM constant back to init (#135172)
This commit is contained in:
parent
13527768cc
commit
15e785b974
@ -4,15 +4,22 @@ import logging
|
||||
|
||||
from pyownet import protocol
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from .const import DOMAIN, PLATFORMS
|
||||
from .const import DOMAIN
|
||||
from .onewirehub import CannotConnect, OneWireConfigEntry, OneWireHub
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
_PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: OneWireConfigEntry) -> bool:
|
||||
"""Set up a 1-Wire proxy for a config entry."""
|
||||
@ -27,7 +34,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: OneWireConfigEntry) -> b
|
||||
|
||||
entry.runtime_data = onewire_hub
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
await hass.config_entries.async_forward_entry_setups(entry, _PLATFORMS)
|
||||
|
||||
entry.async_on_unload(entry.add_update_listener(options_update_listener))
|
||||
|
||||
@ -48,7 +55,7 @@ async def async_unload_entry(
|
||||
hass: HomeAssistant, config_entry: OneWireConfigEntry
|
||||
) -> bool:
|
||||
"""Unload a config entry."""
|
||||
return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
|
||||
return await hass.config_entries.async_unload_platforms(config_entry, _PLATFORMS)
|
||||
|
||||
|
||||
async def options_update_listener(
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DEFAULT_HOST = "localhost"
|
||||
DEFAULT_PORT = 4304
|
||||
|
||||
@ -54,9 +52,3 @@ MANUFACTURER_EDS = "Embedded Data Systems"
|
||||
READ_MODE_BOOL = "bool"
|
||||
READ_MODE_FLOAT = "float"
|
||||
READ_MODE_INT = "int"
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
|
@ -18,7 +18,7 @@ from tests.common import MockConfigEntry
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms() -> Generator[None]:
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.onewire.PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||
with patch("homeassistant.components.onewire._PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||
yield
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ from tests.typing import ClientSessionGenerator
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms() -> Generator[None]:
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.onewire.PLATFORMS", [Platform.SWITCH]):
|
||||
with patch("homeassistant.components.onewire._PLATFORMS", [Platform.SWITCH]):
|
||||
yield
|
||||
|
||||
|
||||
|
@ -80,7 +80,7 @@ async def test_update_options(
|
||||
assert owproxy.call_count == 2
|
||||
|
||||
|
||||
@patch("homeassistant.components.onewire.PLATFORMS", [Platform.SENSOR])
|
||||
@patch("homeassistant.components.onewire._PLATFORMS", [Platform.SENSOR])
|
||||
async def test_registry_cleanup(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
|
@ -22,7 +22,7 @@ from tests.common import MockConfigEntry
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms() -> Generator[None]:
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.onewire.PLATFORMS", [Platform.SENSOR]):
|
||||
with patch("homeassistant.components.onewire._PLATFORMS", [Platform.SENSOR]):
|
||||
yield
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ from tests.common import MockConfigEntry
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms() -> Generator[None]:
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.onewire.PLATFORMS", [Platform.SWITCH]):
|
||||
with patch("homeassistant.components.onewire._PLATFORMS", [Platform.SWITCH]):
|
||||
yield
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user