# coding: utf-8

"""
    Peblar local REST API

    # General This document contains the specification of the WLAC local REST API. This API for local networks is supported by Peblar products from firmware versions 1.6 and onwards. Before the API can be accessed, it is required to be enabled in the advanced settings page of the chargers web interface. The endpoints described below can be reached via http://\\<local_ip\\>/api/wlac/v1/\\<endpoint_name\\> for example http://10.11.12.13/api/wlac/v1/evinterface. <br><br> <img src=\"./images/api_enable.png\"/> <br> 

    The version of the OpenAPI document: 1.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr

class EVInterfaceResponse(BaseModel):
    """
    EVInterfaceResponse
    """
    cp_state: Optional[StrictStr] = Field(default=None, alias="CpState", description="The current state of the Control Pilot which can be:   - State A: No EV connected   - State B: EV connected but suspended by either EV or charger   - State C: EV connected and charging   - State D: Same as C but ventilation requested (not supported)   - State E: Error, short to PE or powered off   - State F: Fault detected by charger   - Invalid: Invalid CP level measured   - Unknown: CP signal cannot be measured.  See [Electric vehicle conductive charging systems - part 1: general requirements, IEC 61851-1, Edition 3.0, 2017-2] for more details on these states. ")
    lock_state: Optional[StrictBool] = Field(default=None, alias="LockState", description="The current state of the socket lock (false = unlocked, true = locked). This value is not present on fixed cable systems.")
    charge_current_limit: Optional[StrictInt] = Field(default=None, alias="ChargeCurrentLimit", description="The maximum current indicated towards the EV in milliAmpere by this API. Note that other factors can cause an even lower limit (e.g. thermal); These are communicated via the fields ChargeCurrentLimitSource and ChargeCurrentLimitActual. ")
    charge_current_limit_source: Optional[StrictStr] = Field(default=None, alias="ChargeCurrentLimitSource", description="One of the following sources will be actively limiting the charging current:    - Charging cable: The maximum rated current of the attached cable.   - High temperature: Charger internal temperature.   - Installation limit: The maximum installation current configured during commissioning.   - Dynamic load balancing: Household installation phase current reached maximum.   - Group load balancing: A maximum communicated by the leader of the group.   - Overcurrent protection: EV exceeded communicated maximum current.   - Hardware limitation: Physical limits of the charger.   - Power factor: EV charged with too low power factor.   - OCPP smart charging: Smart charging profile installed by CPO.   - Phase imbalance: Too much imbalance between phases.   - Local scheduled charging: Locally configured scheduled charging.   - Solar charging: Amount of exported energy.   - Current limiter: User selected limit via web web-interface.   - Local REST API: Limit set by this API.   - Local Modbus API: Limit set by the Modbus API.   - External power limit: External IO defined limit.   - Household power limit: Total household power capacity limit. ")
    charge_current_limit_actual: Optional[StrictInt] = Field(default=None, alias="ChargeCurrentLimitActual", description="The actual current which is communicated to the vehicle per phase. This is the lowest current of all limiting sources.")
    force1_phase: Optional[StrictBool] = Field(default=None, alias="Force1Phase", description="Use only 1 phase for charging (if supported by the charger, see \"Force1PhaseAllowed\"). If a charging session is already ongoing, a switch-over from 3 to 1 phase is done automatically by the charger.")
    __properties = ["CpState", "LockState", "ChargeCurrentLimit", "ChargeCurrentLimitSource", "ChargeCurrentLimitActual", "Force1Phase"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> EVInterfaceResponse:
        """Create an instance of EVInterfaceResponse from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> EVInterfaceResponse:
        """Create an instance of EVInterfaceResponse from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return EVInterfaceResponse.parse_obj(obj)

        _obj = EVInterfaceResponse.parse_obj({
            "cp_state": obj.get("CpState"),
            "lock_state": obj.get("LockState"),
            "charge_current_limit": obj.get("ChargeCurrentLimit"),
            "charge_current_limit_source": obj.get("ChargeCurrentLimitSource"),
            "charge_current_limit_actual": obj.get("ChargeCurrentLimitActual"),
            "force1_phase": obj.get("Force1Phase")
        })
        return _obj


