throw PlatformNotReady if unable to connect (#22515)

Throw `PlatformNotReady` for when the device disconnects, or when the Home Assistant is booting and the ADB server is not ready yet.
This commit is contained in:
Kyle Niewiada 2019-03-29 11:08:36 -04:00 committed by Rohan Kapoor
parent 5f6037d563
commit 1050baa9cc

View File

@ -18,6 +18,7 @@ from homeassistant.const import (
ATTR_COMMAND, ATTR_ENTITY_ID, CONF_DEVICE_CLASS, CONF_HOST, CONF_NAME,
CONF_PORT, STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING,
STATE_STANDBY)
from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv
ANDROIDTV_DOMAIN = 'androidtv'
@ -125,7 +126,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
_LOGGER.warning("Could not connect to %s at %s%s",
device_name, host, adb_log)
return
raise PlatformNotReady
if host in hass.data[ANDROIDTV_DOMAIN]:
_LOGGER.warning("Platform already setup on %s, skipping", host)