Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite to use models instead #126

Merged
merged 8 commits into from
Jan 30, 2022
Prev Previous commit
Next Next commit
Minor code improvements
DurgNomis-drol committed Jan 30, 2022
commit 6764415aca6ec094b297b62f226f140b544683a9
14 changes: 6 additions & 8 deletions mytoyota/models/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
"""Models for vehicle sensors."""
from __future__ import annotations

from typing import Any
from typing import TYPE_CHECKING, Any

from mytoyota.utils.conversions import convert_to_miles

if TYPE_CHECKING:
from mytoyota.models.vehicle import Vehicle


class Dashboard:
"""Instrumentation data model."""

_chargeinfo: dict[str, Any]
_energy: dict[str, Any]

def __init__(
self,
vehicle,
vehicle: Vehicle,
) -> None:
"""Dashboard."""
self._vehicle = vehicle

vehicle_info = vehicle._status_legacy.get("VehicleInfo", {})
self._chargeinfo = vehicle_info.get("ChargeInfo", {})
self._energy = (
vehicle._status.get("energy", [])[0]
if vehicle._status.get("energy")
else {}
vehicle._status.get("energy", [])[0] if "energy" in vehicle._status else {}
)

@property