|
1 | 1 | 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 |
3 | 3 | import os |
4 | 4 | from enum import Enum |
5 | 5 | from datetime import datetime, timedelta |
@@ -88,6 +88,7 @@ def __init__( |
88 | 88 | self.capabilities: AddressableDict[str, GenericCapability] = AddressableDict(localAddress='capabilities', parent=self) |
89 | 89 | self.domains: AddressableDict[str, AddressableDict[str, GenericStatus]] = AddressableDict(localAddress='domains', parent=self) |
90 | 90 | 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) |
91 | 92 | self.coUsers: AddressableList[Vehicle.User] = AddressableList(localAddress='coUsers', parent=self) |
92 | 93 | self.controls: Controls = Controls(localAddress='controls', vehicle=self, parent=self) |
93 | 94 | self.fixAPI: bool = fixAPI |
@@ -203,6 +204,11 @@ def update( # noqa: C901 # pylint: disable=too-many-branches |
203 | 204 | else: |
204 | 205 | self.images.enabled = False |
205 | 206 |
|
| 207 | + if 'tags' in fromDict: |
| 208 | + self.tags.setValueWithCarTime(fromDict['tags'], lastUpdateFromCar=None, fromServer=True) |
| 209 | + else: |
| 210 | + self.tags.enabled = False |
| 211 | + |
206 | 212 | if 'coUsers' in fromDict and fromDict['coUsers'] is not None: |
207 | 213 | for user in fromDict['coUsers']: |
208 | 214 | if 'id' in user: |
@@ -230,6 +236,7 @@ def update( # noqa: C901 # pylint: disable=too-many-branches |
230 | 236 | 'nickname', |
231 | 237 | 'capabilities', |
232 | 238 | 'images', |
| 239 | + 'tags', |
233 | 240 | 'coUsers']}.items(): |
234 | 241 | LOG.warning('%s: Unknown attribute %s with value %s', self.getGlobalAddress(), key, value) |
235 | 242 |
|
@@ -626,6 +633,8 @@ def __str__(self) -> str: # noqa: C901 |
626 | 633 | for coUser in self.coUsers: |
627 | 634 | if coUser.enabled: |
628 | 635 | 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' |
629 | 638 | if self.capabilities.enabled: |
630 | 639 | returnString += f'Capabilities: {len(self.capabilities)} items\n' |
631 | 640 | for capability in self.capabilities.values(): |
|
0 commit comments