mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use device_tracker SourceType enum [s-z] (#75966)
This commit is contained in:
parent
7b1463e03d
commit
c9ddb10024
@ -1,6 +1,6 @@
|
||||
"""StarLine device tracker."""
|
||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||
from homeassistant.components.device_tracker.const import SOURCE_TYPE_GPS
|
||||
from homeassistant.components.device_tracker.const import SourceType
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -56,9 +56,9 @@ class StarlineDeviceTracker(StarlineEntity, TrackerEntity, RestoreEntity):
|
||||
return self._device.position["y"]
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return the source type, eg gps or router, of the device."""
|
||||
return SOURCE_TYPE_GPS
|
||||
return SourceType.GPS
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
@ -7,7 +7,7 @@ from pytile.tile import Tile
|
||||
|
||||
from homeassistant.components.device_tracker import AsyncSeeCallback
|
||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||
from homeassistant.components.device_tracker.const import SOURCE_TYPE_GPS
|
||||
from homeassistant.components.device_tracker.const import SourceType
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -122,9 +122,9 @@ class TileDeviceTracker(CoordinatorEntity, TrackerEntity):
|
||||
return self._tile.longitude
|
||||
|
||||
@property
|
||||
def source_type(self) -> str:
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return the source type, eg gps or router, of the device."""
|
||||
return SOURCE_TYPE_GPS
|
||||
return SourceType.GPS
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
|
@ -19,8 +19,8 @@ import voluptuous as vol
|
||||
from homeassistant.components.device_tracker import (
|
||||
CONF_SCAN_INTERVAL,
|
||||
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
|
||||
SOURCE_TYPE_GPS,
|
||||
AsyncSeeCallback,
|
||||
SourceType,
|
||||
)
|
||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -407,9 +407,9 @@ class TraccarEntity(TrackerEntity, RestoreEntity):
|
||||
return {"name": self._name, "identifiers": {(DOMAIN, self._unique_id)}}
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return the source type, eg gps or router, of the device."""
|
||||
return SOURCE_TYPE_GPS
|
||||
return SourceType.GPS
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register state update callback."""
|
||||
|
@ -3,10 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.device_tracker import (
|
||||
SOURCE_TYPE_BLUETOOTH,
|
||||
SOURCE_TYPE_GPS,
|
||||
)
|
||||
from homeassistant.components.device_tracker import SourceType
|
||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -56,11 +53,11 @@ class TractiveDeviceTracker(TractiveEntity, TrackerEntity):
|
||||
self._attr_unique_id = item.trackable["_id"]
|
||||
|
||||
@property
|
||||
def source_type(self) -> str:
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return the source type, eg gps or router, of the device."""
|
||||
if self._source_type == "PHONE":
|
||||
return SOURCE_TYPE_BLUETOOTH
|
||||
return SOURCE_TYPE_GPS
|
||||
return SourceType.BLUETOOTH
|
||||
return SourceType.GPS
|
||||
|
||||
@property
|
||||
def latitude(self) -> float:
|
||||
|
@ -19,7 +19,7 @@ from aiounifi.events import (
|
||||
|
||||
from homeassistant.components.device_tracker import DOMAIN
|
||||
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
||||
from homeassistant.components.device_tracker.const import SOURCE_TYPE_ROUTER
|
||||
from homeassistant.components.device_tracker.const import SourceType
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
@ -276,9 +276,9 @@ class UniFiClientTracker(UniFiClientBase, ScannerEntity):
|
||||
return self._is_connected
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return the source type of the client."""
|
||||
return SOURCE_TYPE_ROUTER
|
||||
return SourceType.ROUTER
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
@ -406,9 +406,9 @@ class UniFiDeviceTracker(UniFiBase, ScannerEntity):
|
||||
return self._is_connected
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return the source type of the device."""
|
||||
return SOURCE_TYPE_ROUTER
|
||||
return SourceType.ROUTER
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Support for tracking a Volvo."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.device_tracker import SOURCE_TYPE_GPS, AsyncSeeCallback
|
||||
from homeassistant.components.device_tracker import AsyncSeeCallback, SourceType
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
@ -31,7 +31,7 @@ async def async_setup_scanner(
|
||||
await async_see(
|
||||
dev_id=dev_id,
|
||||
host_name=host_name,
|
||||
source_type=SOURCE_TYPE_GPS,
|
||||
source_type=SourceType.GPS,
|
||||
gps=instrument.state,
|
||||
icon="mdi:car",
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
import functools
|
||||
import time
|
||||
|
||||
from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER
|
||||
from homeassistant.components.device_tracker import SourceType
|
||||
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
@ -85,9 +85,9 @@ class ZHADeviceScannerEntity(ScannerEntity, ZhaEntity):
|
||||
return self._connected
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return the source type, eg gps or router, of the device."""
|
||||
return SOURCE_TYPE_ROUTER
|
||||
return SourceType.ROUTER
|
||||
|
||||
@callback
|
||||
def async_battery_percentage_remaining_updated(self, attr_id, attr_name, value):
|
||||
|
Loading…
x
Reference in New Issue
Block a user