mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 13:45:12 +02:00
Code review
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
"""Support for Tile device trackers."""
|
||||
import logging
|
||||
|
||||
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
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import DATA_COORDINATOR, DOMAIN, TileEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTR_ALTITUDE = "altitude"
|
||||
ATTR_CONNECTION_STATE = "connection_state"
|
||||
ATTR_IS_DEAD = "is_dead"
|
||||
@@ -27,6 +33,27 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_scanner(hass, config, async_see, discovery_info=None):
|
||||
"""Detect a legacy configuration and import it."""
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data={
|
||||
CONF_USERNAME: config[CONF_USERNAME],
|
||||
CONF_PASSWORD: config[CONF_PASSWORD],
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
_LOGGER.info(
|
||||
"Your Tile configuration has been imported into the UI; "
|
||||
"please remove it from configuration.yaml"
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class TileDeviceTracker(TileEntity, TrackerEntity):
|
||||
"""Representation of a network infrastructure device."""
|
||||
|
||||
|
Reference in New Issue
Block a user