Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
IceBotYT committed Apr 25, 2023
1 parent 7941890 commit c692d31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
33 changes: 16 additions & 17 deletions homeassistant/components/linear_garage_door/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,20 @@ async def async_setup_entry(
coordinator: LinearUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id]
data = coordinator.data

device_list = []
device_list: list[LinearCoverEntity] = []

for device_id in data:
for subdev in data[device_id]["subdevices"]:
if subdev in SUPPORTED_SUBDEVICES:
device_list.append(
LinearCoverEntity(
device_id=device_id,
device_name=data[device_id]["name"],
subdevice=subdev,
config_entry=config_entry,
coordinator=coordinator,
)
)

device_list.extend(
LinearCoverEntity(
device_id=device_id,
device_name=data[device_id]["name"],
subdevice=subdev,
config_entry=config_entry,
coordinator=coordinator,
)
for subdev in data[device_id]["subdevices"]
if subdev in SUPPORTED_SUBDEVICES
)
async_add_entities(device_list)


Expand Down Expand Up @@ -88,7 +87,7 @@ def device_info(self) -> DeviceInfo:
)

@property
def is_closed(self) -> bool:
def is_closed(self) -> bool: # sourcery skip: remove-unnecessary-cast
"""Return if cover is closed."""
return bool(
self.coordinator.data[self._device_id]["subdevices"][self._subdevice][
Expand All @@ -98,7 +97,7 @@ def is_closed(self) -> bool:
)

@property
def is_opened(self) -> bool:
def is_opened(self) -> bool: # sourcery skip: remove-unnecessary-cast
"""Return if cover is open."""
return bool(
self.coordinator.data[self._device_id]["subdevices"][self._subdevice][
Expand All @@ -108,7 +107,7 @@ def is_opened(self) -> bool:
)

@property
def is_opening(self) -> bool:
def is_opening(self) -> bool: # sourcery skip: remove-unnecessary-cast
"""Return if cover is opening."""
return bool(
self.coordinator.data[self._device_id]["subdevices"][self._subdevice].get(
Expand All @@ -118,7 +117,7 @@ def is_opening(self) -> bool:
)

@property
def is_closing(self) -> bool:
def is_closing(self) -> bool: # sourcery skip: remove-unnecessary-cast
"""Return if cover is closing."""
return bool(
self.coordinator.data[self._device_id]["subdevices"][self._subdevice].get(
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/components/linear_garage_door/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ async def async_get_config_entry_diagnostics(
"""Return diagnostics for a config entry."""
coordinator: LinearUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]

diag_data = {
return {
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
"coordinator_data": coordinator.data,
}

return diag_data

0 comments on commit c692d31

Please sign in to comment.