hass-core/homeassistant/components/teslemetry/models.py
Brett Adams 5186605cec
Add energy history coordinator and sensors to Teslemetry (#126166)
* start

* More

* fix init

* Update requirements_all.txt

* Update requirements_test_all.txt

* Add Tests

* Add missing fixture

* first refresh history

* Fix mock_energy_history

* Remove failures prop

* Update test_init.py

* Actually add the sensors

* Add more icons

* suggested_display_precision

* Fix updated_once

* Fix fixture

* Review changes

* Apply suggestions from code review

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Remove init data

* Update homeassistant/components/teslemetry/coordinator.py

* ruff

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-09-24 10:32:38 +02:00

50 lines
1.2 KiB
Python

"""The Teslemetry integration models."""
from __future__ import annotations
import asyncio
from dataclasses import dataclass
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import Scope
from homeassistant.helpers.device_registry import DeviceInfo
from .coordinator import (
TeslemetryEnergyHistoryCoordinator,
TeslemetryEnergySiteInfoCoordinator,
TeslemetryEnergySiteLiveCoordinator,
TeslemetryVehicleDataCoordinator,
)
@dataclass
class TeslemetryData:
"""Data for the Teslemetry integration."""
vehicles: list[TeslemetryVehicleData]
energysites: list[TeslemetryEnergyData]
scopes: list[Scope]
@dataclass
class TeslemetryVehicleData:
"""Data for a vehicle in the Teslemetry integration."""
api: VehicleSpecific
coordinator: TeslemetryVehicleDataCoordinator
vin: str
wakelock = asyncio.Lock()
device: DeviceInfo
@dataclass
class TeslemetryEnergyData:
"""Data for a vehicle in the Teslemetry integration."""
api: EnergySpecific
live_coordinator: TeslemetryEnergySiteLiveCoordinator
info_coordinator: TeslemetryEnergySiteInfoCoordinator
history_coordinator: TeslemetryEnergyHistoryCoordinator
id: int
device: DeviceInfo