raise PlatformNotReady when speakers unreachable (#56508)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
Bas Nijholt 2021-09-21 23:35:51 +02:00 committed by GitHub
parent 9831ff0487
commit b7a758bd0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -32,6 +32,7 @@ from homeassistant.const import (
STATE_OFF,
STATE_ON,
)
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.event import async_track_time_interval
@ -123,7 +124,10 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
mode = get_ip_mode(host)
mac = await hass.async_add_executor_job(partial(get_mac_address, **{mode: host}))
unique_id = f"kef-{mac}" if mac is not None else None
if mac is None:
raise PlatformNotReady("Cannot get the ip address of kef speaker.")
unique_id = f"kef-{mac}"
media_player = KefMediaPlayer(
name,