diff --git a/homeassistant/components/amcrest/__init__.py b/homeassistant/components/amcrest/__init__.py index 3ee6e685eb5..78463e4a110 100644 --- a/homeassistant/components/amcrest/__init__.py +++ b/homeassistant/components/amcrest/__init__.py @@ -15,10 +15,6 @@ import voluptuous as vol from homeassistant.auth.models import User from homeassistant.auth.permissions.const import POLICY_CONTROL -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR -from homeassistant.components.camera import DOMAIN as CAMERA -from homeassistant.components.sensor import DOMAIN as SENSOR -from homeassistant.components.switch import DOMAIN as SWITCH from homeassistant.const import ( ATTR_ENTITY_ID, CONF_AUTHENTICATION, @@ -34,6 +30,7 @@ from homeassistant.const import ( ENTITY_MATCH_ALL, ENTITY_MATCH_NONE, HTTP_BASIC_AUTHENTICATION, + Platform, ) from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.exceptions import Unauthorized, UnknownUser @@ -301,13 +298,15 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: control_light, ) - discovery.load_platform(hass, CAMERA, DOMAIN, {CONF_NAME: name}, config) + discovery.load_platform( + hass, Platform.CAMERA, DOMAIN, {CONF_NAME: name}, config + ) event_codes = set() if binary_sensors: discovery.load_platform( hass, - BINARY_SENSOR, + Platform.BINARY_SENSOR, DOMAIN, {CONF_NAME: name, CONF_BINARY_SENSORS: binary_sensors}, config, @@ -324,12 +323,20 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: if sensors: discovery.load_platform( - hass, SENSOR, DOMAIN, {CONF_NAME: name, CONF_SENSORS: sensors}, config + hass, + Platform.SENSOR, + DOMAIN, + {CONF_NAME: name, CONF_SENSORS: sensors}, + config, ) if switches: discovery.load_platform( - hass, SWITCH, DOMAIN, {CONF_NAME: name, CONF_SWITCHES: switches}, config + hass, + Platform.SWITCH, + DOMAIN, + {CONF_NAME: name, CONF_SWITCHES: switches}, + config, ) if not hass.data[DATA_AMCREST][DEVICES]: diff --git a/homeassistant/helpers/discovery.py b/homeassistant/helpers/discovery.py index 1923ba9556c..890c0dccae2 100644 --- a/homeassistant/helpers/discovery.py +++ b/homeassistant/helpers/discovery.py @@ -11,6 +11,7 @@ from collections.abc import Callable from typing import Any, TypedDict from homeassistant import core, setup +from homeassistant.const import Platform from homeassistant.core import CALLBACK_TYPE from homeassistant.loader import bind_hass @@ -126,7 +127,7 @@ def async_listen_platform( @bind_hass def load_platform( hass: core.HomeAssistant, - component: str, + component: Platform | str, platform: str, discovered: DiscoveryInfoType, hass_config: ConfigType, @@ -142,7 +143,7 @@ def load_platform( @bind_hass async def async_load_platform( hass: core.HomeAssistant, - component: str, + component: Platform | str, platform: str, discovered: DiscoveryInfoType, hass_config: ConfigType,