mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Make a copy of capability_attributes instead of making a new dict (#116477)
This commit is contained in:
parent
d39707ee4f
commit
2401580b6f
@ -333,7 +333,7 @@ class InputDatetime(collection.CollectionEntity, RestoreEntity):
|
||||
return self._current_datetime.strftime(FMT_TIME)
|
||||
|
||||
@property
|
||||
def capability_attributes(self) -> dict:
|
||||
def capability_attributes(self) -> dict[str, Any]:
|
||||
"""Return the capability attributes."""
|
||||
return {
|
||||
CONF_HAS_DATE: self.has_date,
|
||||
|
@ -360,7 +360,7 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
|
||||
@property
|
||||
@override
|
||||
def capability_attributes(self) -> Mapping[str, Any] | None:
|
||||
def capability_attributes(self) -> dict[str, Any] | None:
|
||||
"""Return the capability attributes."""
|
||||
if state_class := self.state_class:
|
||||
return {ATTR_STATE_CLASS: state_class}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
from datetime import timedelta
|
||||
from enum import IntFlag
|
||||
from functools import cached_property, partial
|
||||
@ -231,7 +230,7 @@ class StateVacuumEntity(
|
||||
)
|
||||
|
||||
@property
|
||||
def capability_attributes(self) -> Mapping[str, Any] | None:
|
||||
def capability_attributes(self) -> dict[str, Any] | None:
|
||||
"""Return capability attributes."""
|
||||
if VacuumEntityFeature.FAN_SPEED in self.supported_features_compat:
|
||||
return {ATTR_FAN_SPEED_LIST: self.fan_speed_list}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
from datetime import timedelta
|
||||
from enum import IntFlag
|
||||
import functools as ft
|
||||
@ -225,7 +224,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
return PRECISION_WHOLE
|
||||
|
||||
@property
|
||||
def capability_attributes(self) -> Mapping[str, Any]:
|
||||
def capability_attributes(self) -> dict[str, Any]:
|
||||
"""Return capability attributes."""
|
||||
data: dict[str, Any] = {
|
||||
ATTR_MIN_TEMP: show_temp(
|
||||
|
@ -533,7 +533,7 @@ class Entity(
|
||||
_attr_assumed_state: bool = False
|
||||
_attr_attribution: str | None = None
|
||||
_attr_available: bool = True
|
||||
_attr_capability_attributes: Mapping[str, Any] | None = None
|
||||
_attr_capability_attributes: dict[str, Any] | None = None
|
||||
_attr_device_class: str | None
|
||||
_attr_device_info: DeviceInfo | None = None
|
||||
_attr_entity_category: EntityCategory | None
|
||||
@ -744,7 +744,7 @@ class Entity(
|
||||
return self._attr_state
|
||||
|
||||
@cached_property
|
||||
def capability_attributes(self) -> Mapping[str, Any] | None:
|
||||
def capability_attributes(self) -> dict[str, Any] | None:
|
||||
"""Return the capability attributes.
|
||||
|
||||
Attributes that explain the capabilities of an entity.
|
||||
@ -1065,7 +1065,7 @@ class Entity(
|
||||
entry = self.registry_entry
|
||||
|
||||
capability_attr = self.capability_attributes
|
||||
attr = dict(capability_attr) if capability_attr else {}
|
||||
attr = capability_attr.copy() if capability_attr else {}
|
||||
shadowed_attr = {}
|
||||
|
||||
available = self.available # only call self.available once per update cycle
|
||||
|
Loading…
x
Reference in New Issue
Block a user