simple-ocpp-cs/app/schemas/meter_value.py

58 lines
1.9 KiB
Python

from datetime import datetime
from decimal import Decimal
import enum
from typing import Optional
from uuid import UUID
from pydantic import BaseModel
class PhaseType(enum.Enum):
L1 = "L1"
L2 = "L2"
L3 = "L3"
N = "N"
L1_N = "L1-N"
L2_N = "L2-N"
L3_N = "L3-N"
L1_L2 = "L1-L2"
L2_L3 = "L2-L3"
L3_L1 = "L3-L1"
class Measurand(enum.Enum):
CURRENT_EXPORT = "Current.Export"
CURRENT_IMPORT = "Current.Import"
CURRENT_OFFERED = "Current.Offered"
ENERGY_ACTIVE_NET = "Energy.Active.Net"
ENERGY_ACTIVE_EXPORT_REGISTER = "Energy.Active.Export.Register"
ENERGY_ACTIVE_IMPORT_REGISTER = "Energy.Active.Import.Register"
ENERGY_ACTIVE_EXPORT_INTERVAL = "Energy.Active.Export.Interval"
ENERGY_ACTIVE_IMPORT_INTERVAL = "Energy.Active.Import.Interval"
ENERGY_REACTIVE_NET = "Energy.Reactive.Net"
ENERGY_REACTIVE_EXPORT_REGISTER = "Energy.Reactive.Export.Register"
ENERGY_REACTIVE_IMPORT_REGISTER = "Energy.Reactive.Import.Register"
ENERGY_REACTIVE_EXPORT_INTERVAL = "Energy.Reactive.Export.Interval"
ENERGY_REACTIVE_IMPORT_INTERVAL = "Energy.Reactive.Import.Interval"
ENERGY_APPARENT_NET = "Energy.Apparent.Net"
ENERGY_APPARENT_IMPORT = "Energy.Apparent.Import"
ENERGY_APPARENT_EXPORT = "Energy.Apparent.Export"
FREQUENCY = "Frequency"
POWER_ACTIVE_EXPORT = "Power.Active.Export"
POWER_ACTIVE_IMPORT = "Power.Active.Import"
POWER_FACTOR = "Power.Factor"
POWER_OFFERED = "Power.Offered"
POWER_REACTIVE_EXPORT = "Power.Reactive.Export"
POWER_REACTIVE_IMPORT = "Power.Reactive.Import"
SOC = "SoC"
VOLTAGE = "Voltage"
class MeterValue(BaseModel):
id: UUID
timestamp: datetime
measurand: Measurand
phase_type: Optional[PhaseType] = None
unit: Optional[str] = None
value: Decimal
transaction_id: str
class Config:
from_attributes = True