Home Assistant Unofficial Reference 2024.12.1
models.py
Go to the documentation of this file.
1 """The powerwall integration models."""
2 
3 from __future__ import annotations
4 
5 from dataclasses import dataclass
6 from typing import TypedDict
7 
8 from tesla_powerwall import (
9  BatteryResponse,
10  DeviceType,
11  GridStatus,
12  MetersAggregatesResponse,
13  Powerwall,
14  PowerwallStatusResponse,
15  SiteInfoResponse,
16  SiteMasterResponse,
17 )
18 
19 from homeassistant.config_entries import ConfigEntry
20 from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
21 
22 type PowerwallConfigEntry = ConfigEntry[PowerwallRuntimeData]
23 
24 
25 @dataclass
27  """Base information for the powerwall integration."""
28 
29  gateway_din: str
30  site_info: SiteInfoResponse
31  status: PowerwallStatusResponse
32  device_type: DeviceType
33  serial_numbers: list[str]
34  url: str
35  batteries: dict[str, BatteryResponse]
36 
37 
38 @dataclass
40  """Point in time data for the powerwall integration."""
41 
42  charge: float
43  site_master: SiteMasterResponse
44  meters: MetersAggregatesResponse
45  grid_services_active: bool
46  grid_status: GridStatus
47  backup_reserve: float | None
48  batteries: dict[str, BatteryResponse]
49 
50 
51 class PowerwallRuntimeData(TypedDict):
52  """Run time data for the powerwall."""
53 
54  coordinator: DataUpdateCoordinator[PowerwallData] | None
55  api_instance: Powerwall
56  base_info: PowerwallBaseInfo
57  api_changed: bool