Add suggested_unit_of_measurement attribute to sensors (#80638)
* Add suggested_unit_of_measurement attribute to sensors * Lazy calculation of initial entity options * Add type alias for entity options * Small tweak * Add tests * Store suggested_unit_of_measurement in its own option key * Adapt to renaming of IMPERIAL_SYSTEM * Fix rebase mistakes * Apply suggestions from code review Co-authored-by: epenet <6771947+epenet@users.noreply.github.com> Co-authored-by: epenet <6771947+epenet@users.noreply.github.com>
This commit is contained in:
parent
0c79a9a33d
commit
6979cd95b0
9 changed files with 380 additions and 48 deletions
|
@ -340,6 +340,18 @@ class Entity(ABC):
|
|||
"""
|
||||
return self._attr_capability_attributes
|
||||
|
||||
def get_initial_entity_options(self) -> er.EntityOptionsType | None:
|
||||
"""Return initial entity options.
|
||||
|
||||
These will be stored in the entity registry the first time the entity is seen,
|
||||
and then never updated.
|
||||
|
||||
Implemented by component base class, should not be extended by integrations.
|
||||
|
||||
Note: Not a property to avoid calculating unless needed.
|
||||
"""
|
||||
return None
|
||||
|
||||
@property
|
||||
def state_attributes(self) -> dict[str, Any] | None:
|
||||
"""Return the state attributes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue