Use Platform constants all over the place 2/3 (#62953)

This commit is contained in:
Sebastian Lövdahl 2021-12-28 22:23:07 +02:00 committed by GitHub
parent c8aabc48f1
commit d18f1cc872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 70 additions and 34 deletions

View file

@ -17,6 +17,7 @@ from homeassistant.const import (
CONF_URL,
CONF_USERNAME,
TEMP_CELSIUS,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery
@ -55,7 +56,12 @@ DOMAIN = "ihc"
IHC_CONTROLLER = "controller"
IHC_INFO = "info"
PLATFORMS = ("binary_sensor", "light", "sensor", "switch")
PLATFORMS = (
Platform.BINARY_SENSOR,
Platform.LIGHT,
Platform.SENSOR,
Platform.SWITCH,
)
def validate_name(config):

View file

@ -48,9 +48,9 @@ INSTEON_PLATFORMS = [
]
X10_PLATFORMS = [
"binary_sensor",
"switch",
"light",
Platform.BINARY_SENSOR,
Platform.SWITCH,
Platform.LIGHT,
]
CONF_IP_PORT = "ip_port"

View file

@ -8,6 +8,7 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE,
Platform,
)
DOMAIN = "kaiterra"
@ -71,4 +72,4 @@ DEFAULT_AQI_STANDARD = "us"
DEFAULT_PREFERRED_UNIT = []
DEFAULT_SCAN_INTERVAL = timedelta(seconds=30)
PLATFORMS = ["sensor", "air_quality"]
PLATFORMS = [Platform.SENSOR, Platform.AIR_QUALITY]

View file

@ -5,7 +5,7 @@ import logging
import linode
import voluptuous as vol
from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.const import CONF_ACCESS_TOKEN, Platform
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
@ -23,7 +23,7 @@ ATTR_VCPUS = "vcpus"
CONF_NODES = "nodes"
DATA_LINODE = "data_li"
LINODE_PLATFORMS = ["binary_sensor", "switch"]
LINODE_PLATFORMS = [Platform.BINARY_SENSOR, Platform.SWITCH]
DOMAIN = "linode"
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)

View file

@ -6,7 +6,13 @@ import lupupy
from lupupy.exceptions import LupusecException
import voluptuous as vol
from homeassistant.const import CONF_IP_ADDRESS, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_NAME,
CONF_PASSWORD,
CONF_USERNAME,
Platform,
)
from homeassistant.helpers import config_validation as cv, discovery
from homeassistant.helpers.entity import Entity
@ -31,7 +37,11 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA,
)
LUPUSEC_PLATFORMS = ["alarm_control_panel", "binary_sensor", "switch"]
LUPUSEC_PLATFORMS = [
Platform.ALARM_CONTROL_PANEL,
Platform.BINARY_SENSOR,
Platform.SWITCH,
]
def setup(hass, config):

View file

@ -4,7 +4,13 @@ import logging
from pylutron import Button, Lutron
import voluptuous as vol
from homeassistant.const import ATTR_ID, CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.const import (
ATTR_ID,
CONF_HOST,
CONF_PASSWORD,
CONF_USERNAME,
Platform,
)
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
@ -12,7 +18,13 @@ from homeassistant.util import slugify
DOMAIN = "lutron"
PLATFORMS = ["light", "cover", "switch", "scene", "binary_sensor"]
PLATFORMS = [
Platform.LIGHT,
Platform.COVER,
Platform.SWITCH,
Platform.SCENE,
Platform.BINARY_SENSOR,
]
_LOGGER = logging.getLogger(__name__)

View file

@ -1,4 +1,6 @@
"""The min_max component."""
from homeassistant.const import Platform
DOMAIN = "min_max"
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]

View file

@ -38,6 +38,7 @@ from homeassistant.const import (
CONF_USERNAME,
HTTP_BASIC_AUTHENTICATION,
HTTP_DIGEST_AUTHENTICATION,
Platform,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, entity_platform
@ -65,7 +66,7 @@ from .const import (
TYPE_MOTIONEYE_MJPEG_CAMERA,
)
PLATFORMS = ["camera"]
PLATFORMS = [Platform.CAMERA]
SCHEMA_TEXT_OVERLAY = vol.In(
[

View file

@ -32,6 +32,7 @@ from homeassistant.const import (
CONF_VALUE_TEMPLATE,
EVENT_HOMEASSISTANT_STARTED,
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import (
CoreState,
@ -127,20 +128,20 @@ DISCOVERY_COOLDOWN = 2
TIMEOUT_ACK = 10
PLATFORMS = [
"alarm_control_panel",
"binary_sensor",
"camera",
"climate",
"cover",
"fan",
"humidifier",
"light",
"lock",
"number",
"scene",
"sensor",
"switch",
"vacuum",
Platform.ALARM_CONTROL_PANEL,
Platform.BINARY_SENSOR,
Platform.CAMERA,
Platform.CLIMATE,
Platform.COVER,
Platform.FAN,
Platform.HUMIDIFIER,
Platform.LIGHT,
Platform.LOCK,
Platform.NUMBER,
Platform.SCENE,
Platform.SENSOR,
Platform.SWITCH,
Platform.VACUUM,
]

View file

@ -10,6 +10,7 @@ from homeassistant.const import (
CONF_SCAN_INTERVAL,
CONF_URL,
CONF_USERNAME,
Platform,
)
from homeassistant.helpers import config_validation as cv, discovery
from homeassistant.helpers.event import track_time_interval
@ -17,7 +18,7 @@ from homeassistant.helpers.event import track_time_interval
_LOGGER = logging.getLogger(__name__)
DOMAIN = "nextcloud"
PLATFORMS = ("sensor", "binary_sensor")
PLATFORMS = (Platform.SENSOR, Platform.BINARY_SENSOR)
SCAN_INTERVAL = timedelta(seconds=60)
# Validate user configuration

View file

@ -8,7 +8,7 @@ import sys
from pycarwings2 import CarwingsError, Session
import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME, Platform
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import load_platform
@ -82,7 +82,7 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA,
)
PLATFORMS = ["sensor", "switch", "binary_sensor"]
PLATFORMS = [Platform.SENSOR, Platform.SWITCH, Platform.BINARY_SENSOR]
SIGNAL_UPDATE_LEAF = "nissan_leaf_update"

View file

@ -1,5 +1,5 @@
"""Constants for the Plex component."""
from homeassistant.const import __version__
from homeassistant.const import Platform, __version__
DOMAIN = "plex"
NAME_FORMAT = "Plex ({})"
@ -16,7 +16,7 @@ DEBOUNCE_TIMEOUT = 1
DISPATCHERS = "dispatchers"
GDM_DEBOUNCER = "gdm_debouncer"
GDM_SCANNER = "gdm_scanner"
PLATFORMS = frozenset(["media_player", "sensor"])
PLATFORMS = frozenset([Platform.MEDIA_PLAYER, Platform.SENSOR])
PLATFORMS_COMPLETED = "platforms_completed"
PLAYER_SOURCE = "player_source"
SERVERS = "servers"

View file

@ -13,6 +13,7 @@ from homeassistant.const import (
CONF_CLIENT_SECRET,
CONF_TOKEN,
CONF_WEBHOOK_ID,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
@ -41,7 +42,7 @@ _LOGGER = logging.getLogger(__name__)
DATA_CONFIG_ENTRY_LOCK = "point_config_entry_lock"
CONFIG_ENTRY_IS_SETUP = "point_config_entry_is_setup"
PLATFORMS = ["binary_sensor", "sensor"]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
CONFIG_SCHEMA = vol.Schema(
{

View file

@ -17,6 +17,7 @@ from homeassistant.const import (
CONF_PORT,
CONF_USERNAME,
CONF_VERIFY_SSL,
Platform,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
@ -26,7 +27,7 @@ from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
)
PLATFORMS = ["binary_sensor"]
PLATFORMS = [Platform.BINARY_SENSOR]
DOMAIN = "proxmoxve"
PROXMOX_CLIENTS = "proxmox_clients"
CONF_REALM = "realm"