Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if CONF_ADB_SERVER_IP not in config:
atv = AndroidTV(host)
if not atv.available:
# "python-adb" with adbkey
if CONF_ADBKEY in config:
adbkey = config[CONF_ADBKEY]
else:
adbkey = DEFAULT_ADBKEY
atv = AndroidTV(host, adbkey)
adb_log = " using adbkey='{0}'".format(adbkey)
else:
adb_log = ""
else:
# "pure-python-adb"
atv = AndroidTV(
host,
adb_server_ip=config[CONF_ADB_SERVER_IP],
adb_server_port=config[CONF_ADB_SERVER_PORT])
adb_log = " using ADB server at {0}:{1}".format(
config[CONF_ADB_SERVER_IP], config[CONF_ADB_SERVER_PORT])
if not atv.available:
_LOGGER.warning(
"Could not connect to Android TV at %s%s", host, adb_log)
raise PlatformNotReady
if host in hass.data[DATA_KEY]:
_LOGGER.warning("Platform already setup on %s, skipping.", host)
else:
device = AndroidTVDevice(atv, name, config[CONF_APPS])
add_entities([device])
if CONF_ADB_SERVER_IP not in config:
atv = AndroidTV(host)
if not atv.available:
# "python-adb" with adbkey
if CONF_ADBKEY in config:
adbkey = config[CONF_ADBKEY]
else:
adbkey = DEFAULT_ADBKEY
atv = AndroidTV(host, adbkey)
adb_log = " using adbkey='{0}'".format(adbkey)
else:
adb_log = ""
else:
# "pure-python-adb"
atv = AndroidTV(
host,
adb_server_ip=config[CONF_ADB_SERVER_IP],
adb_server_port=config[CONF_ADB_SERVER_PORT])
adb_log = " using ADB server at {0}:{1}".format(
config[CONF_ADB_SERVER_IP], config[CONF_ADB_SERVER_PORT])
if not atv.available:
_LOGGER.warning(
"Could not connect to Android TV at %s%s", host, adb_log)
raise PlatformNotReady
if host in hass.data[DATA_KEY]:
_LOGGER.warning("Platform already setup on %s, skipping.", host)
else:
device = AndroidTVDevice(atv, name, config[CONF_APPS])
add_entities([device])
from androidtv import AndroidTV
if DATA_KEY not in hass.data:
hass.data[DATA_KEY] = {}
host = '{0}:{1}'.format(config[CONF_HOST], config[CONF_PORT])
name = config.get(CONF_NAME)
if CONF_ADB_SERVER_IP not in config:
atv = AndroidTV(host)
if not atv.available:
# "python-adb" with adbkey
if CONF_ADBKEY in config:
adbkey = config[CONF_ADBKEY]
else:
adbkey = DEFAULT_ADBKEY
atv = AndroidTV(host, adbkey)
adb_log = " using adbkey='{0}'".format(adbkey)
else:
adb_log = ""
else:
# "pure-python-adb"
atv = AndroidTV(
host,
adb_server_ip=config[CONF_ADB_SERVER_IP],
adb_server_port=config[CONF_ADB_SERVER_PORT])
adb_log = " using ADB server at {0}:{1}".format(
config[CONF_ADB_SERVER_IP], config[CONF_ADB_SERVER_PORT])
if not atv.available:
_LOGGER.warning(
"Could not connect to Android TV at %s%s", host, adb_log)
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the androidtv platform."""
from androidtv import AndroidTV
if DATA_KEY not in hass.data:
hass.data[DATA_KEY] = {}
host = '{0}:{1}'.format(config[CONF_HOST], config[CONF_PORT])
name = config.get(CONF_NAME)
if CONF_ADB_SERVER_IP not in config:
atv = AndroidTV(host)
if not atv.available:
# "python-adb" with adbkey
if CONF_ADBKEY in config:
adbkey = config[CONF_ADBKEY]
else:
adbkey = DEFAULT_ADBKEY
atv = AndroidTV(host, adbkey)
adb_log = " using adbkey='{0}'".format(adbkey)
else:
adb_log = ""
else:
# "pure-python-adb"
atv = AndroidTV(
host,
adb_server_ip=config[CONF_ADB_SERVER_IP],
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the androidtv platform."""
from androidtv import AndroidTV
if DATA_KEY not in hass.data:
hass.data[DATA_KEY] = {}
host = '{0}:{1}'.format(config[CONF_HOST], config[CONF_PORT])
name = config.get(CONF_NAME)
if CONF_ADB_SERVER_IP not in config:
atv = AndroidTV(host)
if not atv.available:
# "python-adb" with adbkey
if CONF_ADBKEY in config:
adbkey = config[CONF_ADBKEY]
else:
adbkey = DEFAULT_ADBKEY
atv = AndroidTV(host, adbkey)
adb_log = " using adbkey='{0}'".format(adbkey)
else:
adb_log = ""
else:
# "pure-python-adb"
atv = AndroidTV(
host,
adb_server_ip=config[CONF_ADB_SERVER_IP],
from androidtv import AndroidTV
if DATA_KEY not in hass.data:
hass.data[DATA_KEY] = {}
host = '{0}:{1}'.format(config[CONF_HOST], config[CONF_PORT])
name = config.get(CONF_NAME)
if CONF_ADB_SERVER_IP not in config:
atv = AndroidTV(host)
if not atv.available:
# "python-adb" with adbkey
if CONF_ADBKEY in config:
adbkey = config[CONF_ADBKEY]
else:
adbkey = DEFAULT_ADBKEY
atv = AndroidTV(host, adbkey)
adb_log = " using adbkey='{0}'".format(adbkey)
else:
adb_log = ""
else:
# "pure-python-adb"
atv = AndroidTV(
host,
adb_server_ip=config[CONF_ADB_SERVER_IP],
adb_server_port=config[CONF_ADB_SERVER_PORT])
adb_log = " using ADB server at {0}:{1}".format(
config[CONF_ADB_SERVER_IP], config[CONF_ADB_SERVER_PORT])
if not atv.available:
_LOGGER.warning(
"Could not connect to Android TV at %s%s", host, adb_log)