From f7193400d4a93b65df268c36df773b8798e2c948 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 4 Dec 2021 13:43:48 +0100 Subject: [PATCH] Use platform enum (6) [S] (#60944) --- .../components/samsungtv/__init__.py | 4 +-- .../components/screenlogic/__init__.py | 11 ++++++-- homeassistant/components/sense/__init__.py | 3 ++- homeassistant/components/sharkiq/const.py | 4 ++- homeassistant/components/shelly/__init__.py | 27 +++++++++++++------ homeassistant/components/sia/const.py | 7 ++--- .../components/simplisafe/__init__.py | 13 ++++----- homeassistant/components/sma/const.py | 3 ++- homeassistant/components/smappee/const.py | 4 ++- .../components/smart_meter_texas/__init__.py | 4 +-- homeassistant/components/smarthab/__init__.py | 4 +-- homeassistant/components/smartthings/const.py | 20 +++++++------- homeassistant/components/smarttub/__init__.py | 10 ++++++- homeassistant/components/smhi/__init__.py | 3 ++- homeassistant/components/sms/__init__.py | 4 +-- .../components/solaredge/__init__.py | 4 +-- homeassistant/components/solarlog/__init__.py | 4 +-- homeassistant/components/soma/__init__.py | 4 +-- homeassistant/components/somfy/__init__.py | 14 ++++++++-- .../components/somfy_mylink/const.py | 3 ++- homeassistant/components/sonarr/__init__.py | 3 ++- homeassistant/components/songpal/__init__.py | 4 +-- .../components/speedtestdotnet/const.py | 8 ++++-- homeassistant/components/spider/const.py | 3 ++- homeassistant/components/spotify/__init__.py | 10 ++++--- .../components/squeezebox/__init__.py | 4 +-- .../components/srp_energy/__init__.py | 4 +-- homeassistant/components/starline/const.py | 10 ++++++- .../components/stookalert/__init__.py | 4 +-- homeassistant/components/subaru/const.py | 3 ++- .../components/surepetcare/__init__.py | 3 ++- .../components/switchbot/__init__.py | 6 ++--- .../components/syncthing/__init__.py | 3 ++- homeassistant/components/syncthru/__init__.py | 6 ++--- .../components/synology_dsm/const.py | 3 ++- .../components/system_bridge/__init__.py | 3 ++- 36 files changed, 146 insertions(+), 81 deletions(-) diff --git a/homeassistant/components/samsungtv/__init__.py b/homeassistant/components/samsungtv/__init__.py index f55dc0639ba..4cbd661f113 100644 --- a/homeassistant/components/samsungtv/__init__.py +++ b/homeassistant/components/samsungtv/__init__.py @@ -9,7 +9,6 @@ import getmac import voluptuous as vol from homeassistant import config_entries -from homeassistant.components.media_player.const import DOMAIN as MP_DOMAIN from homeassistant.config_entries import ConfigEntry, ConfigEntryNotReady from homeassistant.const import ( CONF_HOST, @@ -19,6 +18,7 @@ from homeassistant.const import ( CONF_PORT, CONF_TOKEN, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.core import Event, HomeAssistant, callback import homeassistant.helpers.config_validation as cv @@ -50,7 +50,7 @@ def ensure_unique_hosts(value: dict[Any, Any]) -> dict[Any, Any]: return value -PLATFORMS = [MP_DOMAIN] +PLATFORMS = [Platform.MEDIA_PLAYER] CONFIG_SCHEMA = vol.Schema( { diff --git a/homeassistant/components/screenlogic/__init__.py b/homeassistant/components/screenlogic/__init__.py index 72c1f162552..e88475ea5bb 100644 --- a/homeassistant/components/screenlogic/__init__.py +++ b/homeassistant/components/screenlogic/__init__.py @@ -14,7 +14,7 @@ from screenlogicpy.const import ( ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL +from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr @@ -40,7 +40,14 @@ HEATER_COOLDOWN_DELAY = 6 # These seem to be constant across all controller models PRIMARY_CIRCUIT_IDS = [500, 505] # [Spa, Pool] -PLATFORMS = ["binary_sensor", "climate", "light", "number", "sensor", "switch"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.CLIMATE, + Platform.LIGHT, + Platform.NUMBER, + Platform.SENSOR, + Platform.SWITCH, +] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/sense/__init__.py b/homeassistant/components/sense/__init__.py index 92a4e29108c..4f5153c3d1e 100644 --- a/homeassistant/components/sense/__init__.py +++ b/homeassistant/components/sense/__init__.py @@ -11,6 +11,7 @@ from homeassistant.const import ( CONF_PASSWORD, CONF_TIMEOUT, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady @@ -33,7 +34,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["binary_sensor", "sensor"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR] class SenseDevicesData: diff --git a/homeassistant/components/sharkiq/const.py b/homeassistant/components/sharkiq/const.py index 8f4c56b65db..166e165bd70 100644 --- a/homeassistant/components/sharkiq/const.py +++ b/homeassistant/components/sharkiq/const.py @@ -2,10 +2,12 @@ from datetime import timedelta import logging +from homeassistant.const import Platform + _LOGGER = logging.getLogger(__package__) API_TIMEOUT = 20 -PLATFORMS = ["vacuum"] +PLATFORMS = [Platform.VACUUM] DOMAIN = "sharkiq" SHARK = "Shark" UPDATE_INTERVAL = timedelta(seconds=30) diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index 27f25211a96..8d78c148b51 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -19,6 +19,7 @@ from homeassistant.const import ( CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.core import Event, HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady @@ -66,15 +67,25 @@ from .utils import ( ) BLOCK_PLATFORMS: Final = [ - "binary_sensor", - "button", - "cover", - "light", - "sensor", - "switch", + Platform.BINARY_SENSOR, + Platform.BUTTON, + Platform.COVER, + Platform.LIGHT, + Platform.SENSOR, + Platform.SWITCH, +] +BLOCK_SLEEPING_PLATFORMS: Final = [ + Platform.BINARY_SENSOR, + Platform.CLIMATE, + Platform.SENSOR, +] +RPC_PLATFORMS: Final = [ + Platform.BINARY_SENSOR, + Platform.BUTTON, + Platform.LIGHT, + Platform.SENSOR, + Platform.SWITCH, ] -BLOCK_SLEEPING_PLATFORMS: Final = ["binary_sensor", "climate", "sensor"] -RPC_PLATFORMS: Final = ["binary_sensor", "button", "light", "sensor", "switch"] _LOGGER: Final = logging.getLogger(__name__) COAP_SCHEMA: Final = vol.Schema( diff --git a/homeassistant/components/sia/const.py b/homeassistant/components/sia/const.py index 711c070b1ee..183b3422f78 100644 --- a/homeassistant/components/sia/const.py +++ b/homeassistant/components/sia/const.py @@ -1,10 +1,7 @@ """Constants for the sia integration.""" -from homeassistant.components.alarm_control_panel import ( - DOMAIN as ALARM_CONTROL_PANEL_DOMAIN, -) -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN +from homeassistant.const import Platform -PLATFORMS = [ALARM_CONTROL_PANEL_DOMAIN, BINARY_SENSOR_DOMAIN] +PLATFORMS = [Platform.ALARM_CONTROL_PANEL, Platform.BINARY_SENSOR] DOMAIN = "sia" diff --git a/homeassistant/components/simplisafe/__init__.py b/homeassistant/components/simplisafe/__init__.py index 250b3e6c3b1..925f51cfe87 100644 --- a/homeassistant/components/simplisafe/__init__.py +++ b/homeassistant/components/simplisafe/__init__.py @@ -51,6 +51,7 @@ from homeassistant.const import ( CONF_CODE, CONF_TOKEN, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.core import CoreState, Event, HomeAssistant, ServiceCall, callback from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady @@ -118,12 +119,12 @@ DISPATCHER_TOPIC_WEBSOCKET_EVENT = "simplisafe_websocket_event_{0}" EVENT_SIMPLISAFE_EVENT = "SIMPLISAFE_EVENT" EVENT_SIMPLISAFE_NOTIFICATION = "SIMPLISAFE_NOTIFICATION" -PLATFORMS = ( - "alarm_control_panel", - "binary_sensor", - "lock", - "sensor", -) +PLATFORMS = [ + Platform.ALARM_CONTROL_PANEL, + Platform.BINARY_SENSOR, + Platform.LOCK, + Platform.SENSOR, +] VOLUME_MAP = { "high": Volume.HIGH, diff --git a/homeassistant/components/sma/const.py b/homeassistant/components/sma/const.py index 91173d95493..1cef8dd72d2 100644 --- a/homeassistant/components/sma/const.py +++ b/homeassistant/components/sma/const.py @@ -1,4 +1,5 @@ """Constants for the sma integration.""" +from homeassistant.const import Platform DOMAIN = "sma" @@ -8,7 +9,7 @@ PYSMA_REMOVE_LISTENER = "remove_listener" PYSMA_SENSORS = "pysma_sensors" PYSMA_DEVICE_INFO = "device_info" -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] CONF_CUSTOM = "custom" CONF_FACTOR = "factor" diff --git a/homeassistant/components/smappee/const.py b/homeassistant/components/smappee/const.py index 1abfc3a9b02..1e04a11f47a 100644 --- a/homeassistant/components/smappee/const.py +++ b/homeassistant/components/smappee/const.py @@ -2,6 +2,8 @@ from datetime import timedelta +from homeassistant.const import Platform + DOMAIN = "smappee" DATA_CLIENT = "smappee_data" @@ -12,7 +14,7 @@ CONF_TITLE = "title" ENV_CLOUD = "cloud" ENV_LOCAL = "local" -PLATFORMS = ["binary_sensor", "sensor", "switch"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH] SUPPORTED_LOCAL_DEVICES = ("Smappee1", "Smappee2", "Smappee50") diff --git a/homeassistant/components/smart_meter_texas/__init__.py b/homeassistant/components/smart_meter_texas/__init__.py index 0d636c7558f..b3ee4f807ba 100644 --- a/homeassistant/components/smart_meter_texas/__init__.py +++ b/homeassistant/components/smart_meter_texas/__init__.py @@ -10,7 +10,7 @@ from smart_meter_texas.exceptions import ( ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import aiohttp_client @@ -30,7 +30,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/smarthab/__init__.py b/homeassistant/components/smarthab/__init__.py index 7f8d5a38222..a4dc1a43f31 100644 --- a/homeassistant/components/smarthab/__init__.py +++ b/homeassistant/components/smarthab/__init__.py @@ -5,7 +5,7 @@ import pysmarthab import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import CONF_EMAIL, CONF_PASSWORD +from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady import homeassistant.helpers.config_validation as cv @@ -13,7 +13,7 @@ from homeassistant.helpers.typing import ConfigType DOMAIN = "smarthab" DATA_HUB = "hub" -PLATFORMS = ["light", "cover"] +PLATFORMS = [Platform.LIGHT, Platform.COVER] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/smartthings/const.py b/homeassistant/components/smartthings/const.py index a7aa9066dd2..1bd21cd73cd 100644 --- a/homeassistant/components/smartthings/const.py +++ b/homeassistant/components/smartthings/const.py @@ -2,6 +2,8 @@ from datetime import timedelta import re +from homeassistant.const import Platform + DOMAIN = "smartthings" APP_OAUTH_CLIENT_NAME = "Home Assistant" @@ -32,15 +34,15 @@ STORAGE_VERSION = 1 # Ordered 'specific to least-specific platform' in order for capabilities # to be drawn-down and represented by the most appropriate platform. PLATFORMS = [ - "climate", - "fan", - "light", - "lock", - "cover", - "switch", - "binary_sensor", - "sensor", - "scene", + Platform.CLIMATE, + Platform.FAN, + Platform.LIGHT, + Platform.LOCK, + Platform.COVER, + Platform.SWITCH, + Platform.BINARY_SENSOR, + Platform.SENSOR, + Platform.SCENE, ] IGNORED_CAPABILITIES = [ diff --git a/homeassistant/components/smarttub/__init__.py b/homeassistant/components/smarttub/__init__.py index 89ad9222e7a..4a8aa10a51d 100644 --- a/homeassistant/components/smarttub/__init__.py +++ b/homeassistant/components/smarttub/__init__.py @@ -1,8 +1,16 @@ """SmartTub integration.""" +from homeassistant.const import Platform + from .const import DOMAIN, SMARTTUB_CONTROLLER from .controller import SmartTubController -PLATFORMS = ["binary_sensor", "climate", "light", "sensor", "switch"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.CLIMATE, + Platform.LIGHT, + Platform.SENSOR, + Platform.SWITCH, +] async def async_setup_entry(hass, entry): diff --git a/homeassistant/components/smhi/__init__.py b/homeassistant/components/smhi/__init__.py index 418c9ac32f1..9625d15f92a 100644 --- a/homeassistant/components/smhi/__init__.py +++ b/homeassistant/components/smhi/__init__.py @@ -1,8 +1,9 @@ """Support for the Swedish weather institute weather service.""" from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant -PLATFORMS = ["weather"] +PLATFORMS = [Platform.WEATHER] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/sms/__init__.py b/homeassistant/components/sms/__init__.py index 358f608be58..f987507ca1f 100644 --- a/homeassistant/components/sms/__init__.py +++ b/homeassistant/components/sms/__init__.py @@ -3,14 +3,14 @@ import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import CONF_DEVICE +from homeassistant.const import CONF_DEVICE, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv from .const import DOMAIN, SMS_GATEWAY from .gateway import create_sms_gateway -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] CONFIG_SCHEMA = vol.Schema( {DOMAIN: vol.Schema({vol.Required(CONF_DEVICE): cv.isdevice})}, diff --git a/homeassistant/components/solaredge/__init__.py b/homeassistant/components/solaredge/__init__.py index cb56817fe87..8b83891f4e3 100644 --- a/homeassistant/components/solaredge/__init__.py +++ b/homeassistant/components/solaredge/__init__.py @@ -5,7 +5,7 @@ from requests.exceptions import ConnectTimeout, HTTPError from solaredge import Solaredge from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_API_KEY +from homeassistant.const import CONF_API_KEY, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady import homeassistant.helpers.config_validation as cv @@ -14,7 +14,7 @@ from .const import CONF_SITE_ID, DATA_API_CLIENT, DOMAIN, LOGGER CONFIG_SCHEMA = cv.deprecated(DOMAIN) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/solarlog/__init__.py b/homeassistant/components/solarlog/__init__.py index 190898abb27..c0457b729f5 100644 --- a/homeassistant/components/solarlog/__init__.py +++ b/homeassistant/components/solarlog/__init__.py @@ -7,7 +7,7 @@ from requests.exceptions import HTTPError, Timeout from sunwatcher.solarlog.solarlog import SolarLog from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST +from homeassistant.const import CONF_HOST, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import update_coordinator @@ -15,7 +15,7 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/soma/__init__.py b/homeassistant/components/soma/__init__.py index 532e6204ad9..65171070537 100644 --- a/homeassistant/components/soma/__init__.py +++ b/homeassistant/components/soma/__init__.py @@ -5,7 +5,7 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, CONF_PORT +from homeassistant.const import CONF_HOST, CONF_PORT, Platform from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import DeviceInfo, Entity @@ -26,7 +26,7 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -PLATFORMS = ["cover", "sensor"] +PLATFORMS = [Platform.COVER, Platform.SENSOR] async def async_setup(hass, config): diff --git a/homeassistant/components/somfy/__init__.py b/homeassistant/components/somfy/__init__.py index a6bd320edd6..c021d408288 100644 --- a/homeassistant/components/somfy/__init__.py +++ b/homeassistant/components/somfy/__init__.py @@ -6,7 +6,12 @@ from pymfy.api.devices.category import Category import voluptuous as vol from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, CONF_OPTIMISTIC +from homeassistant.const import ( + CONF_CLIENT_ID, + CONF_CLIENT_SECRET, + CONF_OPTIMISTIC, + Platform, +) from homeassistant.core import HomeAssistant from homeassistant.helpers import ( config_entry_oauth2_flow, @@ -39,7 +44,12 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -PLATFORMS = ["climate", "cover", "sensor", "switch"] +PLATFORMS = [ + Platform.CLIMATE, + Platform.COVER, + Platform.SENSOR, + Platform.SWITCH, +] async def async_setup(hass, config): diff --git a/homeassistant/components/somfy_mylink/const.py b/homeassistant/components/somfy_mylink/const.py index 4d4c4b58eae..bb9f2c5fd42 100644 --- a/homeassistant/components/somfy_mylink/const.py +++ b/homeassistant/components/somfy_mylink/const.py @@ -1,4 +1,5 @@ """Component for the Somfy MyLink device supporting the Synergy API.""" +from homeassistant.const import Platform CONF_SYSTEM_ID = "system_id" CONF_REVERSE = "reverse" @@ -12,6 +13,6 @@ DATA_SOMFY_MYLINK = "somfy_mylink_data" MYLINK_STATUS = "mylink_status" DOMAIN = "somfy_mylink" -PLATFORMS = ["cover"] +PLATFORMS = [Platform.COVER] MANUFACTURER = "Somfy" diff --git a/homeassistant/components/sonarr/__init__.py b/homeassistant/components/sonarr/__init__.py index b2cc13abc37..b574e68ae2f 100644 --- a/homeassistant/components/sonarr/__init__.py +++ b/homeassistant/components/sonarr/__init__.py @@ -12,6 +12,7 @@ from homeassistant.const import ( CONF_PORT, CONF_SSL, CONF_VERIFY_SSL, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady @@ -27,7 +28,7 @@ from .const import ( DOMAIN, ) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] SCAN_INTERVAL = timedelta(seconds=30) diff --git a/homeassistant/components/songpal/__init__.py b/homeassistant/components/songpal/__init__.py index eb93dafb123..e4b7b4a0c0b 100644 --- a/homeassistant/components/songpal/__init__.py +++ b/homeassistant/components/songpal/__init__.py @@ -3,7 +3,7 @@ import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import CONF_NAME +from homeassistant.const import CONF_NAME, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv from homeassistant.helpers.typing import ConfigType @@ -19,7 +19,7 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -PLATFORMS = ["media_player"] +PLATFORMS = [Platform.MEDIA_PLAYER] async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: diff --git a/homeassistant/components/speedtestdotnet/const.py b/homeassistant/components/speedtestdotnet/const.py index 323d17cdd84..caed1f408ba 100644 --- a/homeassistant/components/speedtestdotnet/const.py +++ b/homeassistant/components/speedtestdotnet/const.py @@ -9,7 +9,11 @@ from homeassistant.components.sensor import ( STATE_CLASS_MEASUREMENT, SensorEntityDescription, ) -from homeassistant.const import DATA_RATE_MEGABITS_PER_SECOND, TIME_MILLISECONDS +from homeassistant.const import ( + DATA_RATE_MEGABITS_PER_SECOND, + TIME_MILLISECONDS, + Platform, +) DOMAIN: Final = "speedtestdotnet" @@ -65,4 +69,4 @@ ATTRIBUTION: Final = "Data retrieved from Speedtest.net by Ookla" ICON: Final = "mdi:speedometer" -PLATFORMS: Final = ["sensor"] +PLATFORMS: Final = [Platform.SENSOR] diff --git a/homeassistant/components/spider/const.py b/homeassistant/components/spider/const.py index b8621262ed5..503625fedd2 100644 --- a/homeassistant/components/spider/const.py +++ b/homeassistant/components/spider/const.py @@ -1,6 +1,7 @@ """Constants for the Spider integration.""" +from homeassistant.const import Platform DOMAIN = "spider" DEFAULT_SCAN_INTERVAL = 300 -PLATFORMS = ["climate", "switch", "sensor"] +PLATFORMS = [Platform.CLIMATE, Platform.SWITCH, Platform.SENSOR] diff --git a/homeassistant/components/spotify/__init__.py b/homeassistant/components/spotify/__init__.py index 8af58edd4b4..d251c35c3ec 100644 --- a/homeassistant/components/spotify/__init__.py +++ b/homeassistant/components/spotify/__init__.py @@ -4,9 +4,13 @@ import aiohttp from spotipy import Spotify, SpotifyException import voluptuous as vol -from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ATTR_CREDENTIALS, CONF_CLIENT_ID, CONF_CLIENT_SECRET +from homeassistant.const import ( + ATTR_CREDENTIALS, + CONF_CLIENT_ID, + CONF_CLIENT_SECRET, + Platform, +) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv @@ -37,7 +41,7 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -PLATFORMS = [MEDIA_PLAYER_DOMAIN] +PLATFORMS = [Platform.MEDIA_PLAYER] async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: diff --git a/homeassistant/components/squeezebox/__init__.py b/homeassistant/components/squeezebox/__init__.py index 9bdc8ac9669..f7a20ba4aef 100644 --- a/homeassistant/components/squeezebox/__init__.py +++ b/homeassistant/components/squeezebox/__init__.py @@ -2,15 +2,15 @@ import logging -from homeassistant.components.media_player import DOMAIN as MP_DOMAIN from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from .const import DISCOVERY_TASK, DOMAIN, PLAYER_DISCOVERY_UNSUB _LOGGER = logging.getLogger(__name__) -PLATFORMS = [MP_DOMAIN] +PLATFORMS = [Platform.MEDIA_PLAYER] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/srp_energy/__init__.py b/homeassistant/components/srp_energy/__init__.py index 76d344415d6..ac9cf693c10 100644 --- a/homeassistant/components/srp_energy/__init__.py +++ b/homeassistant/components/srp_energy/__init__.py @@ -4,7 +4,7 @@ import logging from srpenergy.client import SrpEnergyClient from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady @@ -13,7 +13,7 @@ from .const import SRP_ENERGY_DOMAIN _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/starline/const.py b/homeassistant/components/starline/const.py index 488a5cb9e0f..be9656e70c9 100644 --- a/homeassistant/components/starline/const.py +++ b/homeassistant/components/starline/const.py @@ -1,10 +1,18 @@ """StarLine constants.""" import logging +from homeassistant.const import Platform + _LOGGER = logging.getLogger(__package__) DOMAIN = "starline" -PLATFORMS = ["device_tracker", "binary_sensor", "sensor", "lock", "switch"] +PLATFORMS = [ + Platform.DEVICE_TRACKER, + Platform.BINARY_SENSOR, + Platform.SENSOR, + Platform.LOCK, + Platform.SWITCH, +] CONF_APP_ID = "app_id" CONF_APP_SECRET = "app_secret" diff --git a/homeassistant/components/stookalert/__init__.py b/homeassistant/components/stookalert/__init__.py index 8dfc208d945..ad800c20e95 100644 --- a/homeassistant/components/stookalert/__init__.py +++ b/homeassistant/components/stookalert/__init__.py @@ -3,13 +3,13 @@ from __future__ import annotations import stookalert -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from .const import CONF_PROVINCE, DOMAIN -PLATFORMS = (BINARY_SENSOR_DOMAIN,) +PLATFORMS = [Platform.BINARY_SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/subaru/const.py b/homeassistant/components/subaru/const.py index cada29edd3a..596923cbc06 100644 --- a/homeassistant/components/subaru/const.py +++ b/homeassistant/components/subaru/const.py @@ -1,4 +1,5 @@ """Constants for the Subaru integration.""" +from homeassistant.const import Platform DOMAIN = "subaru" FETCH_INTERVAL = 300 @@ -31,7 +32,7 @@ API_GEN_2 = "g2" MANUFACTURER = "Subaru Corp." PLATFORMS = [ - "sensor", + Platform.SENSOR, ] ICONS = { diff --git a/homeassistant/components/surepetcare/__init__.py b/homeassistant/components/surepetcare/__init__.py index adf3d07f79e..78988afa1cf 100644 --- a/homeassistant/components/surepetcare/__init__.py +++ b/homeassistant/components/surepetcare/__init__.py @@ -16,6 +16,7 @@ from homeassistant.const import ( CONF_SCAN_INTERVAL, CONF_TOKEN, CONF_USERNAME, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady @@ -41,7 +42,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["binary_sensor", "lock", "sensor"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.LOCK, Platform.SENSOR] SCAN_INTERVAL = timedelta(minutes=3) CONFIG_SCHEMA = vol.Schema( diff --git a/homeassistant/components/switchbot/__init__.py b/homeassistant/components/switchbot/__init__.py index 421f6cab866..0059d655767 100644 --- a/homeassistant/components/switchbot/__init__.py +++ b/homeassistant/components/switchbot/__init__.py @@ -4,7 +4,7 @@ from asyncio import Lock import switchbot # pylint: disable=import-error from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_SENSOR_TYPE +from homeassistant.const import CONF_SENSOR_TYPE, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady @@ -27,8 +27,8 @@ from .const import ( from .coordinator import SwitchbotDataUpdateCoordinator PLATFORMS_BY_TYPE = { - ATTR_BOT: ["switch", "sensor"], - ATTR_CURTAIN: ["cover", "binary_sensor", "sensor"], + ATTR_BOT: [Platform.SWITCH, Platform.SENSOR], + ATTR_CURTAIN: [Platform.COVER, Platform.BINARY_SENSOR, Platform.SENSOR], } diff --git a/homeassistant/components/syncthing/__init__.py b/homeassistant/components/syncthing/__init__.py index d7cc671465a..ac9d5d32e92 100644 --- a/homeassistant/components/syncthing/__init__.py +++ b/homeassistant/components/syncthing/__init__.py @@ -10,6 +10,7 @@ from homeassistant.const import ( CONF_URL, CONF_VERIFY_SSL, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady @@ -23,7 +24,7 @@ from .const import ( SERVER_UNAVAILABLE, ) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/syncthru/__init__.py b/homeassistant/components/syncthru/__init__.py index da45350836c..a891bc50831 100644 --- a/homeassistant/components/syncthru/__init__.py +++ b/homeassistant/components/syncthru/__init__.py @@ -7,10 +7,8 @@ import logging import async_timeout from pysyncthru import ConnectionMode, SyncThru, SyncThruAPINotSupported -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_URL +from homeassistant.const import CONF_URL, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import aiohttp_client, device_registry as dr from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -19,7 +17,7 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -PLATFORMS = [BINARY_SENSOR_DOMAIN, SENSOR_DOMAIN] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/synology_dsm/const.py b/homeassistant/components/synology_dsm/const.py index b1afe37b765..55f45fddabd 100644 --- a/homeassistant/components/synology_dsm/const.py +++ b/homeassistant/components/synology_dsm/const.py @@ -30,11 +30,12 @@ from homeassistant.const import ( ENTITY_CATEGORY_DIAGNOSTIC, PERCENTAGE, TEMP_CELSIUS, + Platform, ) from homeassistant.helpers.entity import EntityDescription DOMAIN = "synology_dsm" -PLATFORMS = ["binary_sensor", "camera", "sensor", "switch"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.CAMERA, Platform.SENSOR, Platform.SWITCH] COORDINATOR_CAMERAS = "coordinator_cameras" COORDINATOR_CENTRAL = "coordinator_central" COORDINATOR_SWITCHES = "coordinator_switches" diff --git a/homeassistant/components/system_bridge/__init__.py b/homeassistant/components/system_bridge/__init__.py index cf50368c34c..53b0ead9728 100644 --- a/homeassistant/components/system_bridge/__init__.py +++ b/homeassistant/components/system_bridge/__init__.py @@ -20,6 +20,7 @@ from homeassistant.const import ( CONF_HOST, CONF_PATH, CONF_PORT, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ( @@ -40,7 +41,7 @@ from .coordinator import SystemBridgeDataUpdateCoordinator _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["binary_sensor", "sensor"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR] CONF_ARGUMENTS = "arguments" CONF_BRIDGE = "bridge"