1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Use platform enum (3) [H-L] (#60937)

Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
Marc Mueller 2021-12-06 04:10:07 +01:00 committed by GitHub
parent e0cb33a0a1
commit 40b99135e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 165 additions and 132 deletions

View File

@ -12,6 +12,7 @@ from homeassistant.const import (
CONF_NAME,
CONF_SENSORS,
CONF_URL,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
@ -73,7 +74,7 @@ INSTANCE_LIST_SCHEMA = vol.All(
)
CONFIG_SCHEMA = vol.Schema({DOMAIN: INSTANCE_LIST_SCHEMA}, extra=vol.ALLOW_EXTRA)
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]
SERVICE_API_CALL_SCHEMA = vol.Schema(
{

View File

@ -1,8 +1,10 @@
"""Constants for the Harmony component."""
from homeassistant.const import Platform
DOMAIN = "harmony"
SERVICE_SYNC = "sync"
SERVICE_CHANGE_CHANNEL = "change_channel"
PLATFORMS = ["remote", "switch", "select"]
PLATFORMS = [Platform.REMOTE, Platform.SELECT, Platform.SWITCH]
UNIQUE_ID = "unique_id"
ACTIVITY_POWER_OFF = "PowerOff"
HARMONY_OPTIONS_UPDATE = "harmony_options_update"

View File

@ -22,6 +22,7 @@ from homeassistant.const import (
EVENT_CORE_CONFIG_UPDATE,
SERVICE_HOMEASSISTANT_RESTART,
SERVICE_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import DOMAIN as HASS_DOMAIN, HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
@ -68,7 +69,7 @@ _LOGGER = logging.getLogger(__name__)
STORAGE_KEY = DOMAIN
STORAGE_VERSION = 1
PLATFORMS = ["binary_sensor", "sensor"]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
CONF_FRONTEND_REPO = "development_repo"

View File

@ -8,9 +8,8 @@ import logging
from pyheos import Heos, HeosError, const as heos_const
import voluptuous as vol
from homeassistant.components.media_player.const import DOMAIN as MEDIA_PLAYER_DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP
from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP, Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
import homeassistant.helpers.config_validation as cv
@ -35,7 +34,7 @@ from .const import (
SIGNAL_HEOS_UPDATED,
)
PLATFORMS = [MEDIA_PLAYER_DOMAIN]
PLATFORMS = [Platform.MEDIA_PLAYER]
CONFIG_SCHEMA = vol.Schema(
vol.All(
@ -130,7 +129,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
DATA_CONTROLLER_MANAGER: controller_manager,
DATA_GROUP_MANAGER: group_manager,
DATA_SOURCE_MANAGER: source_manager,
MEDIA_PLAYER_DOMAIN: players,
Platform.MEDIA_PLAYER: players,
# Maps player_id to entity_id. Populated by the individual HeosMediaPlayer entities.
DATA_ENTITY_ID_MAP: {},
}
@ -228,7 +227,7 @@ class ControllerManager:
)
# update entity registry
entity_id = self._entity_registry.async_get_entity_id(
MEDIA_PLAYER_DOMAIN, DOMAIN, str(old_id)
Platform.MEDIA_PLAYER, DOMAIN, str(old_id)
)
if entity_id:
self._entity_registry.async_update_entity(
@ -355,7 +354,7 @@ class GroupManager:
# Avoid calling async_update_groups when `DATA_ENTITY_ID_MAP` has not been
# fully populated yet. This may only happen during early startup.
if (
len(self._hass.data[DOMAIN][MEDIA_PLAYER_DOMAIN])
len(self._hass.data[DOMAIN][Platform.MEDIA_PLAYER])
<= len(self._hass.data[DOMAIN][DATA_ENTITY_ID_MAP])
and not self._initialized
):

View File

@ -8,14 +8,14 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
from homeassistant.const import CONF_IP_ADDRESS
from homeassistant.const import CONF_IP_ADDRESS, Platform
import homeassistant.helpers.config_validation as cv
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
PLATFORMS = [CLIMATE_DOMAIN]
PLATFORMS = [Platform.CLIMATE]
def coerce_ip(value):

View File

@ -5,7 +5,7 @@ from hlk_sw16 import create_hlk_sw16_connection
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_SWITCHES
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_SWITCHES, Platform
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import (
@ -24,7 +24,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
PLATFORMS = ["switch"]
PLATFORMS = [Platform.SWITCH]
DATA_DEVICE_REGISTER = "hlk_sw16_device_register"
DATA_DEVICE_LISTENER = "hlk_sw16_device_listener"

View File

@ -7,7 +7,7 @@ from requests import HTTPError
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv
from homeassistant.helpers.typing import ConfigType
@ -32,7 +32,7 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA,
)
PLATFORMS = ["binary_sensor", "light", "sensor", "switch"]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.LIGHT, Platform.SENSOR, Platform.SWITCH]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View File

@ -1,30 +1,21 @@
"""Constants for the HomematicIP Cloud component."""
import logging
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.components.climate import DOMAIN as CLIMATE_DOMAIN
from homeassistant.components.cover import DOMAIN as COVER_DOMAIN
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
from homeassistant.const import Platform
_LOGGER = logging.getLogger(".")
DOMAIN = "homematicip_cloud"
PLATFORMS = [
ALARM_CONTROL_PANEL_DOMAIN,
BINARY_SENSOR_DOMAIN,
CLIMATE_DOMAIN,
COVER_DOMAIN,
LIGHT_DOMAIN,
SENSOR_DOMAIN,
SWITCH_DOMAIN,
WEATHER_DOMAIN,
Platform.ALARM_CONTROL_PANEL,
Platform.BINARY_SENSOR,
Platform.CLIMATE,
Platform.COVER,
Platform.LIGHT,
Platform.SENSOR,
Platform.SWITCH,
Platform.WEATHER,
]
CONF_ACCESSPOINT = "accesspoint"

View File

@ -4,7 +4,7 @@ from datetime import timedelta
import somecomfort
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.util import Throttle
@ -12,7 +12,7 @@ from .const import _LOGGER, CONF_DEV_ID, CONF_LOC_ID, DOMAIN
UPDATE_LOOP_SLEEP_TIME = 5
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=300)
PLATFORMS = ["climate"]
PLATFORMS = [Platform.CLIMATE]
async def async_setup_entry(hass, config):

View File

@ -22,13 +22,7 @@ from requests.exceptions import Timeout
from url_normalize import url_normalize
import voluptuous as vol
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
from homeassistant.components.device_tracker.const import (
DOMAIN as DEVICE_TRACKER_DOMAIN,
)
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import (
ATTR_MODEL,
@ -40,6 +34,7 @@ from homeassistant.const import (
CONF_URL,
CONF_USERNAME,
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.exceptions import ConfigEntryNotReady
@ -123,12 +118,12 @@ CONFIG_SCHEMA = vol.Schema(
SERVICE_SCHEMA = vol.Schema({vol.Optional(CONF_URL): cv.url})
CONFIG_ENTRY_PLATFORMS = (
BINARY_SENSOR_DOMAIN,
DEVICE_TRACKER_DOMAIN,
SENSOR_DOMAIN,
SWITCH_DOMAIN,
)
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.DEVICE_TRACKER,
Platform.SENSOR,
Platform.SWITCH,
]
@attr.s
@ -455,7 +450,7 @@ async def async_setup_entry( # noqa: C901
)
# Forward config entry setup to platforms
hass.config_entries.async_setup_platforms(entry, CONFIG_ENTRY_PLATFORMS)
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
# Notify doesn't support config entry setup yet, load with discovery for now
await discovery.async_load_platform(
@ -495,9 +490,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
"""Unload config entry."""
# Forward config entry unload to platforms
await hass.config_entries.async_unload_platforms(
config_entry, CONFIG_ENTRY_PLATFORMS
)
await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
# Forget about the router and invoke its cleanup
router = hass.data[DOMAIN].routers.pop(config_entry.unique_id)

View File

@ -14,7 +14,7 @@ import async_timeout
from homeassistant import core
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_HOST
from homeassistant.const import CONF_API_KEY, CONF_HOST, Platform
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import aiohttp_client
@ -26,8 +26,14 @@ from .v2.hue_event import async_setup_hue_events
# How long should we sleep if the hub is busy
HUB_BUSY_SLEEP = 0.5
PLATFORMS_v1 = ["light", "binary_sensor", "sensor"]
PLATFORMS_v2 = ["light", "binary_sensor", "sensor", "scene", "switch"]
PLATFORMS_v1 = [Platform.BINARY_SENSOR, Platform.LIGHT, Platform.SENSOR]
PLATFORMS_v2 = [
Platform.BINARY_SENSOR,
Platform.LIGHT,
Platform.SCENE,
Platform.SENSOR,
Platform.SWITCH,
]
class HueBridge:

View File

@ -6,7 +6,7 @@ import async_timeout
from huisbaasje import Huisbaasje, HuisbaasjeException
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.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
@ -23,7 +23,7 @@ from .const import (
SOURCE_TYPES,
)
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]
_LOGGER = logging.getLogger(__name__)

View File

@ -13,7 +13,7 @@ from aiopvapi.userdata import UserData
import async_timeout
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST
from homeassistant.const import CONF_HOST, Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -55,7 +55,7 @@ PARALLEL_UPDATES = 1
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
PLATFORMS = ["cover", "scene", "sensor"]
PLATFORMS = [Platform.COVER, Platform.SCENE, Platform.SENSOR]
_LOGGER = logging.getLogger(__name__)

View File

@ -1,16 +1,14 @@
"""The HVV integration."""
from homeassistant.components.binary_sensor import DOMAIN as DOMAIN_BINARY_SENSOR
from homeassistant.components.sensor import DOMAIN as DOMAIN_SENSOR
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client
from .const import DOMAIN
from .hub import GTIHub
PLATFORMS = [DOMAIN_SENSOR, DOMAIN_BINARY_SENSOR]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -7,14 +7,14 @@ from pyialarm import IAlarm
from homeassistant.components.alarm_control_panel import SCAN_INTERVAL
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.exceptions import ConfigEntryNotReady
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import DATA_COORDINATOR, DOMAIN, IALARM_TO_HASS
PLATFORMS = ["alarm_control_panel"]
PLATFORMS = [Platform.ALARM_CONTROL_PANEL]
_LOGGER = logging.getLogger(__name__)

View File

@ -1,4 +1,5 @@
"""iCloud component constants."""
from homeassistant.const import Platform
DOMAIN = "icloud"
@ -14,7 +15,7 @@ DEFAULT_GPS_ACCURACY_THRESHOLD = 500 # meters
STORAGE_KEY = DOMAIN
STORAGE_VERSION = 2
PLATFORMS = ["device_tracker", "sensor"]
PLATFORMS = [Platform.DEVICE_TRACKER, Platform.SENSOR]
# pyicloud.AppleDevice status
DEVICE_BATTERY_LEVEL = "batteryLevel"

View File

@ -1,11 +1,12 @@
"""The iotawatt integration."""
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from .const import DOMAIN
from .coordinator import IotawattUpdater
PLATFORMS = ("sensor",)
PLATFORMS = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -1,10 +1,12 @@
"""Component for the Portuguese weather service - IPMA."""
from homeassistant.const import Platform
from .config_flow import IpmaFlowHandler # noqa: F401
from .const import DOMAIN # noqa: F401
DEFAULT_NAME = "ipma"
PLATFORMS = ["weather"]
PLATFORMS = [Platform.WEATHER]
async def async_setup_entry(hass, entry):

View File

@ -1,15 +1,20 @@
"""The Internet Printing Protocol (IPP) integration."""
from __future__ import annotations
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SSL, CONF_VERIFY_SSL
from homeassistant.const import (
CONF_HOST,
CONF_PORT,
CONF_SSL,
CONF_VERIFY_SSL,
Platform,
)
from homeassistant.core import HomeAssistant
from .const import CONF_BASE_PATH, DOMAIN
from .coordinator import IPPDataUpdateCoordinator
PLATFORMS = [SENSOR_DOMAIN]
PLATFORMS = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -11,6 +11,7 @@ from pyiqvia import Client
from pyiqvia.errors import IQVIAError
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import aiohttp_client
@ -37,7 +38,7 @@ from .const import (
DEFAULT_ATTRIBUTION = "Data provided by IQVIA™"
DEFAULT_SCAN_INTERVAL = timedelta(minutes=30)
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -7,6 +7,7 @@ from requests.exceptions import ConnectionError as ConnError
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import Platform
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
@ -23,7 +24,7 @@ from .const import (
_LOGGER = logging.getLogger(__name__)
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]
CONFIG_SCHEMA = vol.Schema(
vol.All(

View File

@ -15,14 +15,12 @@ from homeassistant.components.binary_sensor import (
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_SOUND,
DEVICE_CLASS_VIBRATION,
DOMAIN as BINARY_SENSOR,
)
from homeassistant.components.climate.const import (
CURRENT_HVAC_COOL,
CURRENT_HVAC_FAN,
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
DOMAIN as CLIMATE,
FAN_AUTO,
FAN_HIGH,
FAN_MEDIUM,
@ -37,12 +35,6 @@ from homeassistant.components.climate.const import (
PRESET_AWAY,
PRESET_BOOST,
)
from homeassistant.components.cover import DOMAIN as COVER
from homeassistant.components.fan import DOMAIN as FAN
from homeassistant.components.light import DOMAIN as LIGHT
from homeassistant.components.lock import DOMAIN as LOCK
from homeassistant.components.sensor import DOMAIN as SENSOR
from homeassistant.components.switch import DOMAIN as SWITCH
from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION,
CURRENCY_CENT,
@ -109,6 +101,7 @@ from homeassistant.const import (
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
VOLUME_GALLONS,
VOLUME_LITERS,
Platform,
)
_LOGGER = logging.getLogger(__package__)
@ -133,14 +126,29 @@ DEFAULT_VAR_SENSOR_STRING = "HA."
KEY_ACTIONS = "actions"
KEY_STATUS = "status"
PLATFORMS = [BINARY_SENSOR, SENSOR, LOCK, FAN, COVER, LIGHT, SWITCH, CLIMATE]
PROGRAM_PLATFORMS = [BINARY_SENSOR, LOCK, FAN, COVER, SWITCH]
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.CLIMATE,
Platform.COVER,
Platform.FAN,
Platform.LIGHT,
Platform.LOCK,
Platform.SENSOR,
Platform.SWITCH,
]
PROGRAM_PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.COVER,
Platform.FAN,
Platform.LOCK,
Platform.SWITCH,
]
SUPPORTED_BIN_SENS_CLASSES = ["moisture", "opening", "motion", "climate"]
# ISY Scenes are more like Switches than Home Assistant Scenes
# (they can turn off, and report their state)
ISY_GROUP_PLATFORM = SWITCH
ISY_GROUP_PLATFORM = Platform.SWITCH
ISY994_ISY = "isy"
ISY994_NODES = "isy994_nodes"
@ -211,7 +219,7 @@ UOM_PERCENTAGE = "51"
# Insteon Types: https://www.universal-devices.com/developers/wsdk/5.0.4/1_fam.xml
# Z-Wave Categories: https://www.universal-devices.com/developers/wsdk/5.0.4/4_fam.xml
NODE_FILTERS = {
BINARY_SENSOR: {
Platform.BINARY_SENSOR: {
FILTER_UOM: [UOM_ON_OFF],
FILTER_STATES: [],
FILTER_NODE_DEF_ID: [
@ -231,7 +239,7 @@ NODE_FILTERS = {
], # Does a startswith() match; include the dot
FILTER_ZWAVE_CAT: (["104", "112", "138"] + list(map(str, range(148, 180)))),
},
SENSOR: {
Platform.SENSOR: {
# This is just a more-readable way of including MOST uoms between 1-100
# (Remember that range() is non-inclusive of the stop value)
FILTER_UOM: (
@ -255,28 +263,28 @@ NODE_FILTERS = {
FILTER_INSTEON_TYPE: ["0.16.", "0.17.", "0.18.", "9.0.", "9.7."],
FILTER_ZWAVE_CAT: (["118", "143"] + list(map(str, range(180, 186)))),
},
LOCK: {
Platform.LOCK: {
FILTER_UOM: ["11"],
FILTER_STATES: ["locked", "unlocked"],
FILTER_NODE_DEF_ID: ["DoorLock"],
FILTER_INSTEON_TYPE: [TYPE_CATEGORY_LOCK, "4.64."],
FILTER_ZWAVE_CAT: ["111"],
},
FAN: {
Platform.FAN: {
FILTER_UOM: [],
FILTER_STATES: ["off", "low", "med", "high"],
FILTER_NODE_DEF_ID: ["FanLincMotor"],
FILTER_INSTEON_TYPE: ["1.46."],
FILTER_ZWAVE_CAT: [],
},
COVER: {
Platform.COVER: {
FILTER_UOM: [UOM_BARRIER],
FILTER_STATES: ["open", "closed", "closing", "opening", "stopped"],
FILTER_NODE_DEF_ID: ["DimmerMotorSwitch_ADV"],
FILTER_INSTEON_TYPE: [TYPE_CATEGORY_COVER],
FILTER_ZWAVE_CAT: [],
},
LIGHT: {
Platform.LIGHT: {
FILTER_UOM: ["51"],
FILTER_STATES: ["on", "off", "%"],
FILTER_NODE_DEF_ID: [
@ -293,7 +301,7 @@ NODE_FILTERS = {
FILTER_INSTEON_TYPE: [TYPE_CATEGORY_DIMMABLE],
FILTER_ZWAVE_CAT: ["109", "119"],
},
SWITCH: {
Platform.SWITCH: {
FILTER_UOM: ["78"],
FILTER_STATES: ["on", "off"],
FILTER_NODE_DEF_ID: [
@ -323,7 +331,7 @@ NODE_FILTERS = {
],
FILTER_ZWAVE_CAT: ["121", "122", "123", "137", "141", "147"],
},
CLIMATE: {
Platform.CLIMATE: {
FILTER_UOM: [UOM_ON_OFF],
FILTER_STATES: ["heating", "cooling", "idle", "fan_only", "off"],
FILTER_NODE_DEF_ID: ["TempLinc", "Thermostat"],

View File

@ -2,7 +2,7 @@
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_EXCLUDE
from homeassistant.const import CONF_EXCLUDE, Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
@ -10,7 +10,7 @@ from homeassistant.helpers.typing import ConfigType
from .const import DATA_CONFIG, IZONE
from .discovery import async_start_discovery_service, async_stop_discovery_service
PLATFORMS = ["climate"]
PLATFORMS = [Platform.CLIMATE]
CONFIG_SCHEMA = vol.Schema(
{

View File

@ -7,7 +7,7 @@ from pyjuicenet import Api, TokenError
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.const import CONF_ACCESS_TOKEN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv
@ -20,7 +20,7 @@ from .device import JuiceNetApi
_LOGGER = logging.getLogger(__name__)
PLATFORMS = ["sensor", "switch"]
PLATFORMS = [Platform.SENSOR, Platform.SWITCH]
CONFIG_SCHEMA = vol.Schema(
vol.All(

View File

@ -3,10 +3,8 @@ from __future__ import annotations
import logging
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL
from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry, entity_registry
@ -25,7 +23,7 @@ from .const import (
)
from .router import KeeneticRouter
PLATFORMS = [BINARY_SENSOR_DOMAIN, DEVICE_TRACKER_DOMAIN]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.DEVICE_TRACKER]
_LOGGER = logging.getLogger(__name__)
@ -80,7 +78,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
for entity_entry in list(ent_reg.entities.values()):
if (
entity_entry.config_entry_id == config_entry.entry_id
and entity_entry.domain == DEVICE_TRACKER_DOMAIN
and entity_entry.domain == Platform.DEVICE_TRACKER
):
mac = entity_entry.unique_id.partition("_")[0]
if mac not in keep_devices:

View File

@ -8,14 +8,14 @@ from pykmtronic.auth import Auth
from pykmtronic.hub import KMTronicHubAPI
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import DATA_COORDINATOR, DATA_HUB, DOMAIN, MANUFACTURER, UPDATE_LISTENER
PLATFORMS = ["switch"]
PLATFORMS = [Platform.SWITCH]
_LOGGER = logging.getLogger(__name__)

View File

@ -12,6 +12,7 @@ from homeassistant.const import (
CONF_SSL,
CONF_USERNAME,
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -25,7 +26,7 @@ from .const import (
)
_LOGGER = logging.getLogger(__name__)
PLATFORMS = ["media_player"]
PLATFORMS = [Platform.MEDIA_PLAYER]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -31,6 +31,7 @@ from homeassistant.const import (
CONF_ZONE,
STATE_OFF,
STATE_ON,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
@ -216,7 +217,7 @@ CONFIG_SCHEMA = vol.Schema(
)
YAML_CONFIGS = "yaml_configs"
PLATFORMS = ["binary_sensor", "sensor", "switch"]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

View File

@ -4,6 +4,7 @@ import logging
from kostal.plenticore import PlenticoreApiException
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from .const import DOMAIN
@ -11,7 +12,7 @@ from .helper import Plenticore
_LOGGER = logging.getLogger(__name__)
PLATFORMS = ["select", "sensor", "switch"]
PLATFORMS = [Platform.SELECT, Platform.SENSOR, Platform.SWITCH]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -10,7 +10,7 @@ import krakenex
import pykrakenapi
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_SCAN_INTERVAL
from homeassistant.const import CONF_SCAN_INTERVAL, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
@ -27,7 +27,7 @@ from .utils import get_tradable_asset_pairs
CALL_RATE_LIMIT_SLEEP = 1
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]
_LOGGER = logging.getLogger(__name__)

View File

@ -1,11 +1,12 @@
"""Kuler Sky lights integration."""
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from .const import DATA_ADDRESSES, DATA_DISCOVERY_SUBSCRIPTION, DOMAIN
PLATFORMS = ["light"]
PLATFORMS = [Platform.LIGHT]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -8,9 +8,18 @@ from homeassistant.const import (
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
TEMP_KELVIN,
Platform,
)
PLATFORMS = ["binary_sensor", "climate", "cover", "light", "scene", "sensor", "switch"]
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.CLIMATE,
Platform.COVER,
Platform.LIGHT,
Platform.SCENE,
Platform.SENSOR,
Platform.SWITCH,
]
DOMAIN = "lcn"
DATA_LCN = "lcn"

View File

@ -3,7 +3,7 @@ import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
from homeassistant.const import CONF_PORT
from homeassistant.const import CONF_PORT, Platform
import homeassistant.helpers.config_validation as cv
from .const import DOMAIN
@ -26,7 +26,7 @@ CONFIG_SCHEMA = vol.Schema(
DATA_LIFX_MANAGER = "lifx_manager"
PLATFORMS = [LIGHT_DOMAIN]
PLATFORMS = [Platform.LIGHT]
async def async_setup(hass, config):

View File

@ -1,10 +1,11 @@
"""LiteJet constants."""
from homeassistant.const import Platform
DOMAIN = "litejet"
CONF_EXCLUDE_NAMES = "exclude_names"
CONF_INCLUDE_SWITCHES = "include_switches"
PLATFORMS = ["light", "switch", "scene"]
PLATFORMS = [Platform.LIGHT, Platform.SCENE, Platform.SWITCH]
CONF_DEFAULT_TRANSITION = "default_transition"

View File

@ -2,19 +2,21 @@
from pylitterbot.exceptions import LitterRobotException, LitterRobotLoginException
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.components.vacuum import DOMAIN as VACUUM_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from .const import DOMAIN
from .hub import LitterRobotHub
PLATFORMS = [BUTTON_DOMAIN, SELECT_DOMAIN, SENSOR_DOMAIN, SWITCH_DOMAIN, VACUUM_DOMAIN]
PLATFORMS = [
Platform.BUTTON,
Platform.SELECT,
Platform.SENSOR,
Platform.SWITCH,
Platform.VACUUM,
]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -1,6 +1,7 @@
"""Local IP constants."""
from homeassistant.const import Platform
DOMAIN = "local_ip"
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]
SENSOR = "address"

View File

@ -7,13 +7,13 @@ import logging
from aiohttp import web
import voluptuous as vol
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER
from homeassistant.const import (
ATTR_ID,
ATTR_LATITUDE,
ATTR_LONGITUDE,
CONF_WEBHOOK_ID,
STATE_NOT_HOME,
Platform,
)
from homeassistant.helpers import config_entry_flow
import homeassistant.helpers.config_validation as cv
@ -24,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
DOMAIN = "locative"
TRACKER_UPDATE = f"{DOMAIN}_tracker_update"
PLATFORMS = [DEVICE_TRACKER]
PLATFORMS = [Platform.DEVICE_TRACKER]
ATTR_DEVICE_ID = "device"
ATTR_TRIGGER = "trigger"
@ -82,7 +82,7 @@ async def handle_webhook(hass, webhook_id, request):
return web.Response(text=f"Setting location to {location_name}")
if direction == "exit":
current_state = hass.states.get(f"{DEVICE_TRACKER}.{device}")
current_state = hass.states.get(f"{Platform.DEVICE_TRACKER}.{device}")
if current_state is None or current_state.state == location_name:
location_name = STATE_NOT_HOME

View File

@ -18,6 +18,7 @@ from homeassistant.const import (
CONF_MONITORED_CONDITIONS,
CONF_SENSORS,
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
@ -48,7 +49,7 @@ SERVICE_LIVESTREAM_RECORD = "livestream_record"
ATTR_VALUE = "value"
ATTR_DURATION = "duration"
PLATFORMS = ["camera", "sensor"]
PLATFORMS = [Platform.CAMERA, Platform.SENSOR]
SENSOR_KEYS = [desc.key for desc in SENSOR_TYPES]

View File

@ -3,8 +3,7 @@ from __future__ import annotations
from typing import Final
from homeassistant.const import Platform
DOMAIN: Final = "lookin"
PLATFORMS: Final = [
"sensor",
"climate",
]
PLATFORMS: Final = [Platform.CLIMATE, Platform.SENSOR]

View File

@ -21,6 +21,7 @@ from homeassistant.const import (
PERCENTAGE,
PRESSURE_PA,
TEMP_CELSIUS,
Platform,
)
from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryNotReady
@ -38,7 +39,7 @@ DATA_LUFTDATEN_CLIENT = "data_luftdaten_client"
DATA_LUFTDATEN_LISTENER = "data_luftdaten_listener"
DEFAULT_ATTRIBUTION = "Data provided by luftdaten.info"
PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]
SENSOR_HUMIDITY = "humidity"
SENSOR_PM10 = "P1"

View File

@ -12,7 +12,7 @@ from pylutron_caseta.smartbridge import Smartbridge
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_HOST
from homeassistant.const import CONF_HOST, Platform
from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
@ -63,7 +63,14 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA,
)
PLATFORMS = ["light", "switch", "cover", "scene", "fan", "binary_sensor"]
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.COVER,
Platform.FAN,
Platform.LIGHT,
Platform.SCENE,
Platform.SWITCH,
]
async def async_setup(hass, base_config):

View File

@ -13,7 +13,7 @@ import async_timeout
import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers import (
@ -48,7 +48,7 @@ CONFIG_SCHEMA = vol.Schema(
_LOGGER = logging.getLogger(__name__)
PLATFORMS = ["climate", "sensor"]
PLATFORMS = [Platform.CLIMATE, Platform.SENSOR]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: