Adjust AddEntitiesCallback import (part 2) (#88873)

pull/88946/head
epenet 2023-03-01 04:01:36 +01:00 committed by GitHub
parent c724e7c29f
commit 3e8716b37e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 31 deletions

View File

@ -15,7 +15,10 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, UnitOfTemperature from homeassistant.const import PERCENTAGE, UnitOfTemperature
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform as ep from homeassistant.helpers.entity_platform import (
AddEntitiesCallback,
async_get_current_platform,
)
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from . import EightSleepBaseEntity, EightSleepConfigEntryData from . import EightSleepBaseEntity, EightSleepConfigEntryData
@ -68,7 +71,7 @@ SERVICE_EIGHT_SCHEMA = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: ep.AddEntitiesCallback hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None: ) -> None:
"""Set up the eight sleep sensors.""" """Set up the eight sleep sensors."""
config_entry_data: EightSleepConfigEntryData = hass.data[DOMAIN][entry.entry_id] config_entry_data: EightSleepConfigEntryData = hass.data[DOMAIN][entry.entry_id]
@ -95,7 +98,7 @@ async def async_setup_entry(
async_add_entities(all_sensors) async_add_entities(all_sensors)
platform = ep.async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_HEAT_SET, SERVICE_HEAT_SET,
SERVICE_EIGHT_SCHEMA, SERVICE_EIGHT_SCHEMA,

View File

@ -17,10 +17,10 @@ from homeassistant.config_entries import (
) )
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import ( from homeassistant.helpers import config_validation as cv, discovery_flow
config_validation as cv, from homeassistant.helpers.entity_platform import (
discovery_flow, AddEntitiesCallback,
entity_platform, async_get_current_platform,
) )
from .const import ( from .const import (
@ -53,9 +53,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
entry: ConfigEntry,
async_add_entities: entity_platform.AddEntitiesCallback,
) -> None: ) -> None:
"""Set up EZVIZ cameras based on a config entry.""" """Set up EZVIZ cameras based on a config entry."""
@ -132,7 +130,7 @@ async def async_setup_entry(
async_add_entities(camera_entities) async_add_entities(camera_entities)
platform = entity_platform.async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_PTZ, SERVICE_PTZ,

View File

@ -13,9 +13,12 @@ import voluptuous as vol
from homeassistant.components.scene import ATTR_TRANSITION, Scene as SceneEntity from homeassistant.components.scene import ATTR_TRANSITION, Scene as SceneEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_platform
from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import (
AddEntitiesCallback,
async_get_current_platform,
)
from .bridge import HueBridge from .bridge import HueBridge
from .const import DOMAIN from .const import DOMAIN
@ -31,7 +34,7 @@ ATTR_BRIGHTNESS = "brightness"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: entity_platform.AddEntitiesCallback, async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up scene platform from Hue group scenes.""" """Set up scene platform from Hue group scenes."""
bridge: HueBridge = hass.data[DOMAIN][config_entry.entry_id] bridge: HueBridge = hass.data[DOMAIN][config_entry.entry_id]
@ -62,7 +65,7 @@ async def async_setup_entry(
) )
# add platform service to turn_on/activate scene with advanced options # add platform service to turn_on/activate scene with advanced options
platform = entity_platform.async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_ACTIVATE_SCENE, SERVICE_ACTIVATE_SCENE,
{ {

View File

@ -8,7 +8,11 @@ import voluptuous as vol
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity_platform import (
AddEntitiesCallback,
async_get_current_platform,
)
from .const import DOMAIN from .const import DOMAIN
from .coordinator import MicroBotDataUpdateCoordinator from .coordinator import MicroBotDataUpdateCoordinator
@ -23,14 +27,12 @@ CALIBRATE_SCHEMA = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
entry: ConfigEntry,
async_add_entities: entity_platform.AddEntitiesCallback,
) -> None: ) -> None:
"""Set up MicroBot based on a config entry.""" """Set up MicroBot based on a config entry."""
coordinator: MicroBotDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] coordinator: MicroBotDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities([MicroBotBinarySwitch(coordinator, entry)]) async_add_entities([MicroBotBinarySwitch(coordinator, entry)])
platform = entity_platform.async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
CALIBRATE, CALIBRATE,
CALIBRATE_SCHEMA, CALIBRATE_SCHEMA,

View File

@ -32,12 +32,12 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ENTITY_ID, EntityCategory from homeassistant.const import ATTR_ENTITY_ID, EntityCategory
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import ( from homeassistant.helpers import config_validation as cv, issue_registry as ir
config_validation as cv,
entity_platform,
issue_registry as ir,
)
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import (
AddEntitiesCallback,
async_get_current_platform,
)
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from .const import ATTR_DURATION, ATTR_MESSAGE, DISPATCH_ADOPT, DOMAIN, TYPE_EMPTY_VALUE from .const import ATTR_DURATION, ATTR_MESSAGE, DISPATCH_ADOPT, DOMAIN, TYPE_EMPTY_VALUE
@ -319,9 +319,7 @@ VIEWER_SELECTS: tuple[ProtectSelectEntityDescription, ...] = (
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
entry: ConfigEntry,
async_add_entities: entity_platform.AddEntitiesCallback,
) -> None: ) -> None:
"""Set up number entities for UniFi Protect integration.""" """Set up number entities for UniFi Protect integration."""
data: ProtectData = hass.data[DOMAIN][entry.entry_id] data: ProtectData = hass.data[DOMAIN][entry.entry_id]
@ -354,7 +352,7 @@ async def async_setup_entry(
) )
async_add_entities(entities) async_add_entities(entities)
platform = entity_platform.async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SET_DOORBELL_MESSAGE, SERVICE_SET_DOORBELL_MESSAGE,
SET_DOORBELL_LCD_MESSAGE_SCHEMA, SET_DOORBELL_LCD_MESSAGE_SCHEMA,

View File

@ -9,8 +9,12 @@ from homeassistant.components.lock import STATE_LOCKED, STATE_UNLOCKED, LockEnti
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform from homeassistant.const import 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
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import (
AddEntitiesCallback,
async_get_current_platform,
)
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from .core import discovery from .core import discovery
@ -38,7 +42,7 @@ SERVICE_CLEAR_LOCK_USER_CODE = "clear_lock_user_code"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: entity_platform.AddEntitiesCallback, async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up the Zigbee Home Automation Door Lock from config entry.""" """Set up the Zigbee Home Automation Door Lock from config entry."""
entities_to_create = hass.data[DATA_ZHA][Platform.LOCK] entities_to_create = hass.data[DATA_ZHA][Platform.LOCK]
@ -52,7 +56,7 @@ async def async_setup_entry(
) )
config_entry.async_on_unload(unsub) config_entry.async_on_unload(unsub)
platform = entity_platform.async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
SERVICE_SET_LOCK_USER_CODE, SERVICE_SET_LOCK_USER_CODE,