Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions homeassistant/components/netgear/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import logging

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.core import HomeAssistant, callback
Expand Down Expand Up @@ -79,9 +79,9 @@ def is_connected(self) -> bool:
return self._active

@property
def source_type(self) -> str:
def source_type(self) -> SourceType:
"""Return the source type."""
return SOURCE_TYPE_ROUTER
return SourceType.ROUTER

@property
def ip_address(self) -> str:
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/nmap_tracker/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
from typing import Any

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.core import HomeAssistant, callback
Expand Down Expand Up @@ -93,9 +93,9 @@ def hostname(self) -> str | None:
return short_hostname(self._device.hostname)

@property
def source_type(self) -> str:
def source_type(self) -> SourceType:
"""Return tracker source type."""
return SOURCE_TYPE_ROUTER
return SourceType.ROUTER

@property
def should_poll(self) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/owntracks/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from homeassistant.components.device_tracker.const import (
ATTR_SOURCE_TYPE,
DOMAIN,
SOURCE_TYPE_GPS,
SourceType,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
Expand Down Expand Up @@ -115,9 +115,9 @@ def name(self):
return self._data.get("host_name")

@property
def source_type(self):
def source_type(self) -> SourceType:
"""Return the source type, eg gps or router, of the device."""
return self._data.get("source_type", SOURCE_TYPE_GPS)
return self._data.get("source_type", SourceType.GPS)

@property
def device_info(self) -> DeviceInfo:
Expand Down
9 changes: 3 additions & 6 deletions homeassistant/components/owntracks/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from nacl.secret import SecretBox

from homeassistant.components import zone as zone_comp
from homeassistant.components.device_tracker import (
SOURCE_TYPE_BLUETOOTH_LE,
SOURCE_TYPE_GPS,
)
from homeassistant.components.device_tracker import SourceType
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, STATE_HOME
from homeassistant.util import decorator, slugify

Expand Down Expand Up @@ -84,9 +81,9 @@ def _parse_see_args(message, subscribe_topic):
kwargs["attributes"]["battery_status"] = message["bs"]
if "t" in message:
if message["t"] in ("c", "u"):
kwargs["source_type"] = SOURCE_TYPE_GPS
kwargs["source_type"] = SourceType.GPS
if message["t"] == "b":
kwargs["source_type"] = SOURCE_TYPE_BLUETOOTH_LE
kwargs["source_type"] = SourceType.BLUETOOTH_LE

return dev_id, kwargs

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/person/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from homeassistant.components.device_tracker import (
ATTR_SOURCE_TYPE,
DOMAIN as DEVICE_TRACKER_DOMAIN,
SOURCE_TYPE_GPS,
SourceType,
)
from homeassistant.const import (
ATTR_EDITABLE,
Expand Down Expand Up @@ -469,7 +469,7 @@ def _update_state(self):
if not state or state.state in IGNORE_STATES:
continue

if state.attributes.get(ATTR_SOURCE_TYPE) == SOURCE_TYPE_GPS:
if state.attributes.get(ATTR_SOURCE_TYPE) == SourceType.GPS:
latest_gps = _get_latest(latest_gps, state)
elif state.state == STATE_HOME:
latest_non_gps_home = _get_latest(latest_non_gps_home, state)
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/ping/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from homeassistant.components.device_tracker.const import (
CONF_SCAN_INTERVAL,
SCAN_INTERVAL,
SOURCE_TYPE_ROUTER,
SourceType,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
Expand Down Expand Up @@ -114,7 +114,7 @@ async def async_update(now):
)
await asyncio.gather(
*(
async_see(dev_id=host.dev_id, source_type=SOURCE_TYPE_ROUTER)
async_see(dev_id=host.dev_id, source_type=SourceType.ROUTER)
for idx, host in enumerate(hosts)
if results[idx]
)
Expand All @@ -133,7 +133,7 @@ async def async_update(now):
_LOGGER.debug("Multiping responses: %s", responses)
await asyncio.gather(
*(
async_see(dev_id=dev_id, source_type=SOURCE_TYPE_ROUTER)
async_see(dev_id=dev_id, source_type=SourceType.ROUTER)
for idx, dev_id in enumerate(ip_to_dev_id.values())
if responses[idx].is_alive
)
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/renault/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from renault_api.kamereon.models import KamereonVehicleLocationData

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
Expand Down Expand Up @@ -46,9 +46,9 @@ def longitude(self) -> float | None:
return self.coordinator.data.gpsLongitude if self.coordinator.data else None

@property
def source_type(self) -> str:
def source_type(self) -> SourceType:
"""Return the source type of the device."""
return SOURCE_TYPE_GPS
return SourceType.GPS


DEVICE_TRACKER_TYPES: tuple[RenaultDataEntityDescription, ...] = (
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/ruckus_unleashed/device_tracker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for Ruckus Unleashed devices."""
from __future__ import annotations

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.core import HomeAssistant, callback
Expand Down Expand Up @@ -111,6 +111,6 @@ def is_connected(self) -> bool:
return self._mac in self.coordinator.data[API_CLIENTS]

@property
def source_type(self) -> str:
def source_type(self) -> SourceType:
"""Return the source type."""
return SOURCE_TYPE_ROUTER
return SourceType.ROUTER