Skip to content

Commit

Permalink
Add missing enum fields and position errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dvx76 committed Sep 13, 2024
1 parent 85c5d49 commit 7a4a9d9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
10 changes: 10 additions & 0 deletions myskoda/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ async def positions(vin):
print(f" {position.address.zip_code} {position.address.city}")
print(f" {position.address.country} ({position.address.country_code})")

if positions.errors:
print(f"{colored("Error:", "red")}")
for error in positions.errors:
print(f"- {colored("type:", "blue")} {error.type}")
print(f" {colored("description:", "blue")} {error.description}")


@cli.command()
@click.argument("vin")
Expand Down Expand Up @@ -326,3 +332,7 @@ def charger_locked(cond: ChargerLockedState) -> str:
if cond == ChargerLockedState.LOCKED
else colored("unlocked", "red")
)


if __name__ == '__main__':
cli()
1 change: 1 addition & 0 deletions myskoda/models/air_conditioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class TemperatureUnit(StrEnum):

class TimerMode(StrEnum):
ONE_OFF = "ONE_OFF"
RECURRING = "RECURRING"


class Timer(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions myskoda/models/driving_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class EngineType(StrEnum):
DIESEL = "diesel"
ELECTRIC = "electric"


class EngineRange(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions myskoda/models/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class CapabilityId(StrEnum):
VEHICLE_WAKE_UP = "VEHICLE_WAKE_UP"
VEHICLE_WAKE_UP_TRIGGER = "VEHICLE_WAKE_UP_TRIGGER"
WARNING_LIGHTS = "WARNING_LIGHTS"
WEB_RADIO = "WEB_RADIO"
WINDOW_HEATING = "WINDOW_HEATING"


Expand Down
15 changes: 12 additions & 3 deletions myskoda/models/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@
from .common import Address, Coordinates


class Type(StrEnum):
class PositionType(StrEnum):
VEHICLE = "VEHICLE"


class Position(BaseModel):
address: Address
gps_coordinates: Coordinates = Field(None, alias="gpsCoordinates")
type: Type
type: PositionType


class ErrorType(StrEnum):
VEHICLE_IN_MOTION = "VEHICLE_IN_MOTION"


class Error(BaseModel):
type: ErrorType
description: str


class Positions(BaseModel):
"""Positional information (GPS) for the vehicle and other things."""

errors: list[Any]
errors: list[Error]
positions: list[Position]
6 changes: 4 additions & 2 deletions myskoda/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .models.health import Health
from .models.info import Info
from .models.maintenance import Maintenance
from .models.position import Positions, Type
from .models.position import Positions, PositionType
from .models.status import Status
from .models.trip_statistics import TripStatistics

Expand Down Expand Up @@ -298,7 +298,9 @@ async def wakeup(self, vin):
async def honk_flash(self, vin, honk=False):
"""Honk and/or flash."""
positions = await self.get_positions(vin)
position = next(pos for pos in positions.positions if pos.type == Type.VEHICLE)
position = next(
pos for pos in positions.positions if pos.type == PositionType.VEHICLE
)
json_data = {
"mode": "HONK_AND_FLASH" if honk else "FLASH",
"vehiclePosition": {
Expand Down

0 comments on commit 7a4a9d9

Please sign in to comment.