Skip to content

Commit 3132ffd

Browse files
authored
Add attributes reported from ID.7
1 parent 13879cf commit 3132ffd

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

weconnect/elements/battery_status.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def __init__(
1717
):
1818
self.currentSOC_pct = AddressableAttribute(
1919
localAddress='currentSOC_pct', parent=self, value=None, valueType=int)
20+
self.navigationTargetSOC_pct = AddressableAttribute(
21+
localAddress='navigationTargetSOC_pct', parent=self, value=None, valueType=int)
2022
self.cruisingRangeElectric_km = AddressableAttribute(
2123
localAddress='cruisingRangeElectric_km', value=None, parent=self, valueType=int)
2224
super().__init__(vehicle=vehicle, parent=parent, statusId=statusId, fromDict=fromDict, fixAPI=fixAPI)
@@ -45,17 +47,21 @@ def update(self, fromDict, ignoreAttributes=None):
4547
self.cruisingRangeElectric_km.enabled = False
4648

4749
self.currentSOC_pct.fromDict(fromDict['value'], 'currentSOC_pct')
50+
self.navigationTargetSOC_pct.fromDict(fromDict['value'], 'navigationTargetSOC_pct')
4851
else:
4952
self.currentSOC_pct.enabled = False
5053
self.cruisingRangeElectric_km.enabled = False
54+
self.navigationTargetSOC_pct.enabled = False
5155

5256
super().update(fromDict=fromDict, ignoreAttributes=(
53-
ignoreAttributes + ['currentSOC_pct', 'cruisingRangeElectric_km']))
57+
ignoreAttributes + ['currentSOC_pct', 'navigationTargetSOC_pct', 'cruisingRangeElectric_km']))
5458

5559
def __str__(self):
5660
string = super().__str__()
5761
if self.currentSOC_pct.enabled:
5862
string += f'\n\tCurrent SoC: {self.currentSOC_pct.value}%'
63+
if self.navigationTargetSOC_pct.enabled:
64+
string += f'\n\tNavigation Target SoC: {self.navigationTargetSOC_pct.value}%'
5965
if self.cruisingRangeElectric_km.enabled:
6066
if self.cruisingRangeElectric_km.value is not None:
6167
string += f'\n\tRange: {self.cruisingRangeElectric_km.value}km'

weconnect/elements/temperature_battery_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(
2222

2323
def update(self, fromDict, ignoreAttributes=None):
2424
ignoreAttributes = ignoreAttributes or []
25-
LOG.debug('Update range status from dict')
25+
LOG.debug('Update battery temperature status from dict')
2626

2727
if 'value' in fromDict:
2828
self.temperatureHvBatteryMin_K.fromDict(fromDict['value'], 'temperatureHvBatteryMin_K')
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import logging
2+
3+
from weconnect.addressable import AddressableAttribute
4+
from weconnect.elements.generic_status import GenericStatus
5+
from weconnect.util import kelvinToCelsius
6+
7+
LOG = logging.getLogger("weconnect")
8+
9+
10+
class TemperatureOutsideStatus(GenericStatus):
11+
def __init__(
12+
self,
13+
vehicle,
14+
parent,
15+
statusId,
16+
fromDict=None,
17+
fixAPI=True,
18+
):
19+
self.temperatureOutside_K = AddressableAttribute(localAddress='temperatureOutside_K', parent=self, value=None, valueType=float)
20+
super().__init__(vehicle=vehicle, parent=parent, statusId=statusId, fromDict=fromDict, fixAPI=fixAPI)
21+
22+
def update(self, fromDict, ignoreAttributes=None):
23+
ignoreAttributes = ignoreAttributes or []
24+
LOG.debug('Update outside temperature status from dict')
25+
26+
if 'value' in fromDict:
27+
self.temperatureOutside_K.fromDict(fromDict['value'], 'temperatureOutside_K')
28+
29+
else:
30+
self.temperatureOutside_K.enabled = False
31+
32+
super().update(fromDict=fromDict, ignoreAttributes=(ignoreAttributes
33+
+ ['temperatureOutside_K']))
34+
35+
def __str__(self):
36+
string = super().__str__()
37+
if self.temperatureOutside_K.enabled:
38+
string += f'\n\tOutside temperature {kelvinToCelsius(self.temperatureOutside_K.value)}°C'
39+
return string

weconnect/elements/vehicle.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from weconnect.elements.range_measurements import RangeMeasurements
4747
from weconnect.elements.readiness_status import ReadinessStatus
4848
from weconnect.elements.temperature_battery_status import TemperatureBatteryStatus
49+
from weconnect.elements.temperature_outside_status import TemperatureOutsideStatus
4950
from weconnect.elements.charging_profiles import ChargingProfiles
5051
from weconnect.elements.trip import Trip
5152
from weconnect.errors import APICompatibilityError, RetrievalError, APIError, TooManyRequestsError
@@ -309,6 +310,7 @@ def updateStatus(self, updateCapabilities: bool = True, force: bool = False, #
309310
'oilLevelStatus': GenericStatus,
310311
'measurements': GenericStatus,
311312
'temperatureBatteryStatus': TemperatureBatteryStatus,
313+
'temperatureOutsideStatus': TemperatureOutsideStatus,
312314
'fuelLevelStatus': FuelLevelStatus,
313315
},
314316
Domain.BATTERY_SUPPORT: {

0 commit comments

Comments
 (0)