mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Merge pull request #212 from rmkraus/dev
IGNORE_CEC Parameter for Cast device
This commit is contained in:
commit
8363757f1c
@ -25,10 +25,12 @@ from homeassistant.components.media_player import (
|
||||
SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
|
||||
MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_VIDEO)
|
||||
|
||||
CONF_IGNORE_CEC = 'ignore_cec'
|
||||
CAST_SPLASH = 'https://home-assistant.io/images/cast/splash.png'
|
||||
SUPPORT_CAST = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
|
||||
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PREVIOUS_TRACK | \
|
||||
SUPPORT_NEXT_TRACK | SUPPORT_YOUTUBE
|
||||
KNOWN_HOSTS = []
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
@ -43,12 +45,22 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
return False
|
||||
|
||||
if discovery_info:
|
||||
# import CEC IGNORE attributes
|
||||
ignore_cec = config.get(CONF_IGNORE_CEC, [])
|
||||
if isinstance(ignore_cec, list):
|
||||
pychromecast.IGNORE_CEC += ignore_cec
|
||||
else:
|
||||
logger.error('Chromecast conig, %s must be a list.', CONF_IGNORE_CEC)
|
||||
|
||||
hosts = []
|
||||
|
||||
if discovery_info and discovery_info[0] not in KNOWN_HOSTS:
|
||||
hosts = [discovery_info[0]]
|
||||
|
||||
else:
|
||||
hosts = (host_port[0] for host_port
|
||||
in pychromecast.discover_chromecasts())
|
||||
in pychromecast.discover_chromecasts()
|
||||
if host_port[0] not in KNOWN_HOSTS)
|
||||
|
||||
casts = []
|
||||
|
||||
@ -57,6 +69,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
casts.append(CastDevice(host))
|
||||
except pychromecast.ChromecastConnectionError:
|
||||
pass
|
||||
else:
|
||||
KNOWN_HOSTS.append(host)
|
||||
|
||||
add_devices(casts)
|
||||
|
||||
|
@ -18,7 +18,7 @@ phue>=0.8
|
||||
ledcontroller>=1.0.7
|
||||
|
||||
# Chromecast bindings (media_player.cast)
|
||||
pychromecast>=0.6.6
|
||||
pychromecast>=0.6.9
|
||||
|
||||
# Keyboard (keyboard)
|
||||
pyuserinput>=0.1.9
|
||||
|
Loading…
x
Reference in New Issue
Block a user