-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce base entity for Tile (#134109)
- Loading branch information
Showing
2 changed files
with
28 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Define a base Tile entity.""" | ||
|
||
from homeassistant.helpers.device_registry import DeviceInfo | ||
from homeassistant.helpers.update_coordinator import CoordinatorEntity | ||
|
||
from .const import DOMAIN | ||
from .coordinator import TileCoordinator | ||
|
||
|
||
class TileEntity(CoordinatorEntity[TileCoordinator]): | ||
"""Define a base Tile entity.""" | ||
|
||
_attr_has_entity_name = True | ||
|
||
def __init__(self, coordinator: TileCoordinator) -> None: | ||
"""Initialize.""" | ||
super().__init__(coordinator) | ||
self._tile = coordinator.tile | ||
self._attr_device_info = DeviceInfo( | ||
identifiers={(DOMAIN, self._tile.uuid)}, name=self._tile.name | ||
) | ||
|
||
@property | ||
def available(self) -> bool: | ||
"""Return if entity is available.""" | ||
return super().available and not self._tile.dead |