mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Fix "home" route in Tesla Fleet & Teslemetry (#129546)
* translate Home to home * refactor for mypy * Fix home state * Revert key change * Add testing
This commit is contained in:
parent
39093fc2bc
commit
3656bcf752
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import STATE_HOME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
@ -84,4 +85,7 @@ class TeslaFleetDeviceTrackerRouteEntity(TeslaFleetDeviceTrackerEntity):
|
|||||||
@property
|
@property
|
||||||
def location_name(self) -> str | None:
|
def location_name(self) -> str | None:
|
||||||
"""Return a location name for the current location of the device."""
|
"""Return a location name for the current location of the device."""
|
||||||
return self.get("drive_state_active_route_destination")
|
location = self.get("drive_state_active_route_destination")
|
||||||
|
if location == "Home":
|
||||||
|
return STATE_HOME
|
||||||
|
return location
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||||
|
from homeassistant.const import STATE_HOME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
@ -80,4 +81,7 @@ class TeslemetryDeviceTrackerRouteEntity(TeslemetryDeviceTrackerEntity):
|
|||||||
@property
|
@property
|
||||||
def location_name(self) -> str | None:
|
def location_name(self) -> str | None:
|
||||||
"""Return a location name for the current location of the device."""
|
"""Return a location name for the current location of the device."""
|
||||||
return self.get("drive_state_active_route_destination")
|
location = self.get("drive_state_active_route_destination")
|
||||||
|
if location == "Home":
|
||||||
|
return STATE_HOME
|
||||||
|
return location
|
||||||
|
@ -112,6 +112,7 @@
|
|||||||
"wiper_blade_heater": false
|
"wiper_blade_heater": false
|
||||||
},
|
},
|
||||||
"drive_state": {
|
"drive_state": {
|
||||||
|
"active_route_destination": "Home",
|
||||||
"active_route_latitude": 30.2226265,
|
"active_route_latitude": 30.2226265,
|
||||||
"active_route_longitude": -97.6236871,
|
"active_route_longitude": -97.6236871,
|
||||||
"active_route_miles_to_arrival": 0.039491,
|
"active_route_miles_to_arrival": 0.039491,
|
||||||
|
@ -96,6 +96,6 @@
|
|||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': 'not_home',
|
'state': 'home',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
@ -269,6 +269,7 @@
|
|||||||
'climate_state_timestamp': 1705707520649,
|
'climate_state_timestamp': 1705707520649,
|
||||||
'climate_state_wiper_blade_heater': False,
|
'climate_state_wiper_blade_heater': False,
|
||||||
'color': None,
|
'color': None,
|
||||||
|
'drive_state_active_route_destination': 'Home',
|
||||||
'drive_state_active_route_latitude': '**REDACTED**',
|
'drive_state_active_route_latitude': '**REDACTED**',
|
||||||
'drive_state_active_route_longitude': '**REDACTED**',
|
'drive_state_active_route_longitude': '**REDACTED**',
|
||||||
'drive_state_active_route_miles_to_arrival': 0.039491,
|
'drive_state_active_route_miles_to_arrival': 0.039491,
|
||||||
|
@ -112,6 +112,7 @@
|
|||||||
"wiper_blade_heater": false
|
"wiper_blade_heater": false
|
||||||
},
|
},
|
||||||
"drive_state": {
|
"drive_state": {
|
||||||
|
"active_route_destination": "Home",
|
||||||
"active_route_latitude": 30.2226265,
|
"active_route_latitude": 30.2226265,
|
||||||
"active_route_longitude": -97.6236871,
|
"active_route_longitude": -97.6236871,
|
||||||
"active_route_miles_to_arrival": 0.039491,
|
"active_route_miles_to_arrival": 0.039491,
|
||||||
|
@ -96,6 +96,6 @@
|
|||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': 'not_home',
|
'state': 'home',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
@ -270,6 +270,7 @@
|
|||||||
'climate_state_timestamp': 1705707520649,
|
'climate_state_timestamp': 1705707520649,
|
||||||
'climate_state_wiper_blade_heater': False,
|
'climate_state_wiper_blade_heater': False,
|
||||||
'color': None,
|
'color': None,
|
||||||
|
'drive_state_active_route_destination': 'Home',
|
||||||
'drive_state_active_route_latitude': '**REDACTED**',
|
'drive_state_active_route_latitude': '**REDACTED**',
|
||||||
'drive_state_active_route_longitude': '**REDACTED**',
|
'drive_state_active_route_longitude': '**REDACTED**',
|
||||||
'drive_state_active_route_miles_to_arrival': 0.039491,
|
'drive_state_active_route_miles_to_arrival': 0.039491,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user