Skip to content

Commit f2311e0

Browse files
committed
add new tags attribute
1 parent 4a75869 commit f2311e0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

weconnect/elements/vehicle.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from typing import Dict, Set, Any, Type, Optional, cast, TYPE_CHECKING
2+
from typing import Dict, List, Set, Any, Type, Optional, cast, TYPE_CHECKING
33
import os
44
from enum import Enum
55
from datetime import datetime, timedelta
@@ -88,6 +88,7 @@ def __init__(
8888
self.capabilities: AddressableDict[str, GenericCapability] = AddressableDict(localAddress='capabilities', parent=self)
8989
self.domains: AddressableDict[str, AddressableDict[str, GenericStatus]] = AddressableDict(localAddress='domains', parent=self)
9090
self.images: AddressableAttribute[Dict[str, str]] = AddressableAttribute(localAddress='images', parent=self, value=None, valueType=dict)
91+
self.tags: AddressableAttribute[List[str]] = AddressableAttribute(localAddress='tags', parent=self, value=None, valueType=list)
9192
self.coUsers: AddressableList[Vehicle.User] = AddressableList(localAddress='coUsers', parent=self)
9293
self.controls: Controls = Controls(localAddress='controls', vehicle=self, parent=self)
9394
self.fixAPI: bool = fixAPI
@@ -203,6 +204,11 @@ def update( # noqa: C901 # pylint: disable=too-many-branches
203204
else:
204205
self.images.enabled = False
205206

207+
if 'tags' in fromDict:
208+
self.tags.setValueWithCarTime(fromDict['tags'], lastUpdateFromCar=None, fromServer=True)
209+
else:
210+
self.tags.enabled = False
211+
206212
if 'coUsers' in fromDict and fromDict['coUsers'] is not None:
207213
for user in fromDict['coUsers']:
208214
if 'id' in user:
@@ -230,6 +236,7 @@ def update( # noqa: C901 # pylint: disable=too-many-branches
230236
'nickname',
231237
'capabilities',
232238
'images',
239+
'tags',
233240
'coUsers']}.items():
234241
LOG.warning('%s: Unknown attribute %s with value %s', self.getGlobalAddress(), key, value)
235242

@@ -626,6 +633,8 @@ def __str__(self) -> str: # noqa: C901
626633
for coUser in self.coUsers:
627634
if coUser.enabled:
628635
returnString += ''.join(['\t' + line for line in str(coUser).splitlines(True)]) + '\n'
636+
if self.tags.enabled and self.tags.value:
637+
returnString += 'Tags: ' + ', '.join(self.tags.value) + '\n'
629638
if self.capabilities.enabled:
630639
returnString += f'Capabilities: {len(self.capabilities)} items\n'
631640
for capability in self.capabilities.values():

0 commit comments

Comments
 (0)