name: Ceiling fan
products:
  - id: lonfamz9k72cpjgq
    manufacturer: Keyun
    model: MKCFE002
entities:
  - entity: fan
    translation_only_key: fan_with_presets
    dps:
      - id: 60
        type: boolean
        name: switch
      - id: 61
        type: string
        name: preset_mode
        mapping:
          - dps_val: fresh
            value: fresh
          - dps_val: nature
            value: nature
      - id: 62
        type: integer
        name: speed
        range:
          min: 1
          max: 100
      - id: 63
        type: string
        name: direction
      - id: 106
        type: boolean
        name: oscillate
  - entity: switch
    name: Lights
    icon: "mdi:lightbulb-multiple"
    dps:
      - id: 20
        type: boolean
        name: switch
  - entity: light
    dps:
      - id: 20
        type: boolean
        name: available
      - id: 51
        type: base64
        optional: true
        mask: "000100000000000000000000"
        name: switch
        mapping:
          - dps_val: null
            value_mirror: available
      - id: 21
        name: work_mode
        type: string
        mapping:
          - dps_val: white
            value: color_temp
          - dps_val: colour
            value: hs
          - dps_val: scene
            value: Scene
          - dps_val: music
            value: Music
      - id: 22
        name: std_brightness
        type: integer
        range:
          min: 10
          max: 1000
      - id: 51
        type: base64
        optional: true
        mask: "0000000000000000FFFF0000"
        name: brightness
        mapping:
          - dps_val: null
            value_mirror: std_brightness
        range:
          min: 10
          max: 1000
      - id: 23
        name: std_color_temp
        type: integer
        range:
          min: 0
          max: 1000
        mapping:
          - target_range:
              min: 3000
              max: 6000
      - id: 51
        type: base64
        optional: true
        mask: "00000000000000000000FFFF"
        name: color_temp
        mapping:
          - dps_val: null
            value_mirror: std_color_temp
          - target_range:
              min: 3000
              max: 6000
        range:
          min: 0
          max: 1000

  - entity: light
    translation_key: backlight
    dps:
      - id: 20
        type: boolean
        name: available
      - id: 51
        type: base64
        optional: true
        mask: "000200000000000000000000"
        name: switch
        mapping:
          - dps_val: null
            value: false
            hidden: true
      - id: 24
        name: std_rgbhsv
        type: hex
        format:
          - name: h
            bytes: 2
            range:
              min: 0
              max: 360
          - name: s
            bytes: 2
            range:
              min: 0
              max: 1000
          - name: v
            bytes: 2
            range:
              min: 0
              max: 1000
      - id: 51
        type: base64
        optional: true
        force: true
        name: rgbhsv
        format:
          - name: sw
            bytes: 2
          - name: h
            bytes: 2
            range:
              min: 0
              max: 360
          - name: s
            bytes: 2
            range:
              min: 0
              max: 1000
          - name: v
            bytes: 2
            range:
              min: 0
              max: 1000
          - name: wb
            bytes: 2
          - name: wc
            bytes: 2
  - entity: text
    translation_key: scene
    category: config
    icon: "mdi:palette"
    hidden: true
    dps:
      - id: 35
        type: hex
        name: value
  - entity: text
    name: Light control
    category: config
    icon: "mdi:cogs"
    hidden: true
    dps:
      - id: 28
        type: string
        name: value
        optional: true
  - entity: text
    name: Power memory
    category: config
    icon: "mdi:power-settings"
    hidden: true
    dps:
      - id: 33
        type: string
        optional: true
        name: value
  - entity: text
    name: Switch gradient
    category: config
    icon: "mdi:gradient-horizontal"
    hidden: true
    dps:
      - id: 35
        type: string
        optional: true
        name: value
  - entity: text
    name: Mix RGBCW
    category: config
    icon: "mdi:lightbulb"
    hidden: true
    dps:
      - id: 51
        type: base64
        optional: true
        name: value
  - entity: text
    name: Music
    category: config
    icon: "mdi:music"
    hidden: true
    dps:
      - id: 121
        type: string
        optional: true
        name: value
  - entity: switch
    translation_key: do_not_disturb
    category: config
    dps:
      - id: 34
        type: boolean
        name: switch
  - entity: sensor
    name: Fan timer
    class: duration
    category: diagnostic
    dps:
      - id: 64
        type: integer
        name: sensor
        unit: min
  - entity: switch
    translation_key: sound
    category: config
    dps:
      - id: 103
        type: boolean
        name: switch
  - entity: light
    name: White
    category: config
    dps:
      - id: 107
        type: boolean
        name: switch
  - entity: light
    name: Color
    category: config
    dps:
      - id: 108
        type: boolean
        name: switch
  - entity: time
    translation_key: timer
    category: config
    dps:
      - id: 112
        type: integer
        name: second
        optional: true
        range:
          min: 0
          max: 86400
  - entity: switch
    name: Main switch
    category: config
    dps:
      - id: 119
        type: boolean
        name: switch
