Skip to content

Commit 1166c9d

Browse files
bieniuandrewsayre
andauthored
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 <[email protected]>
1 parent 95cc3e3 commit 1166c9d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

homeassistant/components/tractive/device_tracker.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ def __init__(self, client: TractiveClient, item: Trackables) -> None:
5555

5656
@property
5757
def source_type(self) -> SourceType:
58-
"""Return the source type, eg gps or router, of the device."""
58+
"""Return the source type of the device."""
5959
if self._source_type == "PHONE":
6060
return SourceType.BLUETOOTH
61-
if self._source_type == "KNOWN_WIFI":
62-
return SourceType.ROUTER
6361
return SourceType.GPS
6462

6563
@property

tests/components/tractive/test_device_tracker.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,31 @@ async def test_source_type_phone(
5959
hass.states.get("device_tracker.test_pet_tracker").attributes["source_type"]
6060
is SourceType.BLUETOOTH
6161
)
62+
63+
64+
async def test_source_type_gps(
65+
hass: HomeAssistant,
66+
mock_tractive_client: AsyncMock,
67+
mock_config_entry: MockConfigEntry,
68+
) -> None:
69+
"""Test if the source type is GPS when the location sensor is KNOWN WIFI."""
70+
await init_integration(hass, mock_config_entry)
71+
72+
mock_tractive_client.send_position_event(
73+
mock_config_entry,
74+
{
75+
"tracker_id": "device_id_123",
76+
"position": {
77+
"latlong": [22.333, 44.555],
78+
"accuracy": 99,
79+
"sensor_used": "KNOWN_WIFI",
80+
},
81+
},
82+
)
83+
mock_tractive_client.send_hardware_event(mock_config_entry)
84+
await hass.async_block_till_done()
85+
86+
assert (
87+
hass.states.get("device_tracker.test_pet_tracker").attributes["source_type"]
88+
is SourceType.GPS
89+
)

0 commit comments

Comments
 (0)