mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 08:07:45 +00:00
Change update default entity category based on features (#68455)
This commit is contained in:
parent
add741d789
commit
2424564d2c
@ -186,7 +186,9 @@ class UpdateEntity(RestoreEntity):
|
|||||||
return self._attr_entity_category
|
return self._attr_entity_category
|
||||||
if hasattr(self, "entity_description"):
|
if hasattr(self, "entity_description"):
|
||||||
return self.entity_description.entity_category
|
return self.entity_description.entity_category
|
||||||
return EntityCategory.CONFIG
|
if self.supported_features & UpdateEntityFeature.INSTALL:
|
||||||
|
return EntityCategory.CONFIG
|
||||||
|
return EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def in_progress(self) -> bool | int | None:
|
def in_progress(self) -> bool | int | None:
|
||||||
|
@ -21,6 +21,7 @@ from homeassistant.components.update.const import (
|
|||||||
ATTR_RELEASE_URL,
|
ATTR_RELEASE_URL,
|
||||||
ATTR_SKIPPED_VERSION,
|
ATTR_SKIPPED_VERSION,
|
||||||
ATTR_TITLE,
|
ATTR_TITLE,
|
||||||
|
UpdateEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
@ -53,7 +54,7 @@ async def test_update(hass: HomeAssistant) -> None:
|
|||||||
update._attr_release_url = "https://example.com"
|
update._attr_release_url = "https://example.com"
|
||||||
update._attr_title = "Title"
|
update._attr_title = "Title"
|
||||||
|
|
||||||
assert update.entity_category is EntityCategory.CONFIG
|
assert update.entity_category is EntityCategory.DIAGNOSTIC
|
||||||
assert update.current_version == "1.0.0"
|
assert update.current_version == "1.0.0"
|
||||||
assert update.latest_version == "1.0.1"
|
assert update.latest_version == "1.0.1"
|
||||||
assert update.release_summary == "Summary"
|
assert update.release_summary == "Summary"
|
||||||
@ -86,7 +87,12 @@ async def test_update(hass: HomeAssistant) -> None:
|
|||||||
update._attr_latest_version = None
|
update._attr_latest_version = None
|
||||||
assert update.state is None
|
assert update.state is None
|
||||||
|
|
||||||
|
# Test entity category becomes config when its possible to install
|
||||||
|
update._attr_supported_features = UpdateEntityFeature.INSTALL
|
||||||
|
assert update.entity_category is EntityCategory.CONFIG
|
||||||
|
|
||||||
# UpdateEntityDescription was set
|
# UpdateEntityDescription was set
|
||||||
|
update._attr_supported_features = 0
|
||||||
update.entity_description = UpdateEntityDescription(key="F5 - Its very refreshing")
|
update.entity_description = UpdateEntityDescription(key="F5 - Its very refreshing")
|
||||||
assert update.device_class is None
|
assert update.device_class is None
|
||||||
assert update.entity_category is EntityCategory.CONFIG
|
assert update.entity_category is EntityCategory.CONFIG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user