Use platform enum (6) [S] (#60944)

This commit is contained in:
Marc Mueller 2021-12-04 13:43:48 +01:00 committed by GitHub
parent ffb4b4df96
commit f7193400d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 146 additions and 81 deletions

View file

@ -9,7 +9,6 @@ import getmac
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries 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.config_entries import ConfigEntry, ConfigEntryNotReady
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
@ -19,6 +18,7 @@ from homeassistant.const import (
CONF_PORT, CONF_PORT,
CONF_TOKEN, CONF_TOKEN,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform,
) )
from homeassistant.core import Event, HomeAssistant, callback from homeassistant.core import Event, HomeAssistant, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -50,7 +50,7 @@ def ensure_unique_hosts(value: dict[Any, Any]) -> dict[Any, Any]:
return value return value
PLATFORMS = [MP_DOMAIN] PLATFORMS = [Platform.MEDIA_PLAYER]
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema(
{ {

View file

@ -14,7 +14,7 @@ from screenlogicpy.const import (
) )
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr 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 # These seem to be constant across all controller models
PRIMARY_CIRCUIT_IDS = [500, 505] # [Spa, Pool] 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: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -11,6 +11,7 @@ from homeassistant.const import (
CONF_PASSWORD, CONF_PASSWORD,
CONF_TIMEOUT, CONF_TIMEOUT,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
@ -33,7 +34,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["binary_sensor", "sensor"] PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
class SenseDevicesData: class SenseDevicesData:

View file

@ -2,10 +2,12 @@
from datetime import timedelta from datetime import timedelta
import logging import logging
from homeassistant.const import Platform
_LOGGER = logging.getLogger(__package__) _LOGGER = logging.getLogger(__package__)
API_TIMEOUT = 20 API_TIMEOUT = 20
PLATFORMS = ["vacuum"] PLATFORMS = [Platform.VACUUM]
DOMAIN = "sharkiq" DOMAIN = "sharkiq"
SHARK = "Shark" SHARK = "Shark"
UPDATE_INTERVAL = timedelta(seconds=30) UPDATE_INTERVAL = timedelta(seconds=30)

View file

@ -19,6 +19,7 @@ from homeassistant.const import (
CONF_PASSWORD, CONF_PASSWORD,
CONF_USERNAME, CONF_USERNAME,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform,
) )
from homeassistant.core import Event, HomeAssistant, callback from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
@ -66,15 +67,25 @@ from .utils import (
) )
BLOCK_PLATFORMS: Final = [ BLOCK_PLATFORMS: Final = [
"binary_sensor", Platform.BINARY_SENSOR,
"button", Platform.BUTTON,
"cover", Platform.COVER,
"light", Platform.LIGHT,
"sensor", Platform.SENSOR,
"switch", 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__) _LOGGER: Final = logging.getLogger(__name__)
COAP_SCHEMA: Final = vol.Schema( COAP_SCHEMA: Final = vol.Schema(

View file

@ -1,10 +1,7 @@
"""Constants for the sia integration.""" """Constants for the sia integration."""
from homeassistant.components.alarm_control_panel import ( from homeassistant.const import Platform
DOMAIN as ALARM_CONTROL_PANEL_DOMAIN,
)
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
PLATFORMS = [ALARM_CONTROL_PANEL_DOMAIN, BINARY_SENSOR_DOMAIN] PLATFORMS = [Platform.ALARM_CONTROL_PANEL, Platform.BINARY_SENSOR]
DOMAIN = "sia" DOMAIN = "sia"

View file

@ -51,6 +51,7 @@ from homeassistant.const import (
CONF_CODE, CONF_CODE,
CONF_TOKEN, CONF_TOKEN,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform,
) )
from homeassistant.core import CoreState, Event, HomeAssistant, ServiceCall, callback from homeassistant.core import CoreState, Event, HomeAssistant, ServiceCall, callback
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady 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_EVENT = "SIMPLISAFE_EVENT"
EVENT_SIMPLISAFE_NOTIFICATION = "SIMPLISAFE_NOTIFICATION" EVENT_SIMPLISAFE_NOTIFICATION = "SIMPLISAFE_NOTIFICATION"
PLATFORMS = ( PLATFORMS = [
"alarm_control_panel", Platform.ALARM_CONTROL_PANEL,
"binary_sensor", Platform.BINARY_SENSOR,
"lock", Platform.LOCK,
"sensor", Platform.SENSOR,
) ]
VOLUME_MAP = { VOLUME_MAP = {
"high": Volume.HIGH, "high": Volume.HIGH,

View file

@ -1,4 +1,5 @@
"""Constants for the sma integration.""" """Constants for the sma integration."""
from homeassistant.const import Platform
DOMAIN = "sma" DOMAIN = "sma"
@ -8,7 +9,7 @@ PYSMA_REMOVE_LISTENER = "remove_listener"
PYSMA_SENSORS = "pysma_sensors" PYSMA_SENSORS = "pysma_sensors"
PYSMA_DEVICE_INFO = "device_info" PYSMA_DEVICE_INFO = "device_info"
PLATFORMS = ["sensor"] PLATFORMS = [Platform.SENSOR]
CONF_CUSTOM = "custom" CONF_CUSTOM = "custom"
CONF_FACTOR = "factor" CONF_FACTOR = "factor"

View file

@ -2,6 +2,8 @@
from datetime import timedelta from datetime import timedelta
from homeassistant.const import Platform
DOMAIN = "smappee" DOMAIN = "smappee"
DATA_CLIENT = "smappee_data" DATA_CLIENT = "smappee_data"
@ -12,7 +14,7 @@ CONF_TITLE = "title"
ENV_CLOUD = "cloud" ENV_CLOUD = "cloud"
ENV_LOCAL = "local" ENV_LOCAL = "local"
PLATFORMS = ["binary_sensor", "sensor", "switch"] PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH]
SUPPORTED_LOCAL_DEVICES = ("Smappee1", "Smappee2", "Smappee50") SUPPORTED_LOCAL_DEVICES = ("Smappee1", "Smappee2", "Smappee50")

View file

@ -10,7 +10,7 @@ from smart_meter_texas.exceptions import (
) )
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
@ -30,7 +30,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["sensor"] PLATFORMS = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -5,7 +5,7 @@ import pysmarthab
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry 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.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -13,7 +13,7 @@ from homeassistant.helpers.typing import ConfigType
DOMAIN = "smarthab" DOMAIN = "smarthab"
DATA_HUB = "hub" DATA_HUB = "hub"
PLATFORMS = ["light", "cover"] PLATFORMS = [Platform.LIGHT, Platform.COVER]
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -2,6 +2,8 @@
from datetime import timedelta from datetime import timedelta
import re import re
from homeassistant.const import Platform
DOMAIN = "smartthings" DOMAIN = "smartthings"
APP_OAUTH_CLIENT_NAME = "Home Assistant" APP_OAUTH_CLIENT_NAME = "Home Assistant"
@ -32,15 +34,15 @@ STORAGE_VERSION = 1
# Ordered 'specific to least-specific platform' in order for capabilities # Ordered 'specific to least-specific platform' in order for capabilities
# to be drawn-down and represented by the most appropriate platform. # to be drawn-down and represented by the most appropriate platform.
PLATFORMS = [ PLATFORMS = [
"climate", Platform.CLIMATE,
"fan", Platform.FAN,
"light", Platform.LIGHT,
"lock", Platform.LOCK,
"cover", Platform.COVER,
"switch", Platform.SWITCH,
"binary_sensor", Platform.BINARY_SENSOR,
"sensor", Platform.SENSOR,
"scene", Platform.SCENE,
] ]
IGNORED_CAPABILITIES = [ IGNORED_CAPABILITIES = [

View file

@ -1,8 +1,16 @@
"""SmartTub integration.""" """SmartTub integration."""
from homeassistant.const import Platform
from .const import DOMAIN, SMARTTUB_CONTROLLER from .const import DOMAIN, SMARTTUB_CONTROLLER
from .controller import SmartTubController 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): async def async_setup_entry(hass, entry):

View file

@ -1,8 +1,9 @@
"""Support for the Swedish weather institute weather service.""" """Support for the Swedish weather institute weather service."""
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
PLATFORMS = ["weather"] PLATFORMS = [Platform.WEATHER]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -3,14 +3,14 @@
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry 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.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from .const import DOMAIN, SMS_GATEWAY from .const import DOMAIN, SMS_GATEWAY
from .gateway import create_sms_gateway from .gateway import create_sms_gateway
PLATFORMS = ["sensor"] PLATFORMS = [Platform.SENSOR]
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema(
{DOMAIN: vol.Schema({vol.Required(CONF_DEVICE): cv.isdevice})}, {DOMAIN: vol.Schema({vol.Required(CONF_DEVICE): cv.isdevice})},

View file

@ -5,7 +5,7 @@ from requests.exceptions import ConnectTimeout, HTTPError
from solaredge import Solaredge from solaredge import Solaredge
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv 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) CONFIG_SCHEMA = cv.deprecated(DOMAIN)
PLATFORMS = ["sensor"] PLATFORMS = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -7,7 +7,7 @@ from requests.exceptions import HTTPError, Timeout
from sunwatcher.solarlog.solarlog import SolarLog from sunwatcher.solarlog.solarlog import SolarLog
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.helpers import update_coordinator from homeassistant.helpers import update_coordinator
@ -15,7 +15,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["sensor"] PLATFORMS = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -5,7 +5,7 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry 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 from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.entity import DeviceInfo, Entity
@ -26,7 +26,7 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA, extra=vol.ALLOW_EXTRA,
) )
PLATFORMS = ["cover", "sensor"] PLATFORMS = [Platform.COVER, Platform.SENSOR]
async def async_setup(hass, config): async def async_setup(hass, config):

View file

@ -6,7 +6,12 @@ from pymfy.api.devices.category import Category
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.helpers import ( from homeassistant.helpers import (
config_entry_oauth2_flow, config_entry_oauth2_flow,
@ -39,7 +44,12 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA, extra=vol.ALLOW_EXTRA,
) )
PLATFORMS = ["climate", "cover", "sensor", "switch"] PLATFORMS = [
Platform.CLIMATE,
Platform.COVER,
Platform.SENSOR,
Platform.SWITCH,
]
async def async_setup(hass, config): async def async_setup(hass, config):

View file

@ -1,4 +1,5 @@
"""Component for the Somfy MyLink device supporting the Synergy API.""" """Component for the Somfy MyLink device supporting the Synergy API."""
from homeassistant.const import Platform
CONF_SYSTEM_ID = "system_id" CONF_SYSTEM_ID = "system_id"
CONF_REVERSE = "reverse" CONF_REVERSE = "reverse"
@ -12,6 +13,6 @@ DATA_SOMFY_MYLINK = "somfy_mylink_data"
MYLINK_STATUS = "mylink_status" MYLINK_STATUS = "mylink_status"
DOMAIN = "somfy_mylink" DOMAIN = "somfy_mylink"
PLATFORMS = ["cover"] PLATFORMS = [Platform.COVER]
MANUFACTURER = "Somfy" MANUFACTURER = "Somfy"

View file

@ -12,6 +12,7 @@ from homeassistant.const import (
CONF_PORT, CONF_PORT,
CONF_SSL, CONF_SSL,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
@ -27,7 +28,7 @@ from .const import (
DOMAIN, DOMAIN,
) )
PLATFORMS = ["sensor"] PLATFORMS = [Platform.SENSOR]
SCAN_INTERVAL = timedelta(seconds=30) SCAN_INTERVAL = timedelta(seconds=30)

View file

@ -3,7 +3,7 @@
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry 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.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
@ -19,7 +19,7 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA, extra=vol.ALLOW_EXTRA,
) )
PLATFORMS = ["media_player"] PLATFORMS = [Platform.MEDIA_PLAYER]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View file

@ -9,7 +9,11 @@ from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT, STATE_CLASS_MEASUREMENT,
SensorEntityDescription, 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" DOMAIN: Final = "speedtestdotnet"
@ -65,4 +69,4 @@ ATTRIBUTION: Final = "Data retrieved from Speedtest.net by Ookla"
ICON: Final = "mdi:speedometer" ICON: Final = "mdi:speedometer"
PLATFORMS: Final = ["sensor"] PLATFORMS: Final = [Platform.SENSOR]

View file

@ -1,6 +1,7 @@
"""Constants for the Spider integration.""" """Constants for the Spider integration."""
from homeassistant.const import Platform
DOMAIN = "spider" DOMAIN = "spider"
DEFAULT_SCAN_INTERVAL = 300 DEFAULT_SCAN_INTERVAL = 300
PLATFORMS = ["climate", "switch", "sensor"] PLATFORMS = [Platform.CLIMATE, Platform.SWITCH, Platform.SENSOR]

View file

@ -4,9 +4,13 @@ import aiohttp
from spotipy import Spotify, SpotifyException from spotipy import Spotify, SpotifyException
import voluptuous as vol import voluptuous as vol
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv
@ -37,7 +41,7 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA, extra=vol.ALLOW_EXTRA,
) )
PLATFORMS = [MEDIA_PLAYER_DOMAIN] PLATFORMS = [Platform.MEDIA_PLAYER]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View file

@ -2,15 +2,15 @@
import logging import logging
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from .const import DISCOVERY_TASK, DOMAIN, PLAYER_DISCOVERY_UNSUB from .const import DISCOVERY_TASK, DOMAIN, PLAYER_DISCOVERY_UNSUB
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
PLATFORMS = [MP_DOMAIN] PLATFORMS = [Platform.MEDIA_PLAYER]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -4,7 +4,7 @@ import logging
from srpenergy.client import SrpEnergyClient from srpenergy.client import SrpEnergyClient
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
@ -13,7 +13,7 @@ from .const import SRP_ENERGY_DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["sensor"] PLATFORMS = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -1,10 +1,18 @@
"""StarLine constants.""" """StarLine constants."""
import logging import logging
from homeassistant.const import Platform
_LOGGER = logging.getLogger(__package__) _LOGGER = logging.getLogger(__package__)
DOMAIN = "starline" 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_ID = "app_id"
CONF_APP_SECRET = "app_secret" CONF_APP_SECRET = "app_secret"

View file

@ -3,13 +3,13 @@ from __future__ import annotations
import stookalert import stookalert
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from .const import CONF_PROVINCE, DOMAIN from .const import CONF_PROVINCE, DOMAIN
PLATFORMS = (BINARY_SENSOR_DOMAIN,) PLATFORMS = [Platform.BINARY_SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -1,4 +1,5 @@
"""Constants for the Subaru integration.""" """Constants for the Subaru integration."""
from homeassistant.const import Platform
DOMAIN = "subaru" DOMAIN = "subaru"
FETCH_INTERVAL = 300 FETCH_INTERVAL = 300
@ -31,7 +32,7 @@ API_GEN_2 = "g2"
MANUFACTURER = "Subaru Corp." MANUFACTURER = "Subaru Corp."
PLATFORMS = [ PLATFORMS = [
"sensor", Platform.SENSOR,
] ]
ICONS = { ICONS = {

View file

@ -16,6 +16,7 @@ from homeassistant.const import (
CONF_SCAN_INTERVAL, CONF_SCAN_INTERVAL,
CONF_TOKEN, CONF_TOKEN,
CONF_USERNAME, CONF_USERNAME,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
@ -41,7 +42,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["binary_sensor", "lock", "sensor"] PLATFORMS = [Platform.BINARY_SENSOR, Platform.LOCK, Platform.SENSOR]
SCAN_INTERVAL = timedelta(minutes=3) SCAN_INTERVAL = timedelta(minutes=3)
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema(

View file

@ -4,7 +4,7 @@ from asyncio import Lock
import switchbot # pylint: disable=import-error import switchbot # pylint: disable=import-error
from homeassistant.config_entries import ConfigEntry 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.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
@ -27,8 +27,8 @@ from .const import (
from .coordinator import SwitchbotDataUpdateCoordinator from .coordinator import SwitchbotDataUpdateCoordinator
PLATFORMS_BY_TYPE = { PLATFORMS_BY_TYPE = {
ATTR_BOT: ["switch", "sensor"], ATTR_BOT: [Platform.SWITCH, Platform.SENSOR],
ATTR_CURTAIN: ["cover", "binary_sensor", "sensor"], ATTR_CURTAIN: [Platform.COVER, Platform.BINARY_SENSOR, Platform.SENSOR],
} }

View file

@ -10,6 +10,7 @@ from homeassistant.const import (
CONF_URL, CONF_URL,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
@ -23,7 +24,7 @@ from .const import (
SERVER_UNAVAILABLE, SERVER_UNAVAILABLE,
) )
PLATFORMS = ["sensor"] PLATFORMS = [Platform.SENSOR]
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -7,10 +7,8 @@ import logging
import async_timeout import async_timeout
from pysyncthru import ConnectionMode, SyncThru, SyncThruAPINotSupported 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.config_entries import ConfigEntry
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL, Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client, device_registry as dr from homeassistant.helpers import aiohttp_client, device_registry as dr
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
@ -19,7 +17,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__) _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: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -30,11 +30,12 @@ from homeassistant.const import (
ENTITY_CATEGORY_DIAGNOSTIC, ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS, TEMP_CELSIUS,
Platform,
) )
from homeassistant.helpers.entity import EntityDescription from homeassistant.helpers.entity import EntityDescription
DOMAIN = "synology_dsm" DOMAIN = "synology_dsm"
PLATFORMS = ["binary_sensor", "camera", "sensor", "switch"] PLATFORMS = [Platform.BINARY_SENSOR, Platform.CAMERA, Platform.SENSOR, Platform.SWITCH]
COORDINATOR_CAMERAS = "coordinator_cameras" COORDINATOR_CAMERAS = "coordinator_cameras"
COORDINATOR_CENTRAL = "coordinator_central" COORDINATOR_CENTRAL = "coordinator_central"
COORDINATOR_SWITCHES = "coordinator_switches" COORDINATOR_SWITCHES = "coordinator_switches"

View file

@ -20,6 +20,7 @@ from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PATH, CONF_PATH,
CONF_PORT, CONF_PORT,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ( from homeassistant.exceptions import (
@ -40,7 +41,7 @@ from .coordinator import SystemBridgeDataUpdateCoordinator
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
PLATFORMS = ["binary_sensor", "sensor"] PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
CONF_ARGUMENTS = "arguments" CONF_ARGUMENTS = "arguments"
CONF_BRIDGE = "bridge" CONF_BRIDGE = "bridge"