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