Fix review requests for BleBox support from #35370 (#35786)

* fix review requests from #35370

* fix pylint W0621 (redefined-outer-name)
This commit is contained in:
gadgetmobile authored and GitHub committed 2020-05-18 22:30:15 +02:00
1 parent 8258fa515d
commit 93fddbed2b
9 files changed
+32 -24

No files matched your search

+4 -2
View File
@@ -74,7 +74,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
@callback
def create_blebox_entities(hass, config_entry, async_add, entity_klass, entity_type):
def create_blebox_entities(
hass, config_entry, async_add_entities, entity_klass, entity_type
):
"""Create entities from a BleBox product's features."""
product = hass.data[DOMAIN][config_entry.entry_id][PRODUCT]
@@ -84,7 +86,7 @@ def create_blebox_entities(hass, config_entry, async_add, entity_klass, entity_t
for feature in product.features[entity_type]:
entities.append(entity_klass(feature))
async_add(entities, True)
async_add_entities(entities, True)
class BleBoxEntity(Entity):
@@ -5,10 +5,10 @@ from homeassistant.components.air_quality import AirQualityEntity
from . import BleBoxEntity, create_blebox_entities
async def async_setup_entry(hass, config_entry, async_add):
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a BleBox air quality entity."""
create_blebox_entities(
hass, config_entry, async_add, BleBoxAirQualityEntity, "air_qualities"
hass, config_entry, async_add_entities, BleBoxAirQualityEntity, "air_qualities"
)
+4 -2
View File
@@ -16,10 +16,12 @@ from . import BleBoxEntity, create_blebox_entities
from .const import BLEBOX_TO_HASS_COVER_STATES, BLEBOX_TO_HASS_DEVICE_CLASSES
async def async_setup_entry(hass, config_entry, async_add):
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a BleBox entry."""
create_blebox_entities(hass, config_entry, async_add, BleBoxCoverEntity, "covers")
create_blebox_entities(
hass, config_entry, async_add_entities, BleBoxCoverEntity, "covers"
)
class BleBoxCoverEntity(BleBoxEntity, CoverEntity):
+8 -6
View File
@@ -24,10 +24,12 @@ from . import BleBoxEntity, create_blebox_entities
_LOGGER = logging.getLogger(__name__)
async def async_setup_entry(hass, config_entry, async_add):
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a BleBox entry."""
create_blebox_entities(hass, config_entry, async_add, BleBoxLightEntity, "lights")
create_blebox_entities(
hass, config_entry, async_add_entities, BleBoxLightEntity, "lights"
)
class BleBoxLightEntity(BleBoxEntity, LightEntity):
@@ -69,9 +71,9 @@ class BleBoxLightEntity(BleBoxEntity, LightEntity):
async def async_turn_on(self, **kwargs):
"""Turn the light on."""
white = kwargs.get(ATTR_WHITE_VALUE, None)
hs_color = kwargs.get(ATTR_HS_COLOR, None)
brightness = kwargs.get(ATTR_BRIGHTNESS, None)
white = kwargs.get(ATTR_WHITE_VALUE)
hs_color = kwargs.get(ATTR_HS_COLOR)
brightness = kwargs.get(ATTR_BRIGHTNESS)
feature = self._feature
value = feature.sensible_on_value
@@ -90,7 +92,7 @@ class BleBoxLightEntity(BleBoxEntity, LightEntity):
await self._feature.async_on(value)
except BadOnValueError as ex:
_LOGGER.error(
"turning on '%s' failed: Bad value %s (%s)", self.name, value, ex
"Turning on '%s' failed: Bad value %s (%s)", self.name, value, ex
)
async def async_turn_off(self, **kwargs):
+4 -2
View File
@@ -6,10 +6,12 @@ from . import BleBoxEntity, create_blebox_entities
from .const import BLEBOX_TO_HASS_DEVICE_CLASSES, BLEBOX_TO_UNIT_MAP
async def async_setup_entry(hass, config_entry, async_add):
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a BleBox entry."""
create_blebox_entities(hass, config_entry, async_add, BleBoxSensorEntity, "sensors")
create_blebox_entities(
hass, config_entry, async_add_entities, BleBoxSensorEntity, "sensors"
)
class BleBoxSensorEntity(BleBoxEntity, Entity):
+2 -2
View File
@@ -5,10 +5,10 @@ from . import BleBoxEntity, create_blebox_entities
from .const import BLEBOX_TO_HASS_DEVICE_CLASSES
async def async_setup_entry(hass, config_entry, async_add):
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up a BleBox switch entity."""
create_blebox_entities(
hass, config_entry, async_add, BleBoxSwitchEntity, "switches"
hass, config_entry, async_add_entities, BleBoxSwitchEntity, "switches"
)