name: Keypad lock
products:
  - id: g7rboh0x
    manufacturer: Hornbill
    model: Y4
entities:
  - entity: lock
    dps:
      # [Add unlocking method] After the device is online, add unlocking
      # methods. Support adding fingerprint, password, card and face unlocking
      # methods; support administrator tagging.
      - id: 1
        type: string
        optional: true
        sensitive: true
        name: unlock_method_create
      # [Delete unlocking method] After the device is online, delete the
      # unlocking method. Supports deleting fingerprint, password, card and
      # face unlocking methods. This dp appears in pairs with the added dp.
      - id: 2
        type: string
        optional: true
        sensitive: true
        name: unlock_method_delete
      # [Modify unlocking method] After the device is online, you can modify
      # the name of the unlocking method and the content of the password.
      - id: 3
        type: string
        optional: true
        name: unlock_method_modify
      # [Report unlocking record] is used for the device to report the record
      # of fingerprint unlocking. This dp is only enabled when the smart lock
      # product has a fingerprint recognition function in the hardware.
      - id: 12
        type: integer
        name: unlock_fingerprint
        optional: true
        persist: false
        range:
          min: 0
          max: 999
      # [Report unlocking record] is used for the device to report the record
      # of unlocking with ordinary password. This dp is enabled only when the
      # hardware of this smart lock product has a password button that can be
      # used to unlock the door with a password.
      - id: 13
        name: unlock_password
        type: integer
        optional: true
        persist: false
        range:
          min: 0
          max: 999
      # [Report unlocking record] is used for the device to report the door
      # card unlocking record. This dp is enabled only when the smart lock
      # product has a card swiping function in the hardware and can report the
      # card swiping record.
      - id: 15
        name: unlock_card
        type: integer
        optional: true
        persist: false
        range:
          min: 0
          max: 999
      # [Report unlocking record] If the device supports detection of door
      # opening from the inside, it is used for the device to report the record
      # of door opening from the inside. This dp is enabled only when the
      # hardware of this smart lock product can detect and identify unlocking
      # from the inside and can report the data.
      - id: 18
        name: open_inside
        type: boolean
        optional: true
      # [Report unlocking record] is used for the device to report the door
      # opening record generated by the mobile phone app Bluetooth unlocking.
      # Generally, all Bluetooth locks support this function.
      - id: 19
        name: unlock_ble
        type: integer
        optional: true
        persist: false
        range:
          min: 0
          max: 999
      # [Report lock record] is used for the device to report the lock record.
      # If the lock is controlled by the mobile phone app or the lock is
      # manually closed locally, this dp can be used to report.
      - id: 20
        type: string
        optional: true
        name: lock_record
      # [Lock Operation] is used to trigger the device to perform the lock
      # operation, which can be used for automatic lock and manual lock
      # operation. To report the lock (close) record, you need to use dp=20
      # lock record. You need to use 2 dp in combination to fully implement the
      # lock operation and lock record reporting. In addition to these two dp,
      # you also need to use dp47=lock status to report the lock status, so
      # that the unlock/lock status displayed on the app is consistent with
      # the local hardware.
      - id: 46
        type: boolean
        name: lock
        optional: true
      # [Device Status] is used to report the status of the device clutch
      # switch, that is, the switch status of the lock. This dp is enabled only
      # when the product hardware supports the detection of the lock status.
      - id: 47
        type: boolean
        optional: true
        name: lock_state
      # [Online Temporary Password] is used to add an online temporary
      # password, and supports setting time periods and recurring time limits.
      - id: 51
        type: string
        optional: true
        sensitive: true
        name: temporary_password_create
      # [Online temporary password] is used to delete the online temporary
      # password.
      - id: 52
        type: string
        optional: true
        persist: false
        name: temporary_password_delete
      # [Online temporary password] is used to modify the password content and
      # corresponding validity period of the online temporary password.
      - id: 53
        type: string
        optional: true
        sensitive: true
        persist: false
        name: temporary_password_modify
      # [Synchronous unlocking method] is used to synchronize all unlocking
      # methods on the local device with the mobile phone. It is strongly
      # recommended to enable this function.
      - id: 54
        type: string
        optional: true
        persist: false
        sensitive: true
        name: synch_method
      # [Report unlocking record] is used for the device to report the record
      # of online temporary password unlocking.
      - id: 55
        type: integer
        name: unlock_temp_pwd
        optional: true
        persist: false
        range:
          min: 0
          max: 999
      # [Remote unlocking operation] is used to trigger the remote unlocking
      # operation of the device. It is recommended to enable this DP and
      # develop this function. Only when this function is supported and the
      # door lock is connected to the Bluetooth gateway, can the voice control
      # door opening and closing function be realized with smart speaker
      # products such as Alexa or Google Home.
      - id: 61
        type: string
        optional: true
        persist: false
        sensitive: true
        name: remote_no_dp_key
      # [Report unlocking records] is used for the device to report the records
      # of remote unlocking via mobile phone.
      - id: 62
        type: integer
        name: unlock_app
        optional: true
        persist: false
        range:
          min: 0
          max: 999
      # [Report unlocking record] is used for the device to report the record
      # of voice unlocking. This function depends on dp61 = remote door opening
      # (with verification code). It needs to be enabled with dp62 and pay for
      # the voice door opening value-added service at the iot platform
      # value-added service center before this function can be used.
      - id: 63
        type: integer
        name: unlock_voice
        optional: true
        persist: false
        range:
          min: 0
          max: 999
      # [Offline Password] is used to synchronize the timestamp between the
      # cloud and the device. If it is not selected or not synchronized, the
      # offline password will not be available.
      - id: 64
        type: string
        optional: true
        persist: false
        name: password_offline_time
      # [Offline password clear] When a single offline password is cleared
      # locally on the device, the clearing operation record is reported.
      - id: 65
        type: string
        optional: true
        persist: false
        name: offline_pwd_cleared
      # [Offline password clear] When all offline passwords are cleared locally
      # on the device, the clearing operation record is reported.
      - id: 66
        type: string
        optional: true
        persist: false
        sensitive: true
        name: unlock_offline_clear
      # [Report unlocking record] is used for the device to report offline
      # password unlocking records.
      - id: 67
        type: string
        name: unlock_offline_pwd
        optional: true
        persist: false
        sensitive: true
      # [Bluetooth Unlock] is used to configure the verification information
      # required when the device performs Bluetooth unlocking.
      - id: 70
        type: string
        name: check_code_set
        optional: true
        persist: false
        sensitive: true
      # [Bluetooth Unlock] is used to trigger the device to perform Bluetooth
      # unlocking. The trigger source can be a mobile phone, an accessory, or
      # proximity unlocking.
      - id: 71
        type: string
        name: ble_unlock_check
        optional: true
        persist: false
        sensitive: true
      # [Remote unlock] is used to configure the key required for remote
      # unlocking. If the device needs to be unlocked remotely, this DP is
      # required.
      - id: 73
        type: string
        name: remote_pd_setkey_check
        optional: true
        persist: false
        sensitive: true
  - entity: event
    name: Alert
    dps:
      # [Alarm record] When an alarm occurs locally, it is used to report the
      # alarm record of the device. Corresponding value description:
      # 0=fingerprint trial error alarm
      # 1=password trial error alarm
      # 2=card trial error alarm
      # 3=face trial error alarm
      # 4=fake lock (lock tongue stuck)
      # 5=high temperature alarm
      # 6=timeout failure to close the door
      # 7=electronic lock tongue not popped up
      # 8=anti-pry alarm, 9=key insertion
      # 10=low power alarm,
      # 11=battery exhaustion alarm
      # 12=vibration alarm
      # 13=arming alarm
      # If the device only uses a few items in the alarm dp, the redundant
      # content does not need to be deleted. If deleted, the serial number of
      # the MCU needs to be adjusted when reporting. It is recommended that
      # developers do not change the enumeration value in the alarm. In special
      # circumstances, please add, delete, and configure multiple languages
      # under the guidance of pm.
      - id: 21
        type: string
        name: event
        optional: true
        mapping:
          - dps_val: wrong_finger
            value: wrong_finger
          - dps_val: wrong_password
            value: wrong_password
          - dps_val: wrong_card
            value: wrong_card
          - dps_val: wrong_face
            value: wrong_face
          - dps_val: tongue_bad
            value: tongue_bad
          - dps_val: too_hot
            value: too_hot
          - dps_val: unclosed_time
            value: unclosed_time
          - dps_val: tongue_not_out
            value: tongue_not_out
          - dps_val: pry
            value: pry
          - dps_val: key_in
            value: key_in
          - dps_val: low_battery
            value: low_battery
          - dps_val: power_off
            value: power_off
          - dps_val: shock
            value: shock
          - dps_val: defense
            value: defense
          - dps_val: wrong_unlock
            value: wrong_unlock
      # [Doorbell] If the local doorbell ringtone of the device supports
      # switching, you can use this DP to switch the local doorbell ringtone of
      # the door lock on the app; this DP is only enabled if the hardware of
      # this smart lock product supports doorbell ringtone switching and the
      # user is allowed to switch on the app.
      - id: 26
        type: string
        name: event
        optional: true
        mapping:
          - dps_val: ding_0
            value: ding_0
          - dps_val: ding_1
            value: ding_1
  # [Device Status] is used to display the power level in percentage. The range
  # is -1 to 100. When the device reports a value of -1, the power level is not
  # displayed. (Choose one from DP9).
  - entity: sensor
    class: battery
    dps:
      - id: 8
        type: integer
        name: sensor
        unit: "%"
        optional: true
  # [Language] is used to set the playback language of the local navigation
  # voice of the device.
  # 0 = Simplified Chinese
  # 1 = English
  # 2 = Japanese
  # 3 = German
  # 4 = Spanish
  # 5 = Latin
  # 6 = French
  # 7 = Russian
  # 8 = Italian
  # 9 = Traditional Chinese
  # 10 = Korean
  # This dp is only enabled if the hardware of this smart lock product supports
  # language switching and allows users to switch on the app.
  - entity: select
    translation_key: language
    category: config
    dps:
      - id: 28
        type: string
        name: option
        optional: true
        mapping:
          - dps_val: chinese_simplified
            value: chinese
          - dps_val: english
            value: english
  # [Volume] is used to set the volume of the local navigation voice of the
  # device. This dp is only enabled when the hardware of this smart lock
  # product supports door lock volume adjustment and the user is allowed to
  # switch the operation on the app.
  - entity: select
    name: Volume
    category: config
    dps:
      - id: 31
        type: string
        name: option
        optional: true
        mapping:
          - dps_val: mute
            value: Mute
          - dps_val: low
            value: Low
          - dps_val: normal
            value: Normal
          - dps_val: high
            value: High
  # [Device Status] If the device has indoor anti-lock detection, it is used to
  # report the switch status of indoor anti-lock. Only select this dp when the
  # hardware of this smart lock product can detect the anti-lock status and
  # report the data. This dp is only used to display the anti-lock status on
  # the door lock home page interface, and cannot perform anti-lock setting
  # operations.
  # Commented since DP gets reported even if the device doesn't support it.
  # - entity: switch
  #   name: Indoor anti-lock
  #   category: config
  #   dps:
  #     - id: 32
  #       type: boolean
  #       name: switch
  #       optional: true
  # [Automatic Lock] is used to set the switch of the automatic locking
  # function. Through this dp, you can set "Enable automatic locking" and "No
  # automatic locking", that is, the device will not automatically lock, and it
  # can also be used as a normally open mode. Only when the door lock hardware
  # supports this setting, enable this dp and dp36, "Automatic Lock Delay" can
  # be used together to achieve "Automatic Lock after Unlocking xx Seconds" to
  # set the waiting time for automatic locking after unlocking.
  - entity: switch
    name: Automatic lock
    category: config
    icon: "mdi:lock-reset"
    dps:
      - id: 33
        type: boolean
        name: switch
        optional: true
  # [Device Status] If the device has door opening and closing status
  # detection, it is used to report the door opening and closing status. Only
  # enable this dp if this function is supported.
  # Commented since DP gets reported even if the device doesn't support it.
  # - entity: sensor
  #   category: config
  #   class: enum
  #   name: Door status
  #   dps:
  #     - id: 40
  #       type: string
  #       name: sensor
  #       optional: true
  #       mapping:
  #         - dps_val: unknown
  #           value: Unknown
  #         - dps_val: open
  #           value: Open
  #         - dps_val: closed
  #           value: Closed
  # [Approach Unlock] is used to set the delay time of automatic locking in the
  # approach unlock scenario. If it is not enabled, the original automatic
  # locking delay time will be retained.
  # Commented since DP gets reported even if the device doesn't support it.
  # - entity: select
  #   name: Approach unlock delay
  #   category: config
  #   dps:
  #     - id: 89
  #       type: string
  #       name: option
  #       optional: true
  #       mapping:
  #         - dps_val: inactive
  #           value: Inactive
  #         - dps_val: 4s
  #           value: 4s
  #         - dps_val: 6s
  #           value: 6s
  #         - dps_val: 8s
  #           value: 8s
  #         - dps_val: 10s
  #           value: 10s
  #         - dps_val: 12s
  #           value: 12s
  # [Automatic Lock] is used to set the delay time from unlocking the device to
  # automatically locking the device. The setting range is 1s to 30min.
  - entity: number
    name: Automatic lock delay
    icon: "mdi:lock-clock"
    category: config
    dps:
      - id: 36
        type: integer
        name: value
        optional: true
        unit: s
        range:
          min: 1
          max: 1800
