Move OneWire PLATFORM constant back to init (#135172)

This commit is contained in:
epenet 2025-01-09 11:22:08 +01:00 committed by GitHub
parent 13527768cc
commit 15e785b974
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 15 additions and 16 deletions

View File

@ -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(

View File

@ -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,
]

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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