Add discovery suppport to Apple TV (#5801)

Add an optional extended description…
This commit is contained in:
Pierre Ståhl 2017-02-08 12:17:23 +01:00 committed by Pascal Vizeli
parent 2dab6cbb0e
commit 250523c1d8
3 changed files with 14 additions and 9 deletions

View File

@ -40,6 +40,7 @@ SERVICE_HANDLERS = {
'samsung_tv': ('media_player', 'samsungtv'),
'yeelight': ('light', 'yeelight'),
'flux_led': ('light', 'flux_led'),
'apple_tv': ('media_player', 'apple_tv'),
}
CONFIG_SCHEMA = vol.Schema({

View File

@ -21,7 +21,7 @@ import homeassistant.helpers.config_validation as cv
import homeassistant.util.dt as dt_util
REQUIREMENTS = ['pyatv==0.0.1']
REQUIREMENTS = ['pyatv==0.1.1']
_LOGGER = logging.getLogger(__name__)
@ -44,17 +44,21 @@ def async_setup_platform(hass, config, async_add_entities,
"""Setup the Apple TV platform."""
import pyatv
if discovery_info is not None:
name = discovery_info['name']
host = discovery_info['host']
login_id = discovery_info['hsgid']
else:
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
login_id = config.get(CONF_LOGIN_ID)
if DATA_APPLE_TV not in hass.data:
hass.data[DATA_APPLE_TV] = []
name = config.get(CONF_NAME)
host = config.get(CONF_HOST)
login_id = config.get(CONF_LOGIN_ID)
key = '{}:{}'.format(host, name)
if key in hass.data[DATA_APPLE_TV]:
if host in hass.data[DATA_APPLE_TV]:
return False
hass.data[DATA_APPLE_TV].append(key)
hass.data[DATA_APPLE_TV].append(host)
details = pyatv.AppleTVDevice(name, host, login_id)
atv = pyatv.connect_to_apple_tv(details, hass.loop)

View File

@ -418,7 +418,7 @@ pyasn1-modules==0.0.8
pyasn1==0.2.2
# homeassistant.components.media_player.apple_tv
pyatv==0.0.1
pyatv==0.1.1
# homeassistant.components.device_tracker.bbox
# homeassistant.components.sensor.bbox