mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Use device_tracker SourceType enum [h-m] (#75964)
This commit is contained in:
parent
450b7cd644
commit
f068fc8eb7
@ -11,7 +11,7 @@ from stringcase import snakecase
|
||||
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
||||
from homeassistant.components.device_tracker.const import (
|
||||
DOMAIN as DEVICE_TRACKER_DOMAIN,
|
||||
SOURCE_TYPE_ROUTER,
|
||||
SourceType,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -194,9 +194,9 @@ class HuaweiLteScannerEntity(HuaweiLteBaseEntity, ScannerEntity):
|
||||
return self.mac_address
|
||||
|
||||
@property
|
||||
def source_type(self) -> str:
|
||||
"""Return SOURCE_TYPE_ROUTER."""
|
||||
return SOURCE_TYPE_ROUTER
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return SourceType.ROUTER."""
|
||||
return SourceType.ROUTER
|
||||
|
||||
@property
|
||||
def ip_address(self) -> str | None:
|
||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.device_tracker import SOURCE_TYPE_GPS, AsyncSeeCallback
|
||||
from homeassistant.components.device_tracker import AsyncSeeCallback, SourceType
|
||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -105,9 +105,9 @@ class IcloudTrackerEntity(TrackerEntity):
|
||||
return self._device.battery_level
|
||||
|
||||
@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
|
||||
|
||||
@property
|
||||
def icon(self) -> str:
|
||||
|
@ -7,7 +7,7 @@ from ndms2_client import Device
|
||||
|
||||
from homeassistant.components.device_tracker import (
|
||||
DOMAIN as DEVICE_TRACKER_DOMAIN,
|
||||
SOURCE_TYPE_ROUTER,
|
||||
SourceType,
|
||||
)
|
||||
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -109,9 +109,9 @@ class KeeneticTracker(ScannerEntity):
|
||||
)
|
||||
|
||||
@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 name(self) -> str:
|
||||
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, cast
|
||||
|
||||
from homeassistant.components.device_tracker import 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.const import ATTR_BATTERY_CHARGING
|
||||
@ -192,9 +192,9 @@ class Life360DeviceTracker(CoordinatorEntity, TrackerEntity):
|
||||
return self._data.battery_level
|
||||
|
||||
@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
|
||||
|
||||
@property
|
||||
def location_accuracy(self) -> int:
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""Support for the Locative platform."""
|
||||
from homeassistant.components.device_tracker import 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
|
||||
@ -60,9 +60,9 @@ class LocativeEntity(TrackerEntity):
|
||||
return self._name
|
||||
|
||||
@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."""
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""Platform for Mazda device tracker integration."""
|
||||
from homeassistant.components.device_tracker import 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
|
||||
@ -40,9 +40,9 @@ class MazdaDeviceTracker(MazdaEntity, TrackerEntity):
|
||||
self._attr_unique_id = self.vin
|
||||
|
||||
@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 latitude(self):
|
||||
|
@ -9,8 +9,8 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.device_tracker import (
|
||||
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
|
||||
SOURCE_TYPE_ROUTER,
|
||||
AsyncSeeCallback,
|
||||
SourceType,
|
||||
)
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -127,7 +127,7 @@ class MerakiView(HomeAssistantView):
|
||||
self.async_see(
|
||||
gps=gps_location,
|
||||
mac=mac,
|
||||
source_type=SOURCE_TYPE_ROUTER,
|
||||
source_type=SourceType.ROUTER,
|
||||
gps_accuracy=accuracy,
|
||||
attributes=attrs,
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ from typing import Any
|
||||
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
||||
from homeassistant.components.device_tracker.const import (
|
||||
DOMAIN as DEVICE_TRACKER,
|
||||
SOURCE_TYPE_ROUTER,
|
||||
SourceType,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -101,9 +101,9 @@ class MikrotikDataUpdateCoordinatorTracker(
|
||||
return False
|
||||
|
||||
@property
|
||||
def source_type(self) -> str:
|
||||
def source_type(self) -> SourceType:
|
||||
"""Return the source type of the client."""
|
||||
return SOURCE_TYPE_ROUTER
|
||||
return SourceType.ROUTER
|
||||
|
||||
@property
|
||||
def hostname(self) -> str:
|
||||
|
Loading…
x
Reference in New Issue
Block a user