mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Fix device tracker TrackerEntity defaults (#32459)
This commit is contained in:
parent
af76a336af
commit
7678d66464
@ -61,10 +61,15 @@ class BaseTrackerEntity(Entity):
|
|||||||
class TrackerEntity(BaseTrackerEntity):
|
class TrackerEntity(BaseTrackerEntity):
|
||||||
"""Represent a tracked device."""
|
"""Represent a tracked device."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def should_poll(self):
|
||||||
|
"""No polling for entities that have location pushed."""
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def force_update(self):
|
def force_update(self):
|
||||||
"""All updates need to be written to the state machine."""
|
"""All updates need to be written to the state machine if we're not polling."""
|
||||||
return True
|
return not self.should_poll
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def location_accuracy(self):
|
def location_accuracy(self):
|
||||||
|
@ -84,11 +84,6 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
|||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
|
@ -107,11 +107,6 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
|
|||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
|
@ -107,11 +107,6 @@ class IcloudTrackerEntity(TrackerEntity):
|
|||||||
"model": self._device.device_model,
|
"model": self._device.device_model,
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self) -> bool:
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Register state update callback."""
|
"""Register state update callback."""
|
||||||
self._unsub_dispatcher = async_dispatcher_connect(
|
self._unsub_dispatcher = async_dispatcher_connect(
|
||||||
|
@ -61,11 +61,6 @@ class LocativeEntity(TrackerEntity):
|
|||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_type(self):
|
def source_type(self):
|
||||||
"""Return the source type, eg gps or router, of the device."""
|
"""Return the source type, eg gps or router, of the device."""
|
||||||
|
@ -100,11 +100,6 @@ class MobileAppEntity(TrackerEntity, RestoreEntity):
|
|||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._entry.data[ATTR_DEVICE_NAME]
|
return self._entry.data[ATTR_DEVICE_NAME]
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_type(self):
|
def source_type(self):
|
||||||
"""Return the source type, eg gps or router, of the device."""
|
"""Return the source type, eg gps or router, of the device."""
|
||||||
|
@ -118,11 +118,6 @@ class OwnTracksEntity(TrackerEntity, RestoreEntity):
|
|||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._data.get("host_name")
|
return self._data.get("host_name")
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_type(self):
|
def source_type(self):
|
||||||
"""Return the source type, eg gps or router, of the device."""
|
"""Return the source type, eg gps or router, of the device."""
|
||||||
|
@ -68,8 +68,3 @@ class TeslaDeviceEntity(TeslaDevice, TrackerEntity):
|
|||||||
def source_type(self):
|
def source_type(self):
|
||||||
"""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 SOURCE_TYPE_GPS
|
||||||
|
|
||||||
@property
|
|
||||||
def force_update(self):
|
|
||||||
"""All updates do not need to be written to the state machine."""
|
|
||||||
return False
|
|
||||||
|
@ -371,11 +371,6 @@ class TraccarEntity(TrackerEntity, RestoreEntity):
|
|||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
|
19
tests/components/device_tracker/test_config_entry.py
Normal file
19
tests/components/device_tracker/test_config_entry.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
"""Test Device Tracker config entry things."""
|
||||||
|
from homeassistant.components.device_tracker import config_entry
|
||||||
|
|
||||||
|
|
||||||
|
def test_tracker_entity():
|
||||||
|
"""Test tracker entity."""
|
||||||
|
|
||||||
|
class TestEntry(config_entry.TrackerEntity):
|
||||||
|
"""Mock tracker class."""
|
||||||
|
|
||||||
|
should_poll = False
|
||||||
|
|
||||||
|
instance = TestEntry()
|
||||||
|
|
||||||
|
assert instance.force_update
|
||||||
|
|
||||||
|
instance.should_poll = True
|
||||||
|
|
||||||
|
assert not instance.force_update
|
Loading…
x
Reference in New Issue
Block a user