Perform some Tile code cleanup (#58868)

This commit is contained in:
Aaron Bach 2021-11-01 02:03:54 -06:00 committed by GitHub
parent 5836a39f14
commit d024c5e698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -30,8 +30,6 @@ CONF_SHOW_INACTIVE = "show_inactive"
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Tile as config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {}
@callback
def async_migrate_callback(entity_entry: RegistryEntry) -> dict | None:
@ -100,8 +98,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
coordinator_init_tasks.append(coordinator.async_refresh())
await gather_with_concurrency(DEFAULT_INIT_TASK_LIMIT, *coordinator_init_tasks)
hass.data[DOMAIN][entry.entry_id][DATA_COORDINATOR] = coordinators
hass.data[DOMAIN][entry.entry_id][DATA_TILE] = tiles
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
DATA_COORDINATOR: coordinators,
DATA_TILE: tiles,
}
hass.config_entries.async_setup_platforms(entry, PLATFORMS)

View File

@ -10,7 +10,7 @@ from pytile.tile import Tile
from homeassistant.components.device_tracker.config_entry import TrackerEntity
from homeassistant.components.device_tracker.const import SOURCE_TYPE_GPS
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION, CONF_PASSWORD, CONF_USERNAME
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType
@ -32,7 +32,6 @@ ATTR_RING_STATE = "ring_state"
ATTR_TILE_NAME = "tile_name"
ATTR_VOIP_STATE = "voip_state"
DEFAULT_ATTRIBUTION = "Data provided by Tile"
DEFAULT_ICON = "mdi:view-grid"
@ -89,7 +88,7 @@ class TileDeviceTracker(CoordinatorEntity, TrackerEntity):
"""Initialize."""
super().__init__(coordinator)
self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
self._attr_extra_state_attributes = {}
self._attr_name = tile.name
self._attr_unique_id = f"{entry.data[CONF_USERNAME]}_{tile.uuid}"
self._entry = entry