mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Do not return router
as source_type
for Tractive device_tracker
entity (#141188)
* Do not return router as source_type * Add test * Update stale docstring --------- Co-authored-by: Andrew Sayre <6730289+andrewsayre@users.noreply.github.com>
This commit is contained in:
parent
95cc3e31f5
commit
1166c9d927
@ -55,11 +55,9 @@ class TractiveDeviceTracker(TractiveEntity, TrackerEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def source_type(self) -> SourceType:
|
def source_type(self) -> SourceType:
|
||||||
"""Return the source type, eg gps or router, of the device."""
|
"""Return the source type of the device."""
|
||||||
if self._source_type == "PHONE":
|
if self._source_type == "PHONE":
|
||||||
return SourceType.BLUETOOTH
|
return SourceType.BLUETOOTH
|
||||||
if self._source_type == "KNOWN_WIFI":
|
|
||||||
return SourceType.ROUTER
|
|
||||||
return SourceType.GPS
|
return SourceType.GPS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -59,3 +59,31 @@ async def test_source_type_phone(
|
|||||||
hass.states.get("device_tracker.test_pet_tracker").attributes["source_type"]
|
hass.states.get("device_tracker.test_pet_tracker").attributes["source_type"]
|
||||||
is SourceType.BLUETOOTH
|
is SourceType.BLUETOOTH
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_source_type_gps(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_tractive_client: AsyncMock,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
) -> None:
|
||||||
|
"""Test if the source type is GPS when the location sensor is KNOWN WIFI."""
|
||||||
|
await init_integration(hass, mock_config_entry)
|
||||||
|
|
||||||
|
mock_tractive_client.send_position_event(
|
||||||
|
mock_config_entry,
|
||||||
|
{
|
||||||
|
"tracker_id": "device_id_123",
|
||||||
|
"position": {
|
||||||
|
"latlong": [22.333, 44.555],
|
||||||
|
"accuracy": 99,
|
||||||
|
"sensor_used": "KNOWN_WIFI",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
mock_tractive_client.send_hardware_event(mock_config_entry)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert (
|
||||||
|
hass.states.get("device_tracker.test_pet_tracker").attributes["source_type"]
|
||||||
|
is SourceType.GPS
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user