name: Smartplug with USB
products:
  - id: zmql6aexy8ua5rox
    manufacturer: Gosund
    model: SP112
  - id: re5wqraswcozglky
    manufacturer: Gosund
    model: SP6
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
    hidden: unavailable
    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
      - id: 20
        type: integer
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - value: true
  - entity: sensor
    category: diagnostic
    class: current
    hidden: unavailable
    dps:
      - id: 18
        name: sensor
        type: integer
        class: measurement
        force: true
        optional: true
        unit: mA
      - id: 23
        type: integer
        name: calibration
        optional: true
      - id: 18
        type: integer
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - value: true
  - entity: sensor
    category: diagnostic
    class: power
    hidden: unavailable
    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
      - id: 19
        type: integer
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - value: true
  - entity: sensor
    class: energy
    category: diagnostic
    hidden: true
    dps:
      - id: 17
        type: integer
        optional: true
        name: sensor
        unit: kWh
        class: total_increasing
        mapping:
          - scale: 1000
  - entity: time
    category: config
    translation_key: timer
    hidden: unavailable
    dps:
      - id: 9
        type: integer
        optional: true
        name: second
        range:
          min: 0
          max: 86400
      - id: 9
        type: integer
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - value: true
  - entity: time
    category: config
    translation_key: timer_x
    translation_placeholders:
      x: USB
    hidden: unavailable
    dps:
      - id: 15
        type: integer
        optional: true
        name: second
        range:
          min: 0
          max: 86400
      - id: 15
        type: integer
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - value: true
  - entity: select
    translation_key: initial_state
    category: config
    hidden: unavailable
    dps:
      - id: 38
        type: string
        optional: true
        name: option
        mapping:
          - dps_val: power_on
            value: "on"
            available: alternate
          - dps_val: power_off
            value: "off"
            available: alternate
          - dps_val: last
            value: memory
            available: alternate
          - dps_val: "on"
            value: "on"
            available: standard
          - dps_val: "off"
            value: "off"
            available: standard
          - dps_val: memory
            value: memory
            available: standard
          - dps_val: "0"
            value: "off"
            available: numeric
          - dps_val: "1"
            value: "on"
            available: numeric
          - dps_val: "2"
            value: memory
            available: numeric
      - id: 38
        type: string
        optional: true
        name: standard
        mapping:
          - value: false
            conditions:
              - dps_val: ["on", "off", memory]
                value: true
              - dps_val: null
                value: true  # allow options to populate at init
      - id: 38
        type: string
        optional: true
        name: alternate
        mapping:
          - value: false
            conditions:
              - dps_val: [power_on, power_off, last]
                value: true
      - id: 38
        type: string
        optional: true
        name: numeric
        mapping:
          - value: false
            conditions:
              - dps_val: ["0", "1", "2"]
                value: true
      - id: 38
        type: string
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - value: true
  - entity: select
    translation_key: light_mode
    category: config
    hidden: unavailable
    dps:
      - id: 39
        type: string
        name: option
        optional: true
        mapping:
          - dps_val: relay
            value: state
          - dps_val: pos
            value: locator
          - dps_val: none
            value: "off"
      - id: 39
        type: string
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - value: true
  - entity: lock
    translation_key: child_lock
    category: config
    hidden: unavailable
    dps:
      - id: 40
        type: boolean
        optional: true
        name: lock
      - id: 40
        type: boolean
        optional: true
        name: available
        mapping:
          - dps_val: null
            value: false
          - value: true
  - 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
  - entity: text
    translation_key: schedule
    category: config
    hidden: true
    dps:
      - id: 41
        type: base64
        optional: true
        name: value
  - entity: text
    name: Randomized schedule
    category: config
    icon: "mdi:island"
    hidden: true
    dps:
      - id: 42
        type: base64
        optional: true
        name: value
  - entity: text
    name: Inching
    category: config
    icon: "mdi:toggle-switch"
    hidden: true
    dps:
      - id: 43
        type: string
        optional: true
        name: value
