mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Fix "argument of type 'NoneType' is not iterable" during discovery (#4279)
* Fix "argument of type 'NoneType' is not iterable" during discovery When yamaha receivers are dynamically discovered, there config is empty, which means that we need to set zone_ignore to [] otherwise the iteration over receivers fails. * Bump rxv library version to fix play_status bug rxv version 0.3 will issue the play_status command even for sources that don't support it, causing stack traces during updates when receivers are on HDMI inputs. This was fixed in rxv 0.3.1. Bump to fix bug #4226. * Don't discovery receivers that we've already configured The discovery component doesn't know anything about already configured receivers. This means that specifying a receiver manually will make it show up twice if you have the discovery component enabled. This puts a platform specific work around here that ensures that if the media_player is found, we ignore the discovery system.
This commit is contained in:
parent
7d2ab4fce6
commit
e9d19c1dcc
@ -18,7 +18,7 @@ from homeassistant.const import (CONF_NAME, CONF_HOST, STATE_OFF, STATE_ON,
|
|||||||
STATE_PLAYING, STATE_IDLE)
|
STATE_PLAYING, STATE_IDLE)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['rxv==0.3.0']
|
REQUIREMENTS = ['rxv==0.3.1']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ CONF_SOURCE_IGNORE = 'source_ignore'
|
|||||||
CONF_ZONE_IGNORE = 'zone_ignore'
|
CONF_ZONE_IGNORE = 'zone_ignore'
|
||||||
|
|
||||||
DEFAULT_NAME = 'Yamaha Receiver'
|
DEFAULT_NAME = 'Yamaha Receiver'
|
||||||
|
KNOWN = 'yamaha_known_receivers'
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
@ -50,6 +51,11 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
|||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the Yamaha platform."""
|
"""Setup the Yamaha platform."""
|
||||||
import rxv
|
import rxv
|
||||||
|
# keep track of configured receivers so that we don't end up
|
||||||
|
# discovering a receiver dynamically that we have static config
|
||||||
|
# for.
|
||||||
|
if hass.data.get(KNOWN, None) is None:
|
||||||
|
hass.data[KNOWN] = set()
|
||||||
|
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
@ -62,12 +68,17 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
model = discovery_info[1]
|
model = discovery_info[1]
|
||||||
ctrl_url = discovery_info[2]
|
ctrl_url = discovery_info[2]
|
||||||
desc_url = discovery_info[3]
|
desc_url = discovery_info[3]
|
||||||
|
if ctrl_url in hass.data[KNOWN]:
|
||||||
|
_LOGGER.info("%s already manually configured", ctrl_url)
|
||||||
|
return
|
||||||
receivers = rxv.RXV(
|
receivers = rxv.RXV(
|
||||||
ctrl_url,
|
ctrl_url,
|
||||||
model_name=model,
|
model_name=model,
|
||||||
friendly_name=name,
|
friendly_name=name,
|
||||||
unit_desc_url=desc_url).zone_controllers()
|
unit_desc_url=desc_url).zone_controllers()
|
||||||
_LOGGER.info("Receivers: %s", receivers)
|
_LOGGER.info("Receivers: %s", receivers)
|
||||||
|
# when we are dynamically discovered config is empty
|
||||||
|
zone_ignore = []
|
||||||
elif host is None:
|
elif host is None:
|
||||||
receivers = []
|
receivers = []
|
||||||
for recv in rxv.find():
|
for recv in rxv.find():
|
||||||
@ -78,6 +89,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
for receiver in receivers:
|
for receiver in receivers:
|
||||||
if receiver.zone not in zone_ignore:
|
if receiver.zone not in zone_ignore:
|
||||||
|
hass.data[KNOWN].add(receiver.ctrl_url)
|
||||||
add_devices([
|
add_devices([
|
||||||
YamahaDevice(name, receiver, source_ignore, source_names)])
|
YamahaDevice(name, receiver, source_ignore, source_names)])
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ radiotherm==1.2
|
|||||||
# rpi-rf==0.9.5
|
# rpi-rf==0.9.5
|
||||||
|
|
||||||
# homeassistant.components.media_player.yamaha
|
# homeassistant.components.media_player.yamaha
|
||||||
rxv==0.3.0
|
rxv==0.3.1
|
||||||
|
|
||||||
# homeassistant.components.media_player.samsungtv
|
# homeassistant.components.media_player.samsungtv
|
||||||
samsungctl==0.5.1
|
samsungctl==0.5.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user