"""Data models for Victron device readings."""

from __future__ import annotations

from dataclasses import dataclass


@dataclass(frozen=True)
class DeviceIdentity:
    """Identity of a discovered Victron device."""

    unit_id: int
    device_type: str
    product_name: str


@dataclass(frozen=True)
class SystemData:
    """System-level readings from unit 100."""

    battery_voltage: float
    battery_current: float
    battery_power: float
    battery_soc: float
    battery_state: int
    pv_power: float
    grid_power_l1: float
    ac_consumption_l1: float


@dataclass(frozen=True)
class SolarChargerData:
    """MPPT solar charger readings from unit 223."""

    charger_state: int
    pv_voltage: float
    pv_current: float
    pv_power: float
    yield_today: float
    max_charge_power_today: float
    battery_voltage: float
    battery_current: float


@dataclass(frozen=True)
class VEBusData:
    """VE.Bus inverter/charger readings from unit 227."""

    ac_input_voltage: float
    ac_input_current: float
    ac_input_frequency: float
    ac_input_power: float
    ac_output_voltage: float
    ac_output_current: float
    ac_output_frequency: float
    ac_output_power: float
    vebus_state: int
    battery_voltage: float
    battery_current: float
    battery_soc: float


@dataclass(frozen=True)
class VictronData:
    """Combined data from all discovered Victron devices."""

    system: SystemData | None = None
    solar_charger: SolarChargerData | None = None
    vebus: VEBusData | None = None
    discovered_devices: tuple[DeviceIdentity, ...] = ()
