name: Smartplug with USB
products:
  - id: zmql6aexy8ua5rox
    manufacturer: Gosund
    model: SP112
entities:
  - entity: switch
    class: outlet
    dps:
      - id: 1
        type: boolean
        name: switch
      - id: 21
        type: bitfield
        name: factory_test
        optional: true
  - entity: switch
    name: USB
    icon: "mdi:usb"
    dps:
      - id: 7
        type: boolean
        name: switch
  - entity: sensor
    category: diagnostic
    class: voltage
    dps:
      - id: 20
        name: sensor
        type: integer
        class: measurement
        optional: true
        force: true
        unit: V
        mapping:
          - scale: 10
      - id: 22
        type: integer
        name: calibration
        optional: true
  - entity: sensor
    category: diagnostic
    class: current
    dps:
      - id: 18
        name: sensor
        type: integer
        class: measurement
        force: true
        optional: 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
        optional: true
        unit: W
        mapping:
          - scale: 10
      - id: 24
        type: integer
        name: calibration
        optional: true
  - entity: number
    category: config
    name: Outlet timer
    class: duration
    translation_key: timer
    dps:
      - id: 9
        type: integer
        name: value
        unit: min
        range:
          min: 0
          max: 86400
        mapping:
          - scale: 60
            step: 60
  - entity: number
    name: USB timer
    category: config
    class: duration
    translation_key: timer
    dps:
      - id: 15
        type: integer
        name: value
        unit: min
        range:
          min: 0
          max: 86400
        mapping:
          - scale: 60
            step: 60
  - entity: select
    translation_key: initial_state
    category: config
    dps:
      - id: 38
        type: string
        optional: true
        name: option
        mapping:
          - dps_val: power_on
            value: "on"
          - dps_val: power_off
            value: "off"
          - dps_val: last
            value: memory
  - entity: select
    name: Indicator
    icon: "mdi:led-on"
    category: config
    dps:
      - id: 39
        type: string
        name: option
        optional: true
        mapping:
          - dps_val: relay
            value: State
          - dps_val: pos
            value: Position
          - dps_val: none
            value: "Off"
  - entity: binary_sensor
    class: problem
    category: diagnostic
    dps:
      - id: 26
        type: bitfield
        name: sensor
        optional: true
        mapping:
          - dps_val: 0
            value: false
          - value: true
      - id: 26
        type: bitfield
        name: fault_code
        optional: true
