name: EV charger
products:
  - id: o4zjlnwqwe0dzitl
    manufacturer: Tera
    model: 22kW 32A 3 phase
entities:
  - entity: sensor
    translation_key: status
    icon: "mdi:ev-station"
    class: enum
    dps:
      - id: 3  # work_state
        type: string
        name: sensor
        mapping:
          - dps_val: charger_charging
            value: charging
          - dps_val: charger_free
            value: available
          - dps_val: charger_insert
            value: plugged_in
          - dps_val: charger_free_fault
            value: fault_unplugged
          - dps_val: charger_wait
            value: waiting
          - dps_val: charger_pause
            value: paused
          - dps_val: charger_end
            value: charged
          - dps_val: charger_fault
            value: fault
      - id: 23  # system_version
        type: string
        name: system_version
  - entity: sensor
    class: energy
    dps:
      - id: 1  # forward_energy_total
        type: integer
        optional: true
        name: sensor
        class: total_increasing
        unit: kWh
        mapping:
          - scale: 100
  - entity: number
    name: Max current
    category: config
    class: current
    icon: "mdi:ev-plug-type2"
    dps:
      - id: 4  # charge_cur_set
        type: integer
        name: value
        unit: A
        range:
          min: 8
          max: 32
  - entity: sensor
    name: L1 voltage
    class: voltage
    category: diagnostic
    dps:
      - id: 6  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: V
        mask: "FFFF000000000000"
        mapping:
          - scale: 10
  - entity: sensor
    name: L1 current
    class: current
    category: diagnostic
    dps:
      - id: 6  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: A
        mask: "0000FFFFFF000000"
        mapping:
          - scale: 1000
  - entity: sensor
    name: L1 power
    class: power
    category: diagnostic
    dps:
      - id: 6  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: kW
        mask: "0000000000FFFFFF"
        mapping:
          - scale: 1000
  - entity: sensor
    name: L2 voltage
    class: voltage
    category: diagnostic
    dps:
      - id: 7  # phase_2
        type: base64
        name: sensor
        optional: true
        unit: V
        mask: "FFFF000000000000"
        mapping:
          - scale: 10
  - entity: sensor
    name: L2 current
    class: current
    category: diagnostic
    dps:
      - id: 7  # phase_2
        type: base64
        name: sensor
        optional: true
        unit: A
        mask: "0000FFFFFF000000"
        mapping:
          - scale: 1000
  - entity: sensor
    name: L2 power
    class: power
    category: diagnostic
    dps:
      - id: 7  # phase_2
        type: base64
        name: sensor
        optional: true
        unit: kW
        mask: "0000000000FFFFFF"
        mapping:
          - scale: 1000
  - entity: sensor
    name: L3 voltage
    class: voltage
    category: diagnostic
    dps:
      - id: 8  # phase_3
        type: base64
        name: sensor
        optional: true
        unit: V
        mask: "FFFF000000000000"
        mapping:
          - scale: 10
  - entity: sensor
    name: L3 current
    class: current
    category: diagnostic
    dps:
      - id: 8  # phase_3
        type: base64
        name: sensor
        optional: true
        unit: A
        mask: "0000FFFFFF000000"
        mapping:
          - scale: 1000
  - entity: sensor
    name: L3 power
    class: power
    category: diagnostic
    dps:
      - id: 8  # phase_3
        type: base64
        name: sensor
        optional: true
        unit: kW
        mask: "0000000000FFFFFF"
        mapping:
          - scale: 1000
  - entity: sensor
    class: power
    dps:
      - id: 9  # power_total
        type: integer
        name: sensor
        unit: kW
        class: measurement
        mapping:
          - scale: 1000
  - entity: binary_sensor
    class: problem
    category: diagnostic
    dps:
      - id: 10  # fault
        type: bitfield
        name: sensor
        mapping:
          - dps_val: 0
            value: false
          - value: true
      - id: 10  # fault
        type: bitfield
        name: fault_code
  - entity: sensor
    name: Connection
    icon: "mdi:ev-plug-type2"
    class: enum
    dps:
      - id: 13  # connection_state
        type: string
        name: sensor
        mapping:
          - dps_val: controlpi_12v
            value: Standby
          - dps_val: controlpi_12v_pwm
            value: Communication initialising
          - dps_val: controlpi_9v
            value: Vehicle detected
          - dps_val: controlpi_9v_pwm
            value: Vehicle connected
          - dps_val: controlpi_6v
            value: Ready to charge
          - dps_val: controlpi_6v_pwm
            value: Charging
          - dps_val: controlpi_error
            value: Error
  - entity: select
    name: Mode
    category: config
    icon: "mdi:ev-station"
    dps:
      - id: 14  # work_mode
        type: string
        optional: true
        name: option
        mapping:
          - dps_val: charge_now
            value: Immediate
          - dps_val: charge_energy
            value: Fixed charge
          - dps_val: charge_schedule
            value: Scheduled charge
          - dps_val: charge_delay
            value: Delayed charge
          - dps_val: charge_pct
            value: Percentage charge
  - entity: switch
    icon: "mdi:ev-station"
    dps:
      - id: 18  # switch
        type: boolean
        name: switch
  - entity: sensor
    class: temperature
    dps:
      - id: 24  # temp_current
        type: integer
        name: sensor
        unit: C
        class: measurement
  - entity: number
    name: Delay charge
    class: duration
    category: config
    icon: "mdi:car-clock"
    dps:
      - id: 28  # timer_on
        type: integer
        name: value
        optional: true
        unit: h
        range:
          min: 0
          max: 12
