From c6d5a5a6cc7d151ba75a2c6cd80554e17217073b Mon Sep 17 00:00:00 2001 From: zewelor Date: Fri, 21 Jun 2019 21:50:25 +0200 Subject: [PATCH] Improve autodiscovered yeelights model detection (#24671) * Improve autodiscovered yeelights model detection * Lint fixes * Logger warn fix --- homeassistant/components/yeelight/__init__.py | 13 ++++--------- homeassistant/components/yeelight/light.py | 6 ++++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/yeelight/__init__.py b/homeassistant/components/yeelight/__init__.py index 39dc62eddb0..6978acdce8c 100644 --- a/homeassistant/components/yeelight/__init__.py +++ b/homeassistant/components/yeelight/__init__.py @@ -122,17 +122,12 @@ def setup(hass, config): def device_discovered(_, info): _LOGGER.debug("Adding autodetected %s", info['hostname']) - device_type = info['device_type'] - - name = "yeelight_%s_%s" % (device_type, + name = "yeelight_%s_%s" % (info['device_type'], info['properties']['mac']) - ipaddr = info[CONF_HOST] - device_config = DEVICE_SCHEMA({ - CONF_NAME: name, - CONF_MODEL: device_type - }) - _setup_device(hass, config, ipaddr, device_config) + device_config = DEVICE_SCHEMA({CONF_NAME: name}) + + _setup_device(hass, config, info[CONF_HOST], device_config) discovery.listen(hass, SERVICE_YEELIGHT, device_discovered) diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py index 1abb05e784f..88314773be0 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -178,8 +178,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None): _lights_setup_helper(YeelightWithAmbientLight) _lights_setup_helper(YeelightAmbientLight) else: - _LOGGER.error("Cannot determine device type for %s, %s", - device.ipaddr, device.name) + _lights_setup_helper(YeelightGenericLight) + _LOGGER.warning("Cannot determine device type for %s, %s. " + "Falling back to white only", device.ipaddr, + device.name) hass.data[data_key] += lights add_entities(lights, True)