mirror of
https://github.com/home-assistant/core
synced 2024-10-04 07:58:43 +02:00
Log error when integration is missing platform setup (#30690)
This commit is contained in:
parent
672db9cfe9
commit
abe727fbbc
@ -83,6 +83,16 @@ class EntityPlatform:
|
|||||||
platform = self.platform
|
platform = self.platform
|
||||||
hass = self.hass
|
hass = self.hass
|
||||||
|
|
||||||
|
if not hasattr(platform, "async_setup_platform") and not hasattr(
|
||||||
|
platform, "setup_platform"
|
||||||
|
):
|
||||||
|
self.logger.error(
|
||||||
|
"The %s platform for the %s integration does not support platform setup. Please remove it from your config.",
|
||||||
|
self.platform_name,
|
||||||
|
self.domain,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_create_setup_task():
|
def async_create_setup_task():
|
||||||
"""Get task to set up platform."""
|
"""Get task to set up platform."""
|
||||||
|
@ -834,3 +834,17 @@ async def test_override_restored_entities(hass):
|
|||||||
|
|
||||||
state = hass.states.get("test_domain.world")
|
state = hass.states.get("test_domain.world")
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_platform_with_no_setup(hass, caplog):
|
||||||
|
"""Test setting up a platform that doesnt' support setup."""
|
||||||
|
entity_platform = MockEntityPlatform(
|
||||||
|
hass, domain="mock-integration", platform_name="mock-platform", platform=None
|
||||||
|
)
|
||||||
|
|
||||||
|
await entity_platform.async_setup(None)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
"The mock-platform platform for the mock-integration integration does not support platform setup."
|
||||||
|
in caplog.text
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user