Remove setup_platform for demo (#100867)

This commit is contained in:
G Johansson 2023-10-15 23:12:41 +02:00 committed by GitHub
parent 24afbf3ae4
commit 3c3f512583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 149 additions and 168 deletions

View File

@ -48,6 +48,7 @@ COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM = [
Platform.UPDATE,
Platform.VACUUM,
Platform.WATER_HEATER,
Platform.WEATHER,
]
COMPONENTS_WITH_DEMO_PLATFORM = [
@ -56,7 +57,6 @@ COMPONENTS_WITH_DEMO_PLATFORM = [
Platform.NOTIFY,
Platform.IMAGE_PROCESSING,
Platform.DEVICE_TRACKER,
Platform.WEATHER,
]
CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)

View File

@ -5,19 +5,6 @@ from homeassistant.components.air_quality import AirQualityEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Air Quality."""
async_add_entities(
[DemoAirQuality("Home", 14, 23, 100), DemoAirQuality("Office", 4, 16, None)]
)
async def async_setup_entry(
@ -26,7 +13,9 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities)
async_add_entities(
[DemoAirQuality("Home", 14, 23, 100), DemoAirQuality("Office", 4, 16, None)]
)
class DemoAirQuality(AirQualityEntity):

View File

@ -19,16 +19,14 @@ from homeassistant.const import (
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_platform(
async def async_setup_entry(
hass: HomeAssistant,
config: ConfigType,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Demo alarm control panel platform."""
"""Set up the Demo config entry."""
async_add_entities(
[
ManualAlarm( # type:ignore[no-untyped-call]
@ -75,12 +73,3 @@ async def async_setup_platform(
)
]
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities)

View File

@ -7,7 +7,6 @@ from homeassistant.components.fan import FanEntity, FanEntityFeature
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
PRESET_MODE_AUTO = "auto"
PRESET_MODE_SMART = "smart"
@ -20,13 +19,12 @@ FULL_SUPPORT = (
LIMITED_SUPPORT = FanEntityFeature.SET_SPEED
async def async_setup_platform(
async def async_setup_entry(
hass: HomeAssistant,
config: ConfigType,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the demo fan platform."""
"""Set up the Demo config entry."""
async_add_entities(
[
DemoPercentageFan(
@ -88,15 +86,6 @@ async def async_setup_platform(
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities)
class BaseDemoFan(FanEntity):
"""A demonstration fan component that uses legacy fan speeds."""

View File

@ -12,18 +12,16 @@ from homeassistant.components.humidifier import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
SUPPORT_FLAGS = HumidifierEntityFeature(0)
async def async_setup_platform(
async def async_setup_entry(
hass: HomeAssistant,
config: ConfigType,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Demo humidifier devices."""
"""Set up the Demo humidifier devices config entry."""
async_add_entities(
[
DemoHumidifier(
@ -52,15 +50,6 @@ async def async_setup_platform(
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo humidifier devices config entry."""
await async_setup_platform(hass, {}, async_add_entities)
class DemoHumidifier(HumidifierEntity):
"""Representation of a demo humidifier device."""

View File

@ -10,14 +10,14 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
def setup_platform(
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the demo image processing platform."""
add_entities(
async_add_entities(
[
DemoImageProcessingFace("camera.demo_camera", "Demo Face"),
]

View File

@ -15,35 +15,24 @@ from homeassistant.const import (
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
LOCK_UNLOCK_DELAY = 2 # Used to give a realistic lock/unlock experience in frontend
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Demo lock platform."""
async_add_entities(
[
DemoLock("Front Door", STATE_LOCKED),
DemoLock("Kitchen Door", STATE_UNLOCKED),
DemoLock("Poorly Installed Door", STATE_UNLOCKED, False, True),
DemoLock("Openable Lock", STATE_LOCKED, True),
]
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities)
async_add_entities(
[
DemoLock("Front Door", STATE_LOCKED),
DemoLock("Kitchen Door", STATE_UNLOCKED),
DemoLock("Poorly Installed Door", STATE_UNLOCKED, False, True),
DemoLock("Openable Lock", STATE_LOCKED, True),
]
)
class DemoLock(LockEntity):

View File

@ -15,17 +15,15 @@ from homeassistant.components.media_player import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
import homeassistant.util.dt as dt_util
async def async_setup_platform(
async def async_setup_entry(
hass: HomeAssistant,
config: ConfigType,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the media player demo platform."""
"""Set up the Demo config entry."""
async_add_entities(
[
DemoYoutubePlayer(
@ -44,15 +42,6 @@ async def async_setup_platform(
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities)
SOUND_MODE_LIST = ["Music", "Movie"]
DEFAULT_SOUND_MODE = "Music"

View File

@ -9,7 +9,6 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEVICE_DEFAULT_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
async def async_setup_entry(
@ -18,17 +17,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
setup_platform(hass, {}, async_add_entities)
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities_callback: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the demo remotes."""
add_entities_callback(
async_add_entities(
[
DemoRemote("Remote One", False, None),
DemoRemote("Remote Two", True, "mdi:remote"),

View File

@ -7,18 +7,16 @@ from homeassistant.components.siren import SirenEntity, SirenEntityFeature
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
SUPPORT_FLAGS = SirenEntityFeature.TURN_OFF | SirenEntityFeature.TURN_ON
async def async_setup_platform(
async def async_setup_entry(
hass: HomeAssistant,
config: ConfigType,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Demo siren devices."""
"""Set up the Demo siren devices config entry."""
async_add_entities(
[
DemoSiren(name="Siren"),
@ -32,15 +30,6 @@ async def async_setup_platform(
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo siren devices config entry."""
await async_setup_platform(hass, {}, async_add_entities)
class DemoSiren(SirenEntity):
"""Representation of a demo siren device."""

View File

@ -19,7 +19,6 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import event
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
SUPPORT_MINIMAL_SERVICES = VacuumEntityFeature.TURN_ON | VacuumEntityFeature.TURN_OFF
@ -79,16 +78,6 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities)
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Demo vacuums."""
async_add_entities(
[
DemoVacuum(DEMO_VACUUM_COMPLETE, SUPPORT_ALL_SERVICES),

View File

@ -11,7 +11,6 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
SUPPORT_FLAGS_HEATER = (
WaterHeaterEntityFeature.TARGET_TEMPERATURE
@ -21,13 +20,12 @@ SUPPORT_FLAGS_HEATER = (
)
async def async_setup_platform(
async def async_setup_entry(
hass: HomeAssistant,
config: ConfigType,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Demo water_heater devices."""
"""Set up the Demo config entry."""
async_add_entities(
[
DemoWaterHeater(
@ -40,15 +38,6 @@ async def async_setup_platform(
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities)
class DemoWaterHeater(WaterHeaterEntity):
"""Representation of a demo water_heater device."""

View File

@ -27,7 +27,6 @@ from homeassistant.const import UnitOfPressure, UnitOfSpeed, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
import homeassistant.util.dt as dt_util
CONDITION_CLASSES: dict[str, list[str]] = {
@ -61,17 +60,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Demo config entry."""
setup_platform(hass, {}, async_add_entities)
def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Demo weather."""
add_entities(
async_add_entities(
[
DemoWeather(
"South",

View File

@ -1,4 +1,6 @@
"""Test cases around the demo fan platform."""
from unittest.mock import patch
import pytest
from homeassistant.components import fan
@ -15,6 +17,7 @@ from homeassistant.const import (
SERVICE_TURN_ON,
STATE_OFF,
STATE_ON,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@ -31,8 +34,18 @@ FANS_WITH_PRESET_MODES = FULL_FAN_ENTITY_IDS + [
PERCENTAGE_MODEL_FANS = ["fan.percentage_full_fan", "fan.percentage_limited_fan"]
@pytest.fixture
async def fan_only() -> None:
"""Enable only the datetime platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.FAN],
):
yield
@pytest.fixture(autouse=True)
async def setup_comp(hass, disable_platforms):
async def setup_comp(hass: HomeAssistant, fan_only: None):
"""Initialize components."""
assert await async_setup_component(hass, fan.DOMAIN, {"fan": {"platform": "demo"}})
await hass.async_block_till_done()

View File

@ -1,5 +1,7 @@
"""The tests for the demo humidifier component."""
from unittest.mock import patch
import pytest
import voluptuous as vol
@ -22,6 +24,7 @@ from homeassistant.const import (
SERVICE_TURN_ON,
STATE_OFF,
STATE_ON,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@ -31,8 +34,18 @@ ENTITY_HYGROSTAT = "humidifier.hygrostat"
ENTITY_HUMIDIFIER = "humidifier.humidifier"
@pytest.fixture
async def humidifier_only() -> None:
"""Enable only the datetime platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.HUMIDIFIER],
):
yield
@pytest.fixture(autouse=True)
async def setup_demo_humidifier(hass, disable_platforms):
async def setup_demo_humidifier(hass: HomeAssistant, humidifier_only: None):
"""Initialize setup demo humidifier."""
assert await async_setup_component(
hass, DOMAIN, {"humidifier": {"platform": "demo"}}

View File

@ -15,7 +15,7 @@ from homeassistant.components.lock import (
STATE_UNLOCKED,
STATE_UNLOCKING,
)
from homeassistant.const import ATTR_ENTITY_ID, EVENT_STATE_CHANGED
from homeassistant.const import ATTR_ENTITY_ID, EVENT_STATE_CHANGED, Platform
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@ -27,8 +27,18 @@ POORLY_INSTALLED = "lock.poorly_installed_door"
OPENABLE_LOCK = "lock.openable_lock"
@pytest.fixture
async def lock_only() -> None:
"""Enable only the datetime platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.LOCK],
):
yield
@pytest.fixture(autouse=True)
async def setup_comp(hass, disable_platforms):
async def setup_comp(hass: HomeAssistant, lock_only: None):
"""Set up demo component."""
assert await async_setup_component(
hass, LOCK_DOMAIN, {LOCK_DOMAIN: {"platform": DOMAIN}}

View File

@ -13,6 +13,7 @@ from homeassistant.const import (
STATE_OFF,
STATE_PAUSED,
STATE_PLAYING,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import DATA_CLIENTSESSION
@ -26,6 +27,11 @@ TEST_ENTITY_ID = "media_player.walkman"
@pytest.fixture(autouse=True)
def autouse_disable_platforms(disable_platforms):
"""Auto use the disable_platforms fixture."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.MEDIA_PLAYER],
):
yield
@pytest.fixture(name="mock_media_seek")

View File

@ -1,4 +1,6 @@
"""The tests for the demo remote component."""
from unittest.mock import patch
import pytest
import homeassistant.components.remote as remote
@ -9,6 +11,7 @@ from homeassistant.const import (
SERVICE_TURN_ON,
STATE_OFF,
STATE_ON,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@ -17,8 +20,18 @@ ENTITY_ID = "remote.remote_one"
SERVICE_SEND_COMMAND = "send_command"
@pytest.fixture
async def remote_only() -> None:
"""Enable only the datetime platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.REMOTE],
):
yield
@pytest.fixture(autouse=True)
async def setup_component(hass, disable_platforms):
async def setup_component(hass: HomeAssistant, remote_only: None):
"""Initialize components."""
assert await async_setup_component(
hass, remote.DOMAIN, {"remote": {"platform": "demo"}}

View File

@ -16,6 +16,7 @@ from homeassistant.const import (
SERVICE_TURN_ON,
STATE_OFF,
STATE_ON,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@ -24,8 +25,18 @@ ENTITY_SIREN = "siren.siren"
ENTITY_SIREN_WITH_ALL_FEATURES = "siren.siren_with_all_features"
@pytest.fixture
async def siren_only() -> None:
"""Enable only the datetime platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.SIREN],
):
yield
@pytest.fixture(autouse=True)
async def setup_demo_siren(hass, disable_platforms):
async def setup_demo_siren(hass: HomeAssistant, siren_only: None):
"""Initialize setup demo siren."""
assert await async_setup_component(hass, DOMAIN, {"siren": {"platform": "demo"}})
await hass.async_block_till_done()

View File

@ -1,5 +1,6 @@
"""The tests for the Demo vacuum platform."""
from datetime import timedelta
from unittest.mock import patch
import pytest
@ -35,6 +36,7 @@ from homeassistant.const import (
CONF_PLATFORM,
STATE_OFF,
STATE_ON,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
@ -52,8 +54,18 @@ ENTITY_VACUUM_NONE = f"{DOMAIN}.{DEMO_VACUUM_NONE}".lower()
ENTITY_VACUUM_STATE = f"{DOMAIN}.{DEMO_VACUUM_STATE}".lower()
@pytest.fixture
async def vacuum_only() -> None:
"""Enable only the datetime platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.VACUUM],
):
yield
@pytest.fixture(autouse=True)
async def setup_demo_vacuum(hass, disable_platforms):
async def setup_demo_vacuum(hass: HomeAssistant, vacuum_only: None):
"""Initialize setup demo vacuum."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "demo"}})
await hass.async_block_till_done()

View File

@ -1,8 +1,11 @@
"""The tests for the demo water_heater component."""
from unittest.mock import patch
import pytest
import voluptuous as vol
from homeassistant.components import water_heater
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
@ -13,8 +16,18 @@ ENTITY_WATER_HEATER = "water_heater.demo_water_heater"
ENTITY_WATER_HEATER_CELSIUS = "water_heater.demo_water_heater_celsius"
@pytest.fixture
async def water_heater_only() -> None:
"""Enable only the datetime platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.WATER_HEATER],
):
yield
@pytest.fixture(autouse=True)
async def setup_comp(hass, disable_platforms):
async def setup_comp(hass: HomeAssistant, water_heater_only: None):
"""Set up demo component."""
hass.config.units = US_CUSTOMARY_SYSTEM
assert await async_setup_component(

View File

@ -1,6 +1,7 @@
"""The tests for the demo weather component."""
import datetime
from typing import Any
from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory
import pytest
@ -15,7 +16,7 @@ from homeassistant.components.weather import (
ATTR_WEATHER_WIND_BEARING,
ATTR_WEATHER_WIND_SPEED,
)
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.const import ATTR_ATTRIBUTION, Platform
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from homeassistant.util.unit_system import METRIC_SYSTEM
@ -23,7 +24,17 @@ from homeassistant.util.unit_system import METRIC_SYSTEM
from tests.typing import WebSocketGenerator
async def test_attributes(hass: HomeAssistant, disable_platforms) -> None:
@pytest.fixture
async def weather_only() -> None:
"""Enable only the datetime platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.WEATHER],
):
yield
async def test_attributes(hass: HomeAssistant, weather_only) -> None:
"""Test weather attributes."""
assert await async_setup_component(
hass, weather.DOMAIN, {"weather": {"platform": "demo"}}
@ -115,7 +126,7 @@ async def test_forecast(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
freezer: FrozenDateTimeFactory,
disable_platforms: None,
weather_only: None,
forecast_type: str,
expected_forecast: list[dict[str, Any]],
) -> None:

View File

@ -40,7 +40,7 @@ async def test_setup_demo_platform(hass: HomeAssistant) -> None:
"""Test setup."""
mock = MagicMock()
add_entities = mock.MagicMock()
await demo.async_setup_platform(hass, {}, add_entities)
await demo.async_setup_entry(hass, {}, add_entities)
assert add_entities.call_count == 1