Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions homeassistant/components/group/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ATTR_CURRENT_TILT_POSITION,
ATTR_POSITION,
ATTR_TILT_POSITION,
DEVICE_CLASSES_SCHEMA,
DOMAIN,
PLATFORM_SCHEMA,
SERVICE_CLOSE_COVER,
Expand All @@ -34,6 +35,7 @@
ATTR_ASSUMED_STATE,
ATTR_ENTITY_ID,
ATTR_SUPPORTED_FEATURES,
CONF_DEVICE_CLASS,
CONF_ENTITIES,
CONF_NAME,
CONF_UNIQUE_ID,
Expand Down Expand Up @@ -63,6 +65,7 @@
vol.Required(CONF_ENTITIES): cv.entities_domain(DOMAIN),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_UNIQUE_ID): cv.string,
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
}
)

Expand All @@ -77,7 +80,10 @@ async def async_setup_platform(
async_add_entities(
[
CoverGroup(
config.get(CONF_UNIQUE_ID), config[CONF_NAME], config[CONF_ENTITIES]
config.get(CONF_UNIQUE_ID),
config[CONF_NAME],
config.get(CONF_DEVICE_CLASS),
config[CONF_ENTITIES],
)
]
)
Expand All @@ -92,7 +98,13 @@ class CoverGroup(GroupEntity, CoverEntity):
_attr_current_cover_position: int | None = 100
_attr_assumed_state: bool = True

def __init__(self, unique_id: str | None, name: str, entities: list[str]) -> None:
def __init__(
self,
unique_id: str | None,
name: str,
device_class: str | None,
entities: list[str],
) -> None:
"""Initialize a CoverGroup entity."""
self._entities = entities
self._covers: dict[str, set[str]] = {
Expand All @@ -109,6 +121,7 @@ def __init__(self, unique_id: str | None, name: str, entities: list[str]) -> Non
self._attr_name = name
self._attr_extra_state_attributes = {ATTR_ENTITY_ID: entities}
self._attr_unique_id = unique_id
self._device_class = device_class

async def _update_supported_features_event(self, event: Event) -> None:
self.async_set_context(event.context)
Expand Down Expand Up @@ -324,3 +337,8 @@ async def async_update(self) -> None:
if state and state.attributes.get(ATTR_ASSUMED_STATE):
self._attr_assumed_state = True
break

@property
def device_class(self) -> str | None:
"""Return the device class of the cover."""
return self._device_class
3 changes: 3 additions & 0 deletions tests/components/group/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
ATTR_ENTITY_ID,
ATTR_FRIENDLY_NAME,
ATTR_SUPPORTED_FEATURES,
CONF_DEVICE_CLASS,
CONF_ENTITIES,
CONF_UNIQUE_ID,
SERVICE_CLOSE_COVER,
Expand Down Expand Up @@ -81,6 +82,7 @@
"platform": "group",
CONF_ENTITIES: [DEMO_COVER, DEMO_COVER_POS, DEMO_COVER_TILT, DEMO_TILT],
CONF_UNIQUE_ID: "unique_identifier",
CONF_DEVICE_CLASS: "garage",
}
}

Expand Down Expand Up @@ -357,6 +359,7 @@ async def test_attributes(hass, setup_comp):
entry = entity_registry.async_get(COVER_GROUP)
assert entry
assert entry.unique_id == "unique_identifier"
assert entry.original_device_class == "garage"


@pytest.mark.parametrize("config_count", [(CONFIG_TILT_ONLY, 2)])
Expand Down