mirror of
https://github.com/home-assistant/core.git
synced 2025-08-06 14:15:12 +02:00
Align Switcher cover platform with changes from light platform (#130094)
Switcher small fix for cover
This commit is contained in:
@@ -41,16 +41,20 @@ async def async_setup_entry(
|
|||||||
def async_add_cover(coordinator: SwitcherDataUpdateCoordinator) -> None:
|
def async_add_cover(coordinator: SwitcherDataUpdateCoordinator) -> None:
|
||||||
"""Add cover from Switcher device."""
|
"""Add cover from Switcher device."""
|
||||||
entities: list[CoverEntity] = []
|
entities: list[CoverEntity] = []
|
||||||
|
|
||||||
if coordinator.data.device_type.category in (
|
if coordinator.data.device_type.category in (
|
||||||
DeviceCategory.SHUTTER,
|
DeviceCategory.SHUTTER,
|
||||||
DeviceCategory.SINGLE_SHUTTER_DUAL_LIGHT,
|
DeviceCategory.SINGLE_SHUTTER_DUAL_LIGHT,
|
||||||
|
DeviceCategory.DUAL_SHUTTER_SINGLE_LIGHT,
|
||||||
):
|
):
|
||||||
entities.append(SwitcherSingleCoverEntity(coordinator, 0))
|
number_of_covers = len(cast(SwitcherShutter, coordinator.data).position)
|
||||||
if (
|
if number_of_covers == 1:
|
||||||
coordinator.data.device_type.category
|
entities.append(SwitcherSingleCoverEntity(coordinator, 0))
|
||||||
== DeviceCategory.DUAL_SHUTTER_SINGLE_LIGHT
|
else:
|
||||||
):
|
entities.extend(
|
||||||
entities.extend(SwitcherDualCoverEntity(coordinator, i) for i in range(2))
|
SwitcherMultiCoverEntity(coordinator, i)
|
||||||
|
for i in range(number_of_covers)
|
||||||
|
)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
config_entry.async_on_unload(
|
config_entry.async_on_unload(
|
||||||
@@ -152,8 +156,8 @@ class SwitcherSingleCoverEntity(SwitcherBaseCoverEntity):
|
|||||||
self._update_data()
|
self._update_data()
|
||||||
|
|
||||||
|
|
||||||
class SwitcherDualCoverEntity(SwitcherBaseCoverEntity):
|
class SwitcherMultiCoverEntity(SwitcherBaseCoverEntity):
|
||||||
"""Representation of a Switcher dual cover entity."""
|
"""Representation of a Switcher multiple cover entity."""
|
||||||
|
|
||||||
_attr_translation_key = "cover"
|
_attr_translation_key = "cover"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user