Skip to content

Commit 762c179

Browse files
thomasddnfrenck
authored andcommitted
Volvo: fix missing charging power options (home-assistant#150272)
1 parent 6601995 commit 762c179

File tree

4 files changed

+45
-31
lines changed

4 files changed

+45
-31
lines changed

homeassistant/components/volvo/sensor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ def _charging_power_status_value(field: VolvoCarsValue) -> str | None:
8787
return None
8888

8989

90-
_CHARGING_POWER_STATUS_OPTIONS = ["providing_power", "no_power_available"]
90+
_CHARGING_POWER_STATUS_OPTIONS = [
91+
"fault",
92+
"power_available_but_not_activated",
93+
"providing_power",
94+
"no_power_available",
95+
]
9196

9297
_DESCRIPTIONS: tuple[VolvoSensorDescription, ...] = (
9398
# command-accessibility endpoint

homeassistant/components/volvo/strings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"state": {
9595
"connected": "[%key:common::state::connected%]",
9696
"disconnected": "[%key:common::state::disconnected%]",
97-
"fault": "[%key:common::state::error%]"
97+
"fault": "[%key:common::state::fault%]"
9898
}
9999
},
100100
"charging_current_limit": {
@@ -106,6 +106,8 @@
106106
"charging_power_status": {
107107
"name": "Charging power status",
108108
"state": {
109+
"fault": "[%key:common::state::fault%]",
110+
"power_available_but_not_activated": "Power available",
109111
"providing_power": "Providing power",
110112
"no_power_available": "No power"
111113
}
Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,56 @@
11
{
22
"batteryChargeLevel": {
33
"status": "OK",
4-
"value": 38,
4+
"value": 90.0,
55
"unit": "percentage",
6-
"updatedAt": "2025-07-02T08:51:23Z"
6+
"updatedAt": "2025-08-07T14:30:32Z"
77
},
88
"electricRange": {
99
"status": "OK",
10-
"value": 90,
10+
"value": 327,
1111
"unit": "km",
12-
"updatedAt": "2025-07-02T08:51:23Z"
12+
"updatedAt": "2025-08-07T14:30:32Z"
1313
},
1414
"chargerConnectionStatus": {
1515
"status": "OK",
16-
"value": "DISCONNECTED",
17-
"updatedAt": "2025-07-02T08:51:23Z"
16+
"value": "CONNECTED",
17+
"updatedAt": "2025-08-07T14:30:32Z"
1818
},
1919
"chargingStatus": {
2020
"status": "OK",
21-
"value": "IDLE",
22-
"updatedAt": "2025-07-02T08:51:23Z"
21+
"value": "DONE",
22+
"updatedAt": "2025-08-07T14:30:32Z"
2323
},
2424
"chargingType": {
2525
"status": "OK",
26-
"value": "NONE",
27-
"updatedAt": "2025-07-02T08:51:23Z"
26+
"value": "AC",
27+
"updatedAt": "2025-08-07T14:30:32Z"
2828
},
2929
"chargerPowerStatus": {
3030
"status": "OK",
31-
"value": "NO_POWER_AVAILABLE",
32-
"updatedAt": "2025-07-02T08:51:23Z"
31+
"value": "FAULT",
32+
"updatedAt": "2025-08-07T14:30:32Z"
3333
},
3434
"estimatedChargingTimeToTargetBatteryChargeLevel": {
3535
"status": "OK",
36-
"value": 0,
36+
"value": 2,
3737
"unit": "minutes",
38-
"updatedAt": "2025-07-02T08:51:23Z"
38+
"updatedAt": "2025-08-07T14:30:32Z"
3939
},
4040
"chargingCurrentLimit": {
41-
"status": "OK",
42-
"value": 32,
43-
"unit": "ampere",
44-
"updatedAt": "2024-03-05T08:38:44Z"
41+
"status": "ERROR",
42+
"code": "NOT_SUPPORTED",
43+
"message": "Resource is not supported for this vehicle"
4544
},
4645
"targetBatteryChargeLevel": {
4746
"status": "OK",
4847
"value": 90,
4948
"unit": "percentage",
50-
"updatedAt": "2024-09-22T09:40:12Z"
49+
"updatedAt": "2025-08-07T14:49:50Z"
5150
},
5251
"chargingPower": {
5352
"status": "ERROR",
54-
"code": "PROPERTY_NOT_FOUND",
55-
"message": "No valid value could be found for the requested property"
53+
"code": "NOT_SUPPORTED",
54+
"message": "Resource is not supported for this vehicle"
5655
}
5756
}

tests/components/volvo/snapshots/test_sensor.ambr

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
'last_changed': <ANY>,
5353
'last_reported': <ANY>,
5454
'last_updated': <ANY>,
55-
'state': '38',
55+
'state': '90.0',
5656
})
5757
# ---
5858
# name: test_sensor[ex30_2024][sensor.volvo_ex30_battery_capacity-entry]
@@ -229,7 +229,7 @@
229229
'last_changed': <ANY>,
230230
'last_reported': <ANY>,
231231
'last_updated': <ANY>,
232-
'state': 'disconnected',
232+
'state': 'connected',
233233
})
234234
# ---
235235
# name: test_sensor[ex30_2024][sensor.volvo_ex30_charging_limit-entry]
@@ -285,7 +285,7 @@
285285
'last_changed': <ANY>,
286286
'last_reported': <ANY>,
287287
'last_updated': <ANY>,
288-
'state': '32',
288+
'state': 'unavailable',
289289
})
290290
# ---
291291
# name: test_sensor[ex30_2024][sensor.volvo_ex30_charging_power-entry]
@@ -351,6 +351,8 @@
351351
'area_id': None,
352352
'capabilities': dict({
353353
'options': list([
354+
'fault',
355+
'power_available_but_not_activated',
354356
'providing_power',
355357
'no_power_available',
356358
]),
@@ -390,6 +392,8 @@
390392
'device_class': 'enum',
391393
'friendly_name': 'Volvo EX30 Charging power status',
392394
'options': list([
395+
'fault',
396+
'power_available_but_not_activated',
393397
'providing_power',
394398
'no_power_available',
395399
]),
@@ -399,7 +403,7 @@
399403
'last_changed': <ANY>,
400404
'last_reported': <ANY>,
401405
'last_updated': <ANY>,
402-
'state': 'no_power_available',
406+
'state': 'fault',
403407
})
404408
# ---
405409
# name: test_sensor[ex30_2024][sensor.volvo_ex30_charging_status-entry]
@@ -465,7 +469,7 @@
465469
'last_changed': <ANY>,
466470
'last_reported': <ANY>,
467471
'last_updated': <ANY>,
468-
'state': 'idle',
472+
'state': 'done',
469473
})
470474
# ---
471475
# name: test_sensor[ex30_2024][sensor.volvo_ex30_charging_type-entry]
@@ -525,7 +529,7 @@
525529
'last_changed': <ANY>,
526530
'last_reported': <ANY>,
527531
'last_updated': <ANY>,
528-
'state': 'none',
532+
'state': 'ac',
529533
})
530534
# ---
531535
# name: test_sensor[ex30_2024][sensor.volvo_ex30_distance_to_empty_battery-entry]
@@ -581,7 +585,7 @@
581585
'last_changed': <ANY>,
582586
'last_reported': <ANY>,
583587
'last_updated': <ANY>,
584-
'state': '90',
588+
'state': '327',
585589
})
586590
# ---
587591
# name: test_sensor[ex30_2024][sensor.volvo_ex30_distance_to_service-entry]
@@ -693,7 +697,7 @@
693697
'last_changed': <ANY>,
694698
'last_reported': <ANY>,
695699
'last_updated': <ANY>,
696-
'state': '0',
700+
'state': '2',
697701
})
698702
# ---
699703
# name: test_sensor[ex30_2024][sensor.volvo_ex30_odometer-entry]
@@ -2276,6 +2280,8 @@
22762280
'area_id': None,
22772281
'capabilities': dict({
22782282
'options': list([
2283+
'fault',
2284+
'power_available_but_not_activated',
22792285
'providing_power',
22802286
'no_power_available',
22812287
]),
@@ -2315,6 +2321,8 @@
23152321
'device_class': 'enum',
23162322
'friendly_name': 'Volvo XC40 Charging power status',
23172323
'options': list([
2324+
'fault',
2325+
'power_available_but_not_activated',
23182326
'providing_power',
23192327
'no_power_available',
23202328
]),

0 commit comments

Comments
 (0)