name: EV charger
products:
  - id: jui3mys5c9rfdju2
    manufacturer: Ecopoint
    model: 32A
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: 21
        type: string
        optional: true
        name: card_binding
      - id: 22  # meter_id
        type: string
        name: meter_id
      - id: 23  # system_version
        type: string
        name: system_version
  - entity: sensor
    class: energy
    dps:
      - id: 1  # forward_energy_total
        type: integer
        name: sensor
        class: total_increasing
        unit: kWh
        mapping:
          - scale: 100
  - entity: sensor
    class: battery
    dps:
      - id: 2
        type: integer
        optional: true
        name: sensor
        unit: "%"
  - entity: number
    name: Charging current
    category: config
    class: current
    icon: "mdi:ev-plug-type2"
    dps:
      - id: 4  # charge_cur_set
        type: integer
        name: value
        unit: A
        optional: true
        range:
          min: 6
          max: 80
        mapping:
          - scale: 10
  - entity: sensor
    class: power
    category: diagnostic
    dps:
      - id: 9
        type: integer
        optional: true
        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
        type: bitfield
        name: fault_code
  - entity: sensor
    name: Connection
    icon: "mdi:ev-plug-type2"
    class: enum
    category: diagnostic
    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: Charging mode
    icon: "mdi:ev-station"
    category: config
    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
  - entity: sensor
    translation_key: voltage_x
    translation_placeholders:
      x: A
    class: voltage
    dps:
      - id: 6  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: V
        mask: "FFFF000000000000"
        mapping:
          - scale: 10
  - entity: sensor
    translation_key: current_x
    translation_placeholders:
      x: A
    class: current
    dps:
      - id: 6  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: A
        mask: "0000FFFFFF000000"
        mapping:
          - scale: 1000
  - entity: sensor
    translation_key: power_x
    translation_placeholders:
      x: A
    class: power
    dps:
      - id: 6  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: kW
        mask: "0000000000FFFFFF"
        mapping:
          - scale: 1000
  - entity: sensor
    translation_key: voltage_x
    translation_placeholders:
      x: B
    class: voltage
    dps:
      - id: 7  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: V
        mask: "FFFF000000000000"
        mapping:
          - scale: 10
  - entity: sensor
    translation_key: current_x
    translation_placeholders:
      x: B
    class: current
    dps:
      - id: 7  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: A
        mask: "0000FFFFFF000000"
        mapping:
          - scale: 1000
  - entity: sensor
    translation_key: power_x
    translation_placeholders:
      x: B
    class: power
    dps:
      - id: 7  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: kW
        mask: "0000000000FFFFFF"
        mapping:
          - scale: 1000
  - entity: sensor
    translation_key: voltage_x
    translation_placeholders:
      x: C
    class: voltage
    dps:
      - id: 8  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: V
        mask: "FFFF000000000000"
        mapping:
          - scale: 10
  - entity: sensor
    translation_key: current_x
    translation_placeholders:
      x: C
    class: current
    dps:
      - id: 8  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: A
        mask: "0000FFFFFF000000"
        mapping:
          - scale: 1000
  - entity: sensor
    translation_key: power_x
    translation_placeholders:
      x: C
    class: power
    dps:
      - id: 8  # phase_1
        type: base64
        name: sensor
        optional: true
        unit: kW
        mask: "0000000000FFFFFF"
        mapping:
          - scale: 1000
  - entity: sensor
    class: temperature
    category: diagnostic
    dps:
      - id: 24
        type: integer
        name: sensor
        unit: C
        class: measurement
  - entity: number
    name: Charge energy
    category: config
    class: energy_storage
    dps:
      - id: 17
        type: integer
        optional: true
        name: value
        unit: kWh
        range:
          min: 1
          max: 20000000
        mapping:
          - scale: 1000
  - entity: number
    name: Charge time
    category: config
    class: duration
    icon: "mdi:timer"
    dps:
      - id: 19
        type: integer
        optional: true
        name: value
        unit: min
        range:
          min: 1
          max: 1440
  - entity: sensor
    name: Charge energy
    class: energy_storage
    dps:
      - id: 25  # charge_energy_once
        type: integer
        name: sensor
        optional: true
        class: measurement
  - entity: switch
    icon: "mdi:ev-station"
    dps:
      - id: 18  # switch
        type: boolean
        name: switch
  - entity: sensor
    name: Charging time
    class: duration
    dps:
      - id: 101
        type: base64
        name: sensor
        optional: true
        unit: s
        mask: "0000FFFF"
  - entity: select
    name: Mode
    icon: "mdi:cogs"
    category: config
    dps:
      - id: 102
        type: string
        optional: true
        name: option
        mapping:
          - dps_val: home
            value: Home
          - dps_val: mode
            value: Mode
          - dps_val: recode
            value: recode
          - dps_val: setting
            value: setting
  - entity: sensor
    name: Minimum current
    class: current
    category: diagnostic
    dps:
      - id: 103
        type: base64
        optional: true
        name: sensor
        unit: A
        mask: "FFFF0000"
        mapping:
          - scale: 10
  - entity: sensor
    name: Maximum current
    class: current
    category: diagnostic
    dps:
      - id: 103
        type: base64
        optional: true
        name: sensor
        unit: A
        mask: "0000FFFF"
        mapping:
          - scale: 10
