Fix device tracker TrackerEntity defaults (#32459)
This commit is contained in:
parent
af76a336af
commit
7678d66464
10 changed files with 26 additions and 42 deletions
|
@ -61,10 +61,15 @@ class BaseTrackerEntity(Entity):
|
|||
class TrackerEntity(BaseTrackerEntity):
|
||||
"""Represent a tracked device."""
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling for entities that have location pushed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def force_update(self):
|
||||
"""All updates need to be written to the state machine."""
|
||||
return True
|
||||
"""All updates need to be written to the state machine if we're not polling."""
|
||||
return not self.should_poll
|
||||
|
||||
@property
|
||||
def location_accuracy(self):
|
||||
|
|
|
@ -84,11 +84,6 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
|||
"""Return the name of the device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
|
|
|
@ -107,11 +107,6 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
|
|||
"""Return the name of the device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
|
|
|
@ -107,11 +107,6 @@ class IcloudTrackerEntity(TrackerEntity):
|
|||
"model": self._device.device_model,
|
||||
}
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register state update callback."""
|
||||
self._unsub_dispatcher = async_dispatcher_connect(
|
||||
|
|
|
@ -61,11 +61,6 @@ class LocativeEntity(TrackerEntity):
|
|||
"""Return the name of the device."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
"""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 self._entry.data[ATTR_DEVICE_NAME]
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
"""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 self._data.get("host_name")
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
"""Return the source type, eg gps or router, of the device."""
|
||||
|
|
|
@ -68,8 +68,3 @@ class TeslaDeviceEntity(TeslaDevice, TrackerEntity):
|
|||
def source_type(self):
|
||||
"""Return the source type, eg gps or router, of the device."""
|
||||
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 self._name
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling needed."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""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…
Add table
Add a link
Reference in a new issue