Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not return router as source_type for Tractive device_tracker entity #141188

Merged
merged 3 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions homeassistant/components/tractive/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ def __init__(self, client: TractiveClient, item: Trackables) -> None:

@property
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":
return SourceType.BLUETOOTH
if self._source_type == "KNOWN_WIFI":
return SourceType.ROUTER
return SourceType.GPS

@property
Expand Down
28 changes: 28 additions & 0 deletions tests/components/tractive/test_device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,31 @@ async def test_source_type_phone(
hass.states.get("device_tracker.test_pet_tracker").attributes["source_type"]
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
)