name: Camera
products:
  # The product ID (or product_id) from your device information
  - id: 0waimqh4mplog68x
    manufacturer: Nexsmart
    model: AIR 2
entities:
  # ------------------------------------
  # 1. Main Camera & Snapshot
  # ------------------------------------
  - entity: event
    name: Camera
    category: diagnostic
    icon: "mdi:camera-burst"
    # Snapshot trigger (matches movement_detect_pic: 115)
    dps:
      - id: 115
        name: event
        type: base64
        optional: true
        sensitive: true
        mapping:
          - dps_val: null
            value: null
          - value: captured
      - id: 115
        name: snapshot_data
        type: base64
        optional: true
        sensitive: true
  # ------------------------------------
  # 2. Battery and Power
  # ------------------------------------
  - entity: sensor
    class: battery
    category: diagnostic
    # Battery Level Sensor (matches wireless_electricity: 145)
    dps:
      - id: 145
        type: integer
        name: sensor

  - entity: binary_sensor
    class: battery_charging
    # Power Mode Sensor (matches wireless_powermode: 146)
    dps:
      - id: 146
        type: string
        name: sensor
        mapping:
          - dps_val: "0"
            value: false
          - dps_val: "1"
            value: true

  - entity: binary_sensor
    class: connectivity
    category: diagnostic
    # Awake/Sleep Status (matches wireless_awake: 149)
    dps:
      - id: 149
        type: boolean
        name: sensor

  - entity: number
    name: Low battery threshold
    icon: "mdi:battery-alert-variant-outline"
    category: config
    # Low Battery Threshold (matches wireless_lowpower: 147)
    dps:
      - id: 147
        type: integer
        name: value
        unit: "%"
        # Range is 10-50 based on device dump
        range:
          min: 10
          max: 50

  # ------------------------------------
  # 3. Basic Configuration
  # ------------------------------------

  - entity: switch
    translation_key: flip_image
    category: config
    # Flip Image Switch (matches basic_flip: 103)
    dps:
      - id: 103
        type: boolean
        name: switch
        optional: true

  - entity: switch
    name: Watermark
    category: config
    icon: "mdi:watermark"
    # Watermark/OSD Switch (matches basic_osd: 104)
    dps:
      - id: 104
        type: boolean
        name: switch
        optional: true

  - entity: select
    name: Night vision
    icon: "mdi:weather-night"
    category: config
    # Night Vision Mode Selector(matches basic_nightvision: 108)
    dps:
      - id: 108
        type: string
        name: option
        optional: true
        mapping:
          - dps_val: "0"
            value: Auto
          - dps_val: "1"
            value: "Off"
          - dps_val: "2"
            value: "On"

  # ------------------------------------
  # 4. Detection & Alarm
  # ------------------------------------
  - entity: switch
    name: Motion detection
    icon: "mdi:motion-sensor"
    category: config
    # PIR Switch (matches ipc_pir_switch: 240)
    dps:
      - id: 240
        type: boolean
        name: switch

  - entity: number
    name: Motion sensitivity
    icon: "mdi:ruler-square"
    category: config
    # PIR Sensitivity (matches ipc_pir_sensitivity: 241)
    dps:
      - id: 241
        type: integer
        name: value
        # Range is 1-10 based on device dump
        range:
          min: 1
          max: 10

  - entity: switch
    name: Humanoid filter
    icon: "mdi:account-alert"
    category: config
    # Humanoid Filter (matches humanoid_filter: 170)
    dps:
      - id: 170
        type: boolean
        name: switch

  # ------------------------------------
  # 5. Alarm Mode & Linkage
  # ------------------------------------
  # V2 does not support this

  # ------------------------------------
  # 6. Lights & Sirens
  # ------------------------------------
  # V2 does not support this

  # ------------------------------------
  # 7. SD Card and Storage
  # ------------------------------------
  - entity: sensor
    name: SD capacity
    category: diagnostic
    icon: "mdi:micro-sd"
    # SD Capacity Sensor (matches sd_storge: 109)
    dps:
      - id: 109
        type: string
        name: sensor
        optional: true

  - entity: sensor
    name: SD status
    class: enum
    translation_key: status
    category: diagnostic
    icon: "mdi:micro-sd"
    # SD Status Sensor (matches sd_status: 110)
    dps:
      - id: 110
        type: integer
        name: sensor
        optional: true
        mapping:
          - dps_val: 1
            value: normal
          - dps_val: 2
            value: fault
          - dps_val: 3
            value: full
          - dps_val: 4
            value: formatting
          - dps_val: 5
            value: missing
          - dps_val: null
            value: normal

  - entity: button
    name: SD format
    category: config
    icon: "mdi:micro-sd"
    # SD Format Button (matches sd_format: 111) and Status (117)
    dps:
      - id: 111
        type: boolean
        name: button
        optional: true
        persist: false
      - id: 117
        type: integer
        name: state
        optional: true
        persist: false
        mapping:
          - dps_val: -20000
            value: Unknown
          - dps_val: 2000
            value: Formatting
          - dps_val: 2001
            value: Format failed
          - dps_val: 2002
            value: Card missing
          - dps_val: 2003
            value: Card error
          - dps_val: null
            value: Formatted
