diff --git a/homeassistant/components/tessie/sensor.py b/homeassistant/components/tessie/sensor.py index aaf37e51d61..7ed1b0416e3 100644 --- a/homeassistant/components/tessie/sensor.py +++ b/homeassistant/components/tessie/sensor.py @@ -22,6 +22,7 @@ from homeassistant.const import ( UnitOfPressure, UnitOfSpeed, UnitOfTemperature, + UnitOfTime, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -181,6 +182,36 @@ DESCRIPTIONS: tuple[TessieSensorEntityDescription, ...] = ( suggested_display_precision=1, entity_category=EntityCategory.DIAGNOSTIC, ), + TessieSensorEntityDescription( + key="drive_state_active_route_traffic_minutes_delay", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfTime.MINUTES, + device_class=SensorDeviceClass.DURATION, + ), + TessieSensorEntityDescription( + key="drive_state_active_route_energy_at_arrival", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=PERCENTAGE, + device_class=SensorDeviceClass.BATTERY, + entity_category=EntityCategory.DIAGNOSTIC, + ), + TessieSensorEntityDescription( + key="drive_state_active_route_miles_to_arrival", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfLength.MILES, + device_class=SensorDeviceClass.DISTANCE, + ), + TessieSensorEntityDescription( + key="drive_state_active_route_minutes_to_arrival", + state_class=SensorStateClass.MEASUREMENT, + native_unit_of_measurement=UnitOfTime.MINUTES, + device_class=SensorDeviceClass.DURATION, + ), + TessieSensorEntityDescription( + key="drive_state_active_route_destination", + icon="mdi:map-marker", + entity_category=EntityCategory.DIAGNOSTIC, + ), ) @@ -194,7 +225,6 @@ async def async_setup_entry( TessieSensorEntity(vehicle.state_coordinator, description) for vehicle in data for description in DESCRIPTIONS - if description.key in vehicle.state_coordinator.data ) @@ -215,4 +245,4 @@ class TessieSensorEntity(TessieEntity, SensorEntity): @property def native_value(self) -> StateType: """Return the state of the sensor.""" - return self.entity_description.value_fn(self._value) + return self.entity_description.value_fn(self.get()) diff --git a/homeassistant/components/tessie/strings.json b/homeassistant/components/tessie/strings.json index c2483b1be8c..be5be229c81 100644 --- a/homeassistant/components/tessie/strings.json +++ b/homeassistant/components/tessie/strings.json @@ -129,6 +129,21 @@ }, "climate_state_passenger_temp_setting": { "name": "Passenger temperature setting" + }, + "active_route_traffic_minutes_delay": { + "name": "Traffic delay" + }, + "active_route_energy_at_arrival": { + "name": "State of charge at arrival" + }, + "active_route_miles_to_arrival": { + "name": "Distance to arrival" + }, + "active_route_time_to_arrival": { + "name": "Time to arrival" + }, + "drive_state_active_route_destination": { + "name": "Destination" } }, "cover": { diff --git a/tests/components/tessie/fixtures/vehicles.json b/tests/components/tessie/fixtures/vehicles.json index e150b9e60e7..c1b0851eee6 100644 --- a/tests/components/tessie/fixtures/vehicles.json +++ b/tests/components/tessie/fixtures/vehicles.json @@ -127,6 +127,10 @@ "active_route_latitude": 30.2226265, "active_route_longitude": -97.6236871, "active_route_traffic_minutes_delay": 0, + "active_route_destination": "Giga Texas", + "active_route_energy_at_arrival": 65, + "active_route_miles_to_arrival": 46.707353, + "active_route_minutes_to_arrival": 59.2, "gps_as_of": 1701129612, "heading": 185, "latitude": -30.222626,