mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Remove setup_platform for demo (#100867)
This commit is contained in:
parent
24afbf3ae4
commit
3c3f512583
@ -48,6 +48,7 @@ COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM = [
|
|||||||
Platform.UPDATE,
|
Platform.UPDATE,
|
||||||
Platform.VACUUM,
|
Platform.VACUUM,
|
||||||
Platform.WATER_HEATER,
|
Platform.WATER_HEATER,
|
||||||
|
Platform.WEATHER,
|
||||||
]
|
]
|
||||||
|
|
||||||
COMPONENTS_WITH_DEMO_PLATFORM = [
|
COMPONENTS_WITH_DEMO_PLATFORM = [
|
||||||
@ -56,7 +57,6 @@ COMPONENTS_WITH_DEMO_PLATFORM = [
|
|||||||
Platform.NOTIFY,
|
Platform.NOTIFY,
|
||||||
Platform.IMAGE_PROCESSING,
|
Platform.IMAGE_PROCESSING,
|
||||||
Platform.DEVICE_TRACKER,
|
Platform.DEVICE_TRACKER,
|
||||||
Platform.WEATHER,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
|
CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
|
||||||
|
@ -5,19 +5,6 @@ from homeassistant.components.air_quality import AirQualityEntity
|
|||||||
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.entity_platform import AddEntitiesCallback
|
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(
|
async def async_setup_entry(
|
||||||
@ -26,7 +13,9 @@ async def async_setup_entry(
|
|||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo config entry."""
|
"""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):
|
class DemoAirQuality(AirQualityEntity):
|
||||||
|
@ -19,16 +19,14 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
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,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo alarm control panel platform."""
|
"""Set up the Demo config entry."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
ManualAlarm( # type:ignore[no-untyped-call]
|
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)
|
|
||||||
|
@ -7,7 +7,6 @@ from homeassistant.components.fan import FanEntity, FanEntityFeature
|
|||||||
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.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
|
|
||||||
PRESET_MODE_AUTO = "auto"
|
PRESET_MODE_AUTO = "auto"
|
||||||
PRESET_MODE_SMART = "smart"
|
PRESET_MODE_SMART = "smart"
|
||||||
@ -20,13 +19,12 @@ FULL_SUPPORT = (
|
|||||||
LIMITED_SUPPORT = FanEntityFeature.SET_SPEED
|
LIMITED_SUPPORT = FanEntityFeature.SET_SPEED
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the demo fan platform."""
|
"""Set up the Demo config entry."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoPercentageFan(
|
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):
|
class BaseDemoFan(FanEntity):
|
||||||
"""A demonstration fan component that uses legacy fan speeds."""
|
"""A demonstration fan component that uses legacy fan speeds."""
|
||||||
|
|
||||||
|
@ -12,18 +12,16 @@ from homeassistant.components.humidifier import (
|
|||||||
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.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
|
|
||||||
SUPPORT_FLAGS = HumidifierEntityFeature(0)
|
SUPPORT_FLAGS = HumidifierEntityFeature(0)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo humidifier devices."""
|
"""Set up the Demo humidifier devices config entry."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoHumidifier(
|
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):
|
class DemoHumidifier(HumidifierEntity):
|
||||||
"""Representation of a demo humidifier device."""
|
"""Representation of a demo humidifier device."""
|
||||||
|
|
||||||
|
@ -10,14 +10,14 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the demo image processing platform."""
|
"""Set up the demo image processing platform."""
|
||||||
add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoImageProcessingFace("camera.demo_camera", "Demo Face"),
|
DemoImageProcessingFace("camera.demo_camera", "Demo Face"),
|
||||||
]
|
]
|
||||||
|
@ -15,35 +15,24 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
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
|
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(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo config entry."""
|
"""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):
|
class DemoLock(LockEntity):
|
||||||
|
@ -15,17 +15,15 @@ from homeassistant.components.media_player import (
|
|||||||
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.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the media player demo platform."""
|
"""Set up the Demo config entry."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoYoutubePlayer(
|
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"]
|
SOUND_MODE_LIST = ["Music", "Movie"]
|
||||||
DEFAULT_SOUND_MODE = "Music"
|
DEFAULT_SOUND_MODE = "Music"
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -18,17 +17,7 @@ async def async_setup_entry(
|
|||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo config entry."""
|
"""Set up the Demo config entry."""
|
||||||
setup_platform(hass, {}, async_add_entities)
|
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(
|
|
||||||
[
|
[
|
||||||
DemoRemote("Remote One", False, None),
|
DemoRemote("Remote One", False, None),
|
||||||
DemoRemote("Remote Two", True, "mdi:remote"),
|
DemoRemote("Remote Two", True, "mdi:remote"),
|
||||||
|
@ -7,18 +7,16 @@ from homeassistant.components.siren import SirenEntity, SirenEntityFeature
|
|||||||
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.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
|
|
||||||
SUPPORT_FLAGS = SirenEntityFeature.TURN_OFF | SirenEntityFeature.TURN_ON
|
SUPPORT_FLAGS = SirenEntityFeature.TURN_OFF | SirenEntityFeature.TURN_ON
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo siren devices."""
|
"""Set up the Demo siren devices config entry."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoSiren(name="Siren"),
|
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):
|
class DemoSiren(SirenEntity):
|
||||||
"""Representation of a demo siren device."""
|
"""Representation of a demo siren device."""
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import event
|
from homeassistant.helpers import event
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
|
|
||||||
SUPPORT_MINIMAL_SERVICES = VacuumEntityFeature.TURN_ON | VacuumEntityFeature.TURN_OFF
|
SUPPORT_MINIMAL_SERVICES = VacuumEntityFeature.TURN_ON | VacuumEntityFeature.TURN_OFF
|
||||||
|
|
||||||
@ -79,16 +78,6 @@ async def async_setup_entry(
|
|||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo config entry."""
|
"""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(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoVacuum(DEMO_VACUUM_COMPLETE, SUPPORT_ALL_SERVICES),
|
DemoVacuum(DEMO_VACUUM_COMPLETE, SUPPORT_ALL_SERVICES),
|
||||||
|
@ -11,7 +11,6 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
|
|
||||||
SUPPORT_FLAGS_HEATER = (
|
SUPPORT_FLAGS_HEATER = (
|
||||||
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||||
@ -21,13 +20,12 @@ SUPPORT_FLAGS_HEATER = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo water_heater devices."""
|
"""Set up the Demo config entry."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoWaterHeater(
|
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):
|
class DemoWaterHeater(WaterHeaterEntity):
|
||||||
"""Representation of a demo water_heater device."""
|
"""Representation of a demo water_heater device."""
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ from homeassistant.const import UnitOfPressure, UnitOfSpeed, UnitOfTemperature
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
CONDITION_CLASSES: dict[str, list[str]] = {
|
CONDITION_CLASSES: dict[str, list[str]] = {
|
||||||
@ -61,17 +60,7 @@ async def async_setup_entry(
|
|||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the Demo config entry."""
|
"""Set up the Demo config entry."""
|
||||||
setup_platform(hass, {}, async_add_entities)
|
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(
|
|
||||||
[
|
[
|
||||||
DemoWeather(
|
DemoWeather(
|
||||||
"South",
|
"South",
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Test cases around the demo fan platform."""
|
"""Test cases around the demo fan platform."""
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import fan
|
from homeassistant.components import fan
|
||||||
@ -15,6 +17,7 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
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"]
|
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)
|
@pytest.fixture(autouse=True)
|
||||||
async def setup_comp(hass, disable_platforms):
|
async def setup_comp(hass: HomeAssistant, fan_only: None):
|
||||||
"""Initialize components."""
|
"""Initialize components."""
|
||||||
assert await async_setup_component(hass, fan.DOMAIN, {"fan": {"platform": "demo"}})
|
assert await async_setup_component(hass, fan.DOMAIN, {"fan": {"platform": "demo"}})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""The tests for the demo humidifier component."""
|
"""The tests for the demo humidifier component."""
|
||||||
|
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -22,6 +24,7 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
@ -31,8 +34,18 @@ ENTITY_HYGROSTAT = "humidifier.hygrostat"
|
|||||||
ENTITY_HUMIDIFIER = "humidifier.humidifier"
|
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)
|
@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."""
|
"""Initialize setup demo humidifier."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass, DOMAIN, {"humidifier": {"platform": "demo"}}
|
hass, DOMAIN, {"humidifier": {"platform": "demo"}}
|
||||||
|
@ -15,7 +15,7 @@ from homeassistant.components.lock import (
|
|||||||
STATE_UNLOCKED,
|
STATE_UNLOCKED,
|
||||||
STATE_UNLOCKING,
|
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.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
@ -27,8 +27,18 @@ POORLY_INSTALLED = "lock.poorly_installed_door"
|
|||||||
OPENABLE_LOCK = "lock.openable_lock"
|
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)
|
@pytest.fixture(autouse=True)
|
||||||
async def setup_comp(hass, disable_platforms):
|
async def setup_comp(hass: HomeAssistant, lock_only: None):
|
||||||
"""Set up demo component."""
|
"""Set up demo component."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass, LOCK_DOMAIN, {LOCK_DOMAIN: {"platform": DOMAIN}}
|
hass, LOCK_DOMAIN, {LOCK_DOMAIN: {"platform": DOMAIN}}
|
||||||
|
@ -13,6 +13,7 @@ from homeassistant.const import (
|
|||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_PAUSED,
|
STATE_PAUSED,
|
||||||
STATE_PLAYING,
|
STATE_PLAYING,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.aiohttp_client import DATA_CLIENTSESSION
|
from homeassistant.helpers.aiohttp_client import DATA_CLIENTSESSION
|
||||||
@ -26,6 +27,11 @@ TEST_ENTITY_ID = "media_player.walkman"
|
|||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def autouse_disable_platforms(disable_platforms):
|
def autouse_disable_platforms(disable_platforms):
|
||||||
"""Auto use the disable_platforms fixture."""
|
"""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")
|
@pytest.fixture(name="mock_media_seek")
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""The tests for the demo remote component."""
|
"""The tests for the demo remote component."""
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import homeassistant.components.remote as remote
|
import homeassistant.components.remote as remote
|
||||||
@ -9,6 +11,7 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
@ -17,8 +20,18 @@ ENTITY_ID = "remote.remote_one"
|
|||||||
SERVICE_SEND_COMMAND = "send_command"
|
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)
|
@pytest.fixture(autouse=True)
|
||||||
async def setup_component(hass, disable_platforms):
|
async def setup_component(hass: HomeAssistant, remote_only: None):
|
||||||
"""Initialize components."""
|
"""Initialize components."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass, remote.DOMAIN, {"remote": {"platform": "demo"}}
|
hass, remote.DOMAIN, {"remote": {"platform": "demo"}}
|
||||||
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
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"
|
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)
|
@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."""
|
"""Initialize setup demo siren."""
|
||||||
assert await async_setup_component(hass, DOMAIN, {"siren": {"platform": "demo"}})
|
assert await async_setup_component(hass, DOMAIN, {"siren": {"platform": "demo"}})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""The tests for the Demo vacuum platform."""
|
"""The tests for the Demo vacuum platform."""
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ from homeassistant.const import (
|
|||||||
CONF_PLATFORM,
|
CONF_PLATFORM,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
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()
|
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)
|
@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."""
|
"""Initialize setup demo vacuum."""
|
||||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "demo"}})
|
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "demo"}})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
"""The tests for the demo water_heater component."""
|
"""The tests for the demo water_heater component."""
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import water_heater
|
from homeassistant.components import water_heater
|
||||||
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
|
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"
|
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)
|
@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."""
|
"""Set up demo component."""
|
||||||
hass.config.units = US_CUSTOMARY_SYSTEM
|
hass.config.units = US_CUSTOMARY_SYSTEM
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""The tests for the demo weather component."""
|
"""The tests for the demo weather component."""
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
import pytest
|
import pytest
|
||||||
@ -15,7 +16,7 @@ from homeassistant.components.weather import (
|
|||||||
ATTR_WEATHER_WIND_BEARING,
|
ATTR_WEATHER_WIND_BEARING,
|
||||||
ATTR_WEATHER_WIND_SPEED,
|
ATTR_WEATHER_WIND_SPEED,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
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
|
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."""
|
"""Test weather attributes."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass, weather.DOMAIN, {"weather": {"platform": "demo"}}
|
hass, weather.DOMAIN, {"weather": {"platform": "demo"}}
|
||||||
@ -115,7 +126,7 @@ async def test_forecast(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
freezer: FrozenDateTimeFactory,
|
freezer: FrozenDateTimeFactory,
|
||||||
disable_platforms: None,
|
weather_only: None,
|
||||||
forecast_type: str,
|
forecast_type: str,
|
||||||
expected_forecast: list[dict[str, Any]],
|
expected_forecast: list[dict[str, Any]],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -40,7 +40,7 @@ async def test_setup_demo_platform(hass: HomeAssistant) -> None:
|
|||||||
"""Test setup."""
|
"""Test setup."""
|
||||||
mock = MagicMock()
|
mock = MagicMock()
|
||||||
add_entities = 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
|
assert add_entities.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user