mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 08:07:45 +00:00
Implimented Ignore CEC for Chromecasts
1) Added the ability to ignore CEC data from Chromecasts using pending updates to PyChromecast library. 2) Modified cast device to not allow the same device to be imported twice. This can happen when cast is setup as a media_player in the config when the discovery component is active.
This commit is contained in:
parent
336d0a3972
commit
67135a7150
@ -1 +1 @@
|
|||||||
Subproject commit 14f2bb779eb165bce236dcdc69d83e08ab73da1c
|
Subproject commit 015edf9c28a63122aa8f6bc153f0c0ddfaad1caa
|
@ -25,10 +25,12 @@ from homeassistant.components.media_player import (
|
|||||||
SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
|
SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
|
||||||
MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_VIDEO)
|
MEDIA_TYPE_MUSIC, MEDIA_TYPE_TVSHOW, MEDIA_TYPE_VIDEO)
|
||||||
|
|
||||||
|
CONF_IGNORE_CEC = 'ignore_cec'
|
||||||
CAST_SPLASH = 'https://home-assistant.io/images/cast/splash.png'
|
CAST_SPLASH = 'https://home-assistant.io/images/cast/splash.png'
|
||||||
SUPPORT_CAST = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
|
SUPPORT_CAST = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
|
||||||
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PREVIOUS_TRACK | \
|
SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_PREVIOUS_TRACK | \
|
||||||
SUPPORT_NEXT_TRACK | SUPPORT_YOUTUBE
|
SUPPORT_NEXT_TRACK | SUPPORT_YOUTUBE
|
||||||
|
KNOWN_HOSTS = []
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -43,12 +45,22 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
return False
|
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]]
|
hosts = [discovery_info[0]]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
hosts = (host_port[0] for host_port
|
hosts = (host_port[0] for host_port
|
||||||
in pychromecast.discover_chromecasts())
|
in pychromecast.discover_chromecasts()
|
||||||
|
if host_port[0] not in KNOWN_HOSTS)
|
||||||
|
|
||||||
casts = []
|
casts = []
|
||||||
|
|
||||||
@ -57,6 +69,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
casts.append(CastDevice(host))
|
casts.append(CastDevice(host))
|
||||||
except pychromecast.ChromecastConnectionError:
|
except pychromecast.ChromecastConnectionError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
KNOWN_HOSTS.append(host)
|
||||||
|
|
||||||
add_devices(casts)
|
add_devices(casts)
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ phue>=0.8
|
|||||||
ledcontroller>=1.0.7
|
ledcontroller>=1.0.7
|
||||||
|
|
||||||
# Chromecast bindings (media_player.cast)
|
# Chromecast bindings (media_player.cast)
|
||||||
pychromecast>=0.6.6
|
pychromecast>=0.6.7
|
||||||
|
|
||||||
# Keyboard (keyboard)
|
# Keyboard (keyboard)
|
||||||
pyuserinput>=0.1.9
|
pyuserinput>=0.1.9
|
||||||
|
Loading…
x
Reference in New Issue
Block a user