Add option to display all input sources / Add support for favourite channels / Treat Marantz SR5008 as Denon AVR-X device (#7949)

* add option to display all sources / pushed to version 0.4.3 of library

* Add show_all_sources option for auto discovery too

* change code style for hass

* fix lint
pull/7951/head
Oliver 2017-06-08 09:46:26 +02:00 committed by Pascal Vizeli
parent 8a4e993183
commit 482db94372
2 changed files with 11 additions and 5 deletions

View File

@ -19,11 +19,13 @@ from homeassistant.const import (
CONF_NAME, STATE_ON)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['denonavr==0.4.2']
REQUIREMENTS = ['denonavr==0.4.3']
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = None
DEFAULT_SHOW_SOURCES = False
CONF_SHOW_ALL_SOURCES = 'show_all_sources'
KEY_DENON_CACHE = 'denonavr_hosts'
SUPPORT_DENON = SUPPORT_VOLUME_STEP | SUPPORT_VOLUME_MUTE | \
@ -37,6 +39,8 @@ SUPPORT_MEDIA_MODES = SUPPORT_PLAY_MEDIA | \
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_SHOW_ALL_SOURCES, default=DEFAULT_SHOW_SOURCES):
cv.boolean,
})
@ -52,6 +56,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
cache = hass.data[KEY_DENON_CACHE] = set()
# Start assignment of host and name
show_all_sources = config.get(CONF_SHOW_ALL_SOURCES)
# 1. option: manual setting
if config.get(CONF_HOST) is not None:
host = config.get(CONF_HOST)
@ -60,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if host not in cache:
cache.add(host)
receivers.append(
DenonDevice(denonavr.DenonAVR(host, name)))
DenonDevice(denonavr.DenonAVR(host, name, show_all_sources)))
_LOGGER.info("Denon receiver at host %s initialized", host)
# 2. option: discovery using netdisco
if discovery_info is not None:
@ -70,7 +75,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if host not in cache:
cache.add(host)
receivers.append(
DenonDevice(denonavr.DenonAVR(host, name)))
DenonDevice(denonavr.DenonAVR(host, name, show_all_sources)))
_LOGGER.info("Denon receiver at host %s initialized", host)
# 3. option: discovery using denonavr library
if config.get(CONF_HOST) is None and discovery_info is None:
@ -85,7 +90,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if host not in cache:
cache.add(host)
receivers.append(
DenonDevice(denonavr.DenonAVR(host, name)))
DenonDevice(
denonavr.DenonAVR(host, name, show_all_sources)))
_LOGGER.info("Denon receiver at host %s initialized", host)
# Add all freshly discovered receivers

View File

@ -144,7 +144,7 @@ datapoint==0.4.3
# decora==0.4
# homeassistant.components.media_player.denonavr
denonavr==0.4.2
denonavr==0.4.3
# homeassistant.components.media_player.directv
directpy==0.1