Improve autodiscovered yeelights model detection (#24671)
* Improve autodiscovered yeelights model detection * Lint fixes * Logger warn fixpull/24839/head
parent
072879cc6e
commit
c6e8e2398c
|
@ -122,17 +122,12 @@ def setup(hass, config):
|
||||||
def device_discovered(_, info):
|
def device_discovered(_, info):
|
||||||
_LOGGER.debug("Adding autodetected %s", info['hostname'])
|
_LOGGER.debug("Adding autodetected %s", info['hostname'])
|
||||||
|
|
||||||
device_type = info['device_type']
|
name = "yeelight_%s_%s" % (info['device_type'],
|
||||||
|
|
||||||
name = "yeelight_%s_%s" % (device_type,
|
|
||||||
info['properties']['mac'])
|
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)
|
discovery.listen(hass, SERVICE_YEELIGHT, device_discovered)
|
||||||
|
|
||||||
|
|
|
@ -178,8 +178,10 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
_lights_setup_helper(YeelightWithAmbientLight)
|
_lights_setup_helper(YeelightWithAmbientLight)
|
||||||
_lights_setup_helper(YeelightAmbientLight)
|
_lights_setup_helper(YeelightAmbientLight)
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Cannot determine device type for %s, %s",
|
_lights_setup_helper(YeelightGenericLight)
|
||||||
device.ipaddr, device.name)
|
_LOGGER.warning("Cannot determine device type for %s, %s. "
|
||||||
|
"Falling back to white only", device.ipaddr,
|
||||||
|
device.name)
|
||||||
|
|
||||||
hass.data[data_key] += lights
|
hass.data[data_key] += lights
|
||||||
add_entities(lights, True)
|
add_entities(lights, True)
|
||||||
|
|
Loading…
Reference in New Issue