From 4a84a8caa95b6b13e8744790d31ed81e311f3f63 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:22:49 +0200 Subject: [PATCH] Use Platform enum (#76967) --- homeassistant/components/bayesian/__init__.py | 4 +++- homeassistant/components/google/__init__.py | 3 ++- homeassistant/components/ping/const.py | 4 +++- homeassistant/components/sabnzbd/__init__.py | 3 ++- .../components/slimproto/__init__.py | 4 ++-- homeassistant/components/sonos/const.py | 20 ++++++++----------- homeassistant/components/vulcan/__init__.py | 3 ++- homeassistant/components/webostv/const.py | 4 +++- homeassistant/components/ws66i/__init__.py | 4 ++-- 9 files changed, 27 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/bayesian/__init__.py b/homeassistant/components/bayesian/__init__.py index 485592dc5e4..e6f865b5656 100644 --- a/homeassistant/components/bayesian/__init__.py +++ b/homeassistant/components/bayesian/__init__.py @@ -1,4 +1,6 @@ """The bayesian component.""" +from homeassistant.const import Platform + DOMAIN = "bayesian" -PLATFORMS = ["binary_sensor"] +PLATFORMS = [Platform.BINARY_SENSOR] diff --git a/homeassistant/components/google/__init__.py b/homeassistant/components/google/__init__.py index 4b72aaa77ad..c983868b167 100644 --- a/homeassistant/components/google/__init__.py +++ b/homeassistant/components/google/__init__.py @@ -29,6 +29,7 @@ from homeassistant.const import ( CONF_ENTITIES, CONF_NAME, CONF_OFFSET, + Platform, ) from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.exceptions import ( @@ -88,7 +89,7 @@ YAML_DEVICES = f"{DOMAIN}_calendars.yaml" TOKEN_FILE = f".{DOMAIN}.token" -PLATFORMS = ["calendar"] +PLATFORMS = [Platform.CALENDAR] CONFIG_SCHEMA = vol.Schema( diff --git a/homeassistant/components/ping/const.py b/homeassistant/components/ping/const.py index 9ca99db2419..1a77c62fa5c 100644 --- a/homeassistant/components/ping/const.py +++ b/homeassistant/components/ping/const.py @@ -1,5 +1,7 @@ """Tracks devices by sending a ICMP echo request (ping).""" +from homeassistant.const import Platform + # The ping binary and icmplib timeouts are not the same # timeout. ping is an overall timeout, icmplib is the # time since the data was sent. @@ -13,6 +15,6 @@ ICMP_TIMEOUT = 1 PING_ATTEMPTS_COUNT = 3 DOMAIN = "ping" -PLATFORMS = ["binary_sensor"] +PLATFORMS = [Platform.BINARY_SENSOR] PING_PRIVS = "ping_privs" diff --git a/homeassistant/components/sabnzbd/__init__.py b/homeassistant/components/sabnzbd/__init__.py index aca8d1cd9f4..fe9a64f3d6b 100644 --- a/homeassistant/components/sabnzbd/__init__.py +++ b/homeassistant/components/sabnzbd/__init__.py @@ -16,6 +16,7 @@ from homeassistant.const import ( CONF_PORT, CONF_SENSORS, CONF_SSL, + Platform, ) from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError @@ -47,7 +48,7 @@ from .const import ( from .sab import get_client from .sensor import OLD_SENSOR_KEYS -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] _LOGGER = logging.getLogger(__name__) SERVICES = ( diff --git a/homeassistant/components/slimproto/__init__.py b/homeassistant/components/slimproto/__init__.py index a96ff7ae925..c22349bb2f2 100644 --- a/homeassistant/components/slimproto/__init__.py +++ b/homeassistant/components/slimproto/__init__.py @@ -4,13 +4,13 @@ from __future__ import annotations from aioslimproto import SlimServer from homeassistant.config_entries import ConfigEntry -from homeassistant.const import EVENT_HOMEASSISTANT_STOP +from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform from homeassistant.core import Event, HomeAssistant from homeassistant.helpers import device_registry as dr from .const import DOMAIN -PLATFORMS = ["media_player"] +PLATFORMS = [Platform.MEDIA_PLAYER] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/sonos/const.py b/homeassistant/components/sonos/const.py index e6a5225e30e..4c10bb113c7 100644 --- a/homeassistant/components/sonos/const.py +++ b/homeassistant/components/sonos/const.py @@ -1,8 +1,6 @@ """Const for Sonos.""" import datetime -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN -from homeassistant.components.media_player import DOMAIN as MP_DOMAIN from homeassistant.components.media_player.const import ( MEDIA_CLASS_ALBUM, MEDIA_CLASS_ARTIST, @@ -19,22 +17,20 @@ from homeassistant.components.media_player.const import ( MEDIA_TYPE_PLAYLIST, MEDIA_TYPE_TRACK, ) -from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN -from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN +from homeassistant.const import Platform UPNP_ST = "urn:schemas-upnp-org:device:ZonePlayer:1" DOMAIN = "sonos" DATA_SONOS = "sonos_media_player" DATA_SONOS_DISCOVERY_MANAGER = "sonos_discovery_manager" -PLATFORMS = { - BINARY_SENSOR_DOMAIN, - MP_DOMAIN, - NUMBER_DOMAIN, - SENSOR_DOMAIN, - SWITCH_DOMAIN, -} +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.MEDIA_PLAYER, + Platform.NUMBER, + Platform.SENSOR, + Platform.SWITCH, +] SONOS_ARTIST = "artists" SONOS_ALBUM = "albums" diff --git a/homeassistant/components/vulcan/__init__.py b/homeassistant/components/vulcan/__init__.py index 8e66075935b..0bfd09d590d 100644 --- a/homeassistant/components/vulcan/__init__.py +++ b/homeassistant/components/vulcan/__init__.py @@ -4,13 +4,14 @@ from aiohttp import ClientConnectorError from vulcan import Account, Keystore, UnauthorizedCertificateException, Vulcan from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DOMAIN -PLATFORMS = ["calendar"] +PLATFORMS = [Platform.CALENDAR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/webostv/const.py b/homeassistant/components/webostv/const.py index f471ca7340d..830c0a4134a 100644 --- a/homeassistant/components/webostv/const.py +++ b/homeassistant/components/webostv/const.py @@ -4,8 +4,10 @@ import asyncio from aiowebostv import WebOsTvCommandError from websockets.exceptions import ConnectionClosed, ConnectionClosedOK +from homeassistant.const import Platform + DOMAIN = "webostv" -PLATFORMS = ["media_player"] +PLATFORMS = [Platform.MEDIA_PLAYER] DATA_CONFIG_ENTRY = "config_entry" DATA_HASS_CONFIG = "hass_config" DEFAULT_NAME = "LG webOS Smart TV" diff --git a/homeassistant/components/ws66i/__init__.py b/homeassistant/components/ws66i/__init__.py index 0b40ce84816..cffedc2f684 100644 --- a/homeassistant/components/ws66i/__init__.py +++ b/homeassistant/components/ws66i/__init__.py @@ -6,7 +6,7 @@ import logging from pyws66i import WS66i, get_ws66i from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_IP_ADDRESS, EVENT_HOMEASSISTANT_STOP +from homeassistant.const import CONF_IP_ADDRESS, EVENT_HOMEASSISTANT_STOP, Platform from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady @@ -16,7 +16,7 @@ from .models import SourceRep, Ws66iData _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["media_player"] +PLATFORMS = [Platform.MEDIA_PLAYER] @callback