mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Remove redundant property definitions in Tile (#52448)
This commit is contained in:
parent
8c0559cc57
commit
e29c75a68e
@ -24,14 +24,9 @@ DEFAULT_UPDATE_INTERVAL = timedelta(minutes=2)
|
|||||||
CONF_SHOW_INACTIVE = "show_inactive"
|
CONF_SHOW_INACTIVE = "show_inactive"
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
|
||||||
"""Set up the Tile component."""
|
|
||||||
hass.data[DOMAIN] = {DATA_COORDINATOR: {}, DATA_TILE: {}}
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass, entry):
|
||||||
"""Set up Tile as config entry."""
|
"""Set up Tile as config entry."""
|
||||||
|
hass.data.setdefault(DOMAIN, {DATA_COORDINATOR: {}, DATA_TILE: {}})
|
||||||
hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id] = {}
|
hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id] = {}
|
||||||
hass.data[DOMAIN][DATA_TILE][entry.entry_id] = {}
|
hass.data[DOMAIN][DATA_TILE][entry.entry_id] = {}
|
||||||
|
|
||||||
|
@ -63,35 +63,22 @@ async def async_setup_scanner(hass, config, async_see, discovery_info=None):
|
|||||||
class TileDeviceTracker(CoordinatorEntity, TrackerEntity):
|
class TileDeviceTracker(CoordinatorEntity, TrackerEntity):
|
||||||
"""Representation of a network infrastructure device."""
|
"""Representation of a network infrastructure device."""
|
||||||
|
|
||||||
|
_attr_icon = DEFAULT_ICON
|
||||||
|
|
||||||
def __init__(self, entry, coordinator, tile):
|
def __init__(self, entry, coordinator, tile):
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
|
||||||
|
self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
||||||
|
self._attr_name = tile.name
|
||||||
|
self._attr_unique_id = f"{entry.data[CONF_USERNAME]}_{tile.uuid}"
|
||||||
self._entry = entry
|
self._entry = entry
|
||||||
self._tile = tile
|
self._tile = tile
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
"""Return if entity is available."""
|
"""Return if entity is available."""
|
||||||
return self.coordinator.last_update_success and not self._tile.dead
|
return super().available and not self._tile.dead
|
||||||
|
|
||||||
@property
|
|
||||||
def battery_level(self):
|
|
||||||
"""Return the battery level of the device.
|
|
||||||
|
|
||||||
Percentage from 0-100.
|
|
||||||
"""
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def extra_state_attributes(self):
|
|
||||||
"""Return the device state attributes."""
|
|
||||||
return self._attrs
|
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self):
|
|
||||||
"""Return the icon."""
|
|
||||||
return DEFAULT_ICON
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def location_accuracy(self):
|
def location_accuracy(self):
|
||||||
@ -111,16 +98,6 @@ class TileDeviceTracker(CoordinatorEntity, TrackerEntity):
|
|||||||
"""Return longitude value of the device."""
|
"""Return longitude value of the device."""
|
||||||
return self._tile.longitude
|
return self._tile.longitude
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name."""
|
|
||||||
return self._tile.name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
"""Return the unique ID of the entity."""
|
|
||||||
return f"{self._entry.data[CONF_USERNAME]}_{self._tile.uuid}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_type(self):
|
def source_type(self):
|
||||||
"""Return the source type, eg gps or router, of the device."""
|
"""Return the source type, eg gps or router, of the device."""
|
||||||
@ -135,7 +112,7 @@ class TileDeviceTracker(CoordinatorEntity, TrackerEntity):
|
|||||||
@callback
|
@callback
|
||||||
def _update_from_latest_data(self):
|
def _update_from_latest_data(self):
|
||||||
"""Update the entity from the latest data."""
|
"""Update the entity from the latest data."""
|
||||||
self._attrs.update(
|
self._attr_extra_state_attributes.update(
|
||||||
{
|
{
|
||||||
ATTR_ALTITUDE: self._tile.altitude,
|
ATTR_ALTITUDE: self._tile.altitude,
|
||||||
ATTR_IS_LOST: self._tile.lost,
|
ATTR_IS_LOST: self._tile.lost,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user