Remove redundant source_type property from ScannerEntities (#126716)

pull/126729/head
epenet 2024-09-25 08:58:54 +02:00 committed by GitHub
parent a3c2a7e1e0
commit b48c439bff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 9 additions and 78 deletions

View File

@ -2,7 +2,7 @@
from __future__ import annotations
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -71,11 +71,6 @@ class AsusWrtDevice(ScannerEntity):
"""Return true if the device is connected to the network."""
return self._device.is_connected
@property
def source_type(self) -> SourceType:
"""Return the source type."""
return SourceType.ROUTER
@property
def hostname(self) -> str | None:
"""Return the hostname of device."""

View File

@ -5,7 +5,7 @@ from __future__ import annotations
from datetime import datetime
from typing import Any
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -98,11 +98,6 @@ class FreeboxDevice(ScannerEntity):
"""Return true if the device is connected to the network."""
return self._active
@property
def source_type(self) -> SourceType:
"""Return the source type."""
return SourceType.ROUTER
@callback
def async_on_demand_update(self) -> None:
"""Update state."""

View File

@ -5,7 +5,7 @@ from __future__ import annotations
import datetime
import logging
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -112,8 +112,3 @@ class FritzBoxTracker(FritzDeviceBase, ScannerEntity):
if device.ssid:
attrs["ssid"] = device.ssid
return attrs
@property
def source_type(self) -> SourceType:
"""Return tracker source type."""
return SourceType.ROUTER

View File

@ -11,7 +11,6 @@ from stringcase import snakecase
from homeassistant.components.device_tracker import (
DOMAIN as DEVICE_TRACKER_DOMAIN,
ScannerEntity,
SourceType,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
@ -195,11 +194,6 @@ class HuaweiLteScannerEntity(HuaweiLteBaseEntity, ScannerEntity):
def _device_unique_id(self) -> str:
return self.mac_address
@property
def source_type(self) -> SourceType:
"""Return SourceType.ROUTER."""
return SourceType.ROUTER
@property
def ip_address(self) -> str | None:
"""Return the primary ip address of the device."""

View File

@ -9,7 +9,6 @@ from ndms2_client import Device
from homeassistant.components.device_tracker import (
DOMAIN as DEVICE_TRACKER_DOMAIN,
ScannerEntity,
SourceType,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
@ -103,11 +102,6 @@ class KeeneticTracker(ScannerEntity):
< self._router.consider_home_interval
)
@property
def source_type(self) -> SourceType:
"""Return the source type of the client."""
return SourceType.ROUTER
@property
def name(self) -> str:
"""Return the name of the device."""

View File

@ -7,7 +7,6 @@ from typing import Any
from homeassistant.components.device_tracker import (
DOMAIN as DEVICE_TRACKER,
ScannerEntity,
SourceType,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
@ -94,11 +93,6 @@ class MikrotikDataUpdateCoordinatorTracker(
return True
return False
@property
def source_type(self) -> SourceType:
"""Return the source type of the client."""
return SourceType.ROUTER
@property
def hostname(self) -> str:
"""Return the hostname of the client."""

View File

@ -4,7 +4,7 @@ from __future__ import annotations
import logging
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -81,11 +81,6 @@ class NetgearScannerEntity(NetgearDeviceEntity, ScannerEntity):
"""Return true if the device is connected to the router."""
return self._active
@property
def source_type(self) -> SourceType:
"""Return the source type."""
return SourceType.ROUTER
@property
def ip_address(self) -> str:
"""Return the IP address."""

View File

@ -5,7 +5,7 @@ from __future__ import annotations
import logging
from typing import Any
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -95,11 +95,6 @@ class NmapTrackerEntity(ScannerEntity):
return None
return short_hostname(self._device.hostname)
@property
def source_type(self) -> SourceType:
"""Return tracker source type."""
return SourceType.ROUTER
@callback
def async_process_update(self, online: bool) -> None:
"""Update device."""

View File

@ -8,7 +8,6 @@ from homeassistant.components.device_tracker import (
CONF_CONSIDER_HOME,
DEFAULT_CONSIDER_HOME,
ScannerEntity,
SourceType,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
@ -57,11 +56,6 @@ class PingDeviceTracker(CoordinatorEntity[PingUpdateCoordinator], ScannerEntity)
"""Return a unique ID."""
return self.config_entry.entry_id
@property
def source_type(self) -> SourceType:
"""Return the source type which is router."""
return SourceType.ROUTER
@property
def is_connected(self) -> bool:
"""Return true if ping returns is_alive or considered home."""

View File

@ -4,7 +4,7 @@ from __future__ import annotations
import logging
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
@ -121,8 +121,3 @@ class RuckusDevice(CoordinatorEntity, ScannerEntity):
def is_connected(self) -> bool:
"""Return true if the device is connected to the network."""
return self._mac in self.coordinator.data[KEY_SYS_CLIENTS]
@property
def source_type(self) -> SourceType:
"""Return the source type."""
return SourceType.ROUTER

View File

@ -4,7 +4,7 @@ import logging
from tplink_omada_client.clients import OmadaWirelessClient
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -61,11 +61,6 @@ class OmadaClientScannerEntity(
self._client_id = client_id
self._attr_name = display_name
@property
def source_type(self) -> SourceType:
"""Return the source type of the device."""
return SourceType.ROUTER
def _do_update(self) -> None:
self._client_details = self.coordinator.data.get(self._client_id)

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from aiovodafone import VodafoneStationDevice
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -91,11 +91,6 @@ class VodafoneStationTracker(CoordinatorEntity[VodafoneStationRouter], ScannerEn
"""Return true if the device is connected to the network."""
return self._device_info.home
@property
def source_type(self) -> SourceType:
"""Return the source type."""
return SourceType.ROUTER
@property
def hostname(self) -> str | None:
"""Return the hostname of device."""

View File

@ -4,7 +4,7 @@ from __future__ import annotations
import functools
from homeassistant.components.device_tracker import ScannerEntity, SourceType
from homeassistant.components.device_tracker import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
@ -53,11 +53,6 @@ class ZHADeviceScannerEntity(ScannerEntity, ZHAEntity):
"""Return true if the device is connected to the network."""
return self.entity_data.entity.is_connected
@property
def source_type(self) -> SourceType:
"""Return the source type, eg gps or router, of the device."""
return SourceType.ROUTER
@property
def battery_level(self) -> int | None:
"""Return the battery level of the device.