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_URL,
CONF_USERNAME, CONF_USERNAME,
TEMP_CELSIUS, TEMP_CELSIUS,
Platform,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
@ -55,7 +56,12 @@ DOMAIN = "ihc"
IHC_CONTROLLER = "controller" IHC_CONTROLLER = "controller"
IHC_INFO = "info" IHC_INFO = "info"
PLATFORMS = ("binary_sensor", "light", "sensor", "switch") PLATFORMS = (
Platform.BINARY_SENSOR,
Platform.LIGHT,
Platform.SENSOR,
Platform.SWITCH,
)
def validate_name(config): def validate_name(config):

View file

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

View file

@ -8,6 +8,7 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
PERCENTAGE, PERCENTAGE,
Platform,
) )
DOMAIN = "kaiterra" DOMAIN = "kaiterra"
@ -71,4 +72,4 @@ DEFAULT_AQI_STANDARD = "us"
DEFAULT_PREFERRED_UNIT = [] DEFAULT_PREFERRED_UNIT = []
DEFAULT_SCAN_INTERVAL = timedelta(seconds=30) 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 linode
import voluptuous as vol 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 import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle from homeassistant.util import Throttle
@ -23,7 +23,7 @@ ATTR_VCPUS = "vcpus"
CONF_NODES = "nodes" CONF_NODES = "nodes"
DATA_LINODE = "data_li" DATA_LINODE = "data_li"
LINODE_PLATFORMS = ["binary_sensor", "switch"] LINODE_PLATFORMS = [Platform.BINARY_SENSOR, Platform.SWITCH]
DOMAIN = "linode" DOMAIN = "linode"
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)

View file

@ -6,7 +6,13 @@ import lupupy
from lupupy.exceptions import LupusecException from lupupy.exceptions import LupusecException
import voluptuous as vol 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 import config_validation as cv, discovery
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
@ -31,7 +37,11 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA, 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): def setup(hass, config):

View file

@ -4,7 +4,13 @@ import logging
from pylutron import Button, Lutron from pylutron import Button, Lutron
import voluptuous as vol 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 from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
@ -12,7 +18,13 @@ from homeassistant.util import slugify
DOMAIN = "lutron" 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__) _LOGGER = logging.getLogger(__name__)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,6 +17,7 @@ from homeassistant.const import (
CONF_PORT, CONF_PORT,
CONF_USERNAME, CONF_USERNAME,
CONF_VERIFY_SSL, CONF_VERIFY_SSL,
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
@ -26,7 +27,7 @@ from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator, DataUpdateCoordinator,
) )
PLATFORMS = ["binary_sensor"] PLATFORMS = [Platform.BINARY_SENSOR]
DOMAIN = "proxmoxve" DOMAIN = "proxmoxve"
PROXMOX_CLIENTS = "proxmox_clients" PROXMOX_CLIENTS = "proxmox_clients"
CONF_REALM = "realm" CONF_REALM = "realm"