Skip to content
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
24 changes: 14 additions & 10 deletions homeassistant/components/volvo/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from .const import DATA_BATTERY_CAPACITY, DOMAIN

VERY_SLOW_INTERVAL = 60
VERY_SLOW_INTERVAL = 30
SLOW_INTERVAL = 15
MEDIUM_INTERVAL = 2
FAST_INTERVAL = 1
Expand Down Expand Up @@ -214,11 +214,8 @@ async def _async_determine_api_calls(
api = self.context.api

return [
api.async_get_brakes_status,
api.async_get_command_accessibility,
api.async_get_diagnostics,
api.async_get_engine_warnings,
api.async_get_odometer,
api.async_get_statistics,
api.async_get_tyre_states,
api.async_get_warnings,
]
Expand Down Expand Up @@ -260,16 +257,17 @@ async def _async_determine_api_calls(
self,
) -> list[Callable[[], Coroutine[Any, Any, Any]]]:
api = self.context.api
api_calls: list[Any] = [api.async_get_command_accessibility]
api_calls: list[Any] = [
api.async_get_brakes_status,
api.async_get_engine_warnings,
api.async_get_odometer,
]

location = await api.async_get_location()

if location.get("location") is not None:
api_calls.append(api.async_get_location)

if self.context.vehicle.has_combustion_engine():
api_calls.append(api.async_get_fuel_status)

return api_calls


Expand Down Expand Up @@ -299,7 +297,10 @@ async def _async_determine_api_calls(
) -> list[Callable[[], Coroutine[Any, Any, Any]]]:
api = self.context.api
vehicle = self.context.vehicle
api_calls: list[Any] = [api.async_get_engine_status]
api_calls: list[Any] = [
api.async_get_engine_status,
api.async_get_statistics,
]

if vehicle.has_battery_engine():
capabilities = await api.async_get_energy_capabilities()
Expand All @@ -317,6 +318,9 @@ def _normalize_key(key: str) -> str:

api_calls.append(self._async_get_energy_state)

if self.context.vehicle.has_combustion_engine():
api_calls.append(api.async_get_fuel_status)

return api_calls

async def _async_get_energy_state(
Expand Down
130 changes: 65 additions & 65 deletions tests/components/volvo/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@
}),
}),
'Volvo medium interval coordinator': dict({
'averageEnergyConsumption': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:53:44.785000+00:00',
'unit': 'kWh/100km',
'value': 22.6,
}),
'averageSpeed': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km/h',
'value': 53,
}),
'averageSpeedAutomatic': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km/h',
'value': 26,
}),
'batteryChargeLevel': dict({
'extra_data': dict({
'updated_at': '2025-07-02T08:51:23Z',
Expand Down Expand Up @@ -158,6 +179,13 @@
'unit': None,
'value': 'AC',
}),
'distanceToEmptyBattery': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:30:08.338000+00:00',
'unit': 'km',
'value': 250,
}),
'electricRange': dict({
'extra_data': dict({
'updated_at': '2025-07-02T08:51:23Z',
Expand Down Expand Up @@ -192,14 +220,35 @@
'unit': 'percentage',
'value': 90,
}),
'tripMeterAutomatic': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km',
'value': 18.2,
}),
'tripMeterManual': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km',
'value': 3822.9,
}),
}),
'Volvo slow interval coordinator': dict({
'availabilityStatus': dict({
'brakeFluidLevelWarning': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:32:26.169000+00:00',
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': None,
'value': 'AVAILABLE',
'value': 'NO_WARNING',
}),
'engineCoolantLevelWarning': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': None,
'value': 'NO_WARNING',
}),
'location': dict({
'extra_data': dict({
Expand All @@ -218,41 +267,34 @@
}),
'type': 'Feature',
}),
}),
'Volvo very slow interval coordinator': dict({
'averageEnergyConsumption': dict({
'odometer': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:53:44.785000+00:00',
'unit': 'kWh/100km',
'value': 22.6,
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km',
'value': 30000,
}),
'averageSpeed': dict({
'oilLevelWarning': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km/h',
'value': 53,
'unit': None,
'value': 'NO_WARNING',
}),
'averageSpeedAutomatic': dict({
}),
'Volvo very slow interval coordinator': dict({
'availabilityStatus': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km/h',
'value': 26,
'timestamp': '2024-12-30T14:32:26.169000+00:00',
'unit': None,
'value': 'AVAILABLE',
}),
'battery_capacity_kwh': dict({
'extra_data': dict({
}),
'value': 81.608,
}),
'brakeFluidLevelWarning': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': None,
'value': 'NO_WARNING',
}),
'brakeLightCenterWarning': dict({
'extra_data': dict({
}),
Expand Down Expand Up @@ -288,27 +330,13 @@
'unit': None,
'value': 'NO_WARNING',
}),
'distanceToEmptyBattery': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:30:08.338000+00:00',
'unit': 'km',
'value': 250,
}),
'distanceToService': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km',
'value': 29000,
}),
'engineCoolantLevelWarning': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': None,
'value': 'NO_WARNING',
}),
'engineHoursToService': dict({
'extra_data': dict({
}),
Expand Down Expand Up @@ -379,20 +407,6 @@
'unit': None,
'value': 'NO_WARNING',
}),
'odometer': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km',
'value': 30000,
}),
'oilLevelWarning': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': None,
'value': 'NO_WARNING',
}),
'positionLightFrontLeftWarning': dict({
'extra_data': dict({
}),
Expand Down Expand Up @@ -470,20 +484,6 @@
'unit': 'months',
'value': 23,
}),
'tripMeterAutomatic': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km',
'value': 18.2,
}),
'tripMeterManual': dict({
'extra_data': dict({
}),
'timestamp': '2024-12-30T14:18:56.849000+00:00',
'unit': 'km',
'value': 3822.9,
}),
'turnIndicationFrontLeftWarning': dict({
'extra_data': dict({
}),
Expand Down
Loading