From 8a9a1c5feda94de69f4aa4443c3cc17f169627ab Mon Sep 17 00:00:00 2001 From: Brett Adams Date: Fri, 29 May 2026 15:55:44 +1000 Subject: [PATCH] Move Tesla Fleet route destination from device tracker to a sensor (#172513) Co-authored-by: Claude Opus 4.8 --- .../components/tesla_fleet/device_tracker.py | 9 --- .../components/tesla_fleet/sensor.py | 4 ++ .../snapshots/test_device_tracker.ambr | 2 +- .../tesla_fleet/snapshots/test_sensor.ambr | 63 +++++++++++++++++++ 4 files changed, 68 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/tesla_fleet/device_tracker.py b/homeassistant/components/tesla_fleet/device_tracker.py index 1bb299d8d07..4ac2042822d 100644 --- a/homeassistant/components/tesla_fleet/device_tracker.py +++ b/homeassistant/components/tesla_fleet/device_tracker.py @@ -2,7 +2,6 @@ from homeassistant.components.device_tracker import TrackerEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import STATE_HOME from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from homeassistant.helpers.restore_state import RestoreEntity @@ -83,11 +82,3 @@ class TeslaFleetDeviceTrackerRouteEntity(TeslaFleetDeviceTrackerEntity): self.get("drive_state_active_route_longitude", False) is None or self.get("drive_state_active_route_latitude", False) is None ) - - @property - def location_name(self) -> str | None: - """Return a location name for the current location of the device.""" - location = self.get("drive_state_active_route_destination") - if location == "Home": - return STATE_HOME - return location diff --git a/homeassistant/components/tesla_fleet/sensor.py b/homeassistant/components/tesla_fleet/sensor.py index b33a8e1fb2f..0603e89ca88 100644 --- a/homeassistant/components/tesla_fleet/sensor.py +++ b/homeassistant/components/tesla_fleet/sensor.py @@ -280,6 +280,10 @@ VEHICLE_DESCRIPTIONS: tuple[TeslaFleetSensorEntityDescription, ...] = ( native_unit_of_measurement=UnitOfLength.MILES, device_class=SensorDeviceClass.DISTANCE, ), + TeslaFleetSensorEntityDescription( + key="drive_state_active_route_destination", + entity_registry_enabled_default=False, + ), ) diff --git a/tests/components/tesla_fleet/snapshots/test_device_tracker.ambr b/tests/components/tesla_fleet/snapshots/test_device_tracker.ambr index 36b107c3517..c7729ce7b19 100644 --- a/tests/components/tesla_fleet/snapshots/test_device_tracker.ambr +++ b/tests/components/tesla_fleet/snapshots/test_device_tracker.ambr @@ -108,6 +108,6 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'home', + 'state': 'not_home', }) # --- diff --git a/tests/components/tesla_fleet/snapshots/test_sensor.ambr b/tests/components/tesla_fleet/snapshots/test_sensor.ambr index d778fae8f69..62580e09753 100644 --- a/tests/components/tesla_fleet/snapshots/test_sensor.ambr +++ b/tests/components/tesla_fleet/snapshots/test_sensor.ambr @@ -3216,6 +3216,69 @@ 'state': 'stopped', }) # --- +# name: test_sensors[sensor.test_destination-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.test_destination', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Destination', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Destination', + 'platform': 'tesla_fleet', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'drive_state_active_route_destination', + 'unique_id': 'LRWXF7EK4KC700000-drive_state_active_route_destination', + 'unit_of_measurement': None, + }) +# --- +# name: test_sensors[sensor.test_destination-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Destination', + }), + 'context': , + 'entity_id': 'sensor.test_destination', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'Home', + }) +# --- +# name: test_sensors[sensor.test_destination-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Destination', + }), + 'context': , + 'entity_id': 'sensor.test_destination', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_sensors[sensor.test_distance_to_arrival-entry] EntityRegistryEntrySnapshot({ 'aliases': list([