Improve code quality of the Broadlink light platform (#58790)
This commit is contained in:
parent
7047205fb8
commit
9bc0e8e8ab
1 changed files with 3 additions and 3 deletions
|
@ -28,9 +28,10 @@ BROADLINK_COLOR_MODE_SCENES = 2
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the Broadlink light."""
|
"""Set up the Broadlink light."""
|
||||||
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
||||||
|
lights = []
|
||||||
|
|
||||||
if device.api.type == "LB1":
|
if device.api.type == "LB1":
|
||||||
lights = [BroadlinkLight(device)]
|
lights.append(BroadlinkLight(device))
|
||||||
|
|
||||||
async_add_entities(lights)
|
async_add_entities(lights)
|
||||||
|
|
||||||
|
@ -129,8 +130,7 @@ class BroadlinkLight(BroadlinkEntity, LightEntity):
|
||||||
)
|
)
|
||||||
except (BroadlinkException, OSError) as err:
|
except (BroadlinkException, OSError) as err:
|
||||||
_LOGGER.error("Failed to set state: %s", err)
|
_LOGGER.error("Failed to set state: %s", err)
|
||||||
return False
|
return
|
||||||
|
|
||||||
self._update_state(state)
|
self._update_state(state)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
return True
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue