name: Energy monitoring smartplug
products:
  - id: jdj6ccklup7btq3a
    name: Tongou TO-Q-SY1-JWT
  - id: w906qkrrhd3otiwd
    name: Moes ME322
primary_entity:
  entity: switch
  class: outlet
  dps:
    - id: 1
      type: boolean
      name: switch
    - id: 21
      type: integer
      name: test_bit
      optional: true
    - id: 26
      type: bitfield
      name: fault_code
    - id: 42
      type: string
      name: cycle_timer
      optional: true
    - id: 43
      type: string
      name: random_timer
      optional: true
    - id: 44
      type: string
      name: inching
      optional: true
secondary_entities:
  - entity: number
    category: config
    translation_key: timer
    dps:
      - id: 9
        type: integer
        name: value
        unit: min
        range:
          min: 0
          max: 86400
        mapping:
          - scale: 60
            step: 60
  - entity: sensor
    category: diagnostic
    name: Energy
    dps:
      - id: 17
        name: sensor
        type: integer
        optional: true
        unit: Wh
      - id: 25
        type: integer
        name: calibration
        optional: true
  - entity: sensor
    category: diagnostic
    class: current
    dps:
      - id: 18
        name: sensor
        type: integer
        class: measurement
        force: true
        unit: mA
      - id: 23
        type: integer
        name: calibration
        optional: true
  - entity: sensor
    category: diagnostic
    class: power
    dps:
      - id: 19
        name: sensor
        type: integer
        class: measurement
        force: true
        unit: W
        mapping:
          - scale: 10
      - id: 24
        type: integer
        name: calibration
        optional: true
  - entity: sensor
    category: diagnostic
    class: voltage
    dps:
      - id: 20
        name: sensor
        type: integer
        class: measurement
        force: true
        unit: V
        mapping:
          - scale: 10
      - id: 22
        type: integer
        name: calibration
        optional: true
  - entity: binary_sensor
    class: problem
    category: diagnostic
    dps:
      - id: 26
        type: bitfield
        name: sensor
        mapping:
          - dps_val: 0
            value: false
          - value: true
  - entity: select
    category: config
    translation_key: initial_state
    dps:
      - id: 38
        type: string
        name: option
        mapping:
          - dps_val: "on"
            value: "on"
          - dps_val: "off"
            value: "off"
          - dps_val: memory
            value: memory
  - entity: switch
    name: Overcharge protection
    category: config
    dps:
      - id: 39
        type: boolean
        name: switch
        optional: true
  - entity: lock
    translation_key: child_lock
    category: config
    dps:
      - id: 41
        type: boolean
        name: lock
  - entity: select
    name: Light mode
    icon: "mdi:television-ambient-light"
    category: config
    dps:
      - id: 40
        type: string
        name: option
        optional: true
        mapping:
          - dps_val: relay
            value: State
          - dps_val: pos
            value: Position
          - dps_val: "on"
            value: "On"
  - entity: binary_sensor
    name: Online
    class: connectivity
    category: diagnostic
    dps:
      - id: 66
        type: boolean
        optional: true
        name: sensor
        mapping:
          - dps_val: offline
            value: false
          - dps_val: online
            value: true
          # if missing, assume online as we can reach it
          - dps_val: null
            value: true
