Log Module SDK

Last Updated on : 2024-10-11 02:16:04download

The @ray-js/wechat-ms-log SDK integrates capabilities that enable users to get the latest log or all logs through the lock miniapp.

Installation

yarn add @ray-js/wechat-ms-log

// or

npm install @ray-js/wechat-ms-log

Get all logs

getLogList

Request parameters

Parameter Type Description Required
device_id string The device ID. true
start_time number The start time. If there is no time limit, set it to 0. true
end_time number The end time. If there is no time limit, set it to 0. true
user_ids string The user ID of a home member. false
log_categories string The log category. Valid values:
  • operation: operations log
  • unlock_record: unlocking record
  • close_record: locking record
  • alarm_record: alert record
false
last_row_key string The key of the last record in the previous query. This parameter is returned for the previous query and is not required in the first query. false
page_size number The number of records to return per page. The maximum value is 100. false
only_show_media_record boolean Specifies whether to include images. Valid values:
  • true: include images
  • false: not include images
false

Response parameters

Parameter Type Description
has_more boolean Indicates whether more data exists.
last_row_key string The key of the last record in the previous query.
records IResult[] The list of results.

Description of IResult

Parameter Type Description
current_user boolean Indicates whether the record belongs to the current user. This parameter is returned when combined unlocking methods are not used.
data IData The details of the alert record or operations log.
dp_id number The ID of the data point (DP).
log_category string The log category. Valid values:
  • operation: operations log
  • unlock_record: unlocking record
  • close_record: locking record
  • alarm_record: alert record
log_id number The log ID.
log_type ILogType The log type.
media_info_list IMediaInfo[] The information of images or videos taken when unlocking the door.
member_bindable_flag number Indicates whether the unlocking method reported by this log can be bound to a contact. Valid values:
  • 1: yes
  • 0: no. The unlocking method may have been bound to a contact.
record_type number The record type. This parameter is returned only for unlocking records.
  • 1: common unlocking record
  • 2: alert record
time number The log event time. It is a timestamp in milliseconds.
unlock_name string The name of the unlocking method. It may be empty.
user_id string The user ID. This parameter is returned only for unlocking records, duress alarms, and operation logs.
user_name string The name of the user who unlocks the door or the name of the unlocking password.
union_unlock_info IUnlockInfo[] The information about combined unlocking methods.

Description of IMediaInfo

Parameter Type Description
file_url string The full file URL.
file_key string The encryption key.
file_path string The file path.
bucket string The bucket where the file resides.
media_key string The key for pulling the stream of a live video. To navigate to the audio or video playback URL, this data must be carried.
media_url string The URL for pulling the stream of a live video. To navigate to the audio or video playback URL, this data must be carried.

Description of IUnlockInfo

Parameter Type Description
user_name string The name of the user who triggers combined unlocking methods. It may be empty.
op_mode string The type of the unlocking method when combined unlocking methods are used.
unlock_name string The name of the unlocking method when combined unlocking methods are used. It may be empty.
current_user boolean Indicates whether it is the current user when combined unlocking methods are used.
sn number The hardware serial number (SN) when combined unlocking methods are used.

IData string

Example

Value Meaning
wrong_password Consecutive wrong passwords.
wrong_finger Consecutive wrong fingerprints.
wrong_card Consecutive wrong cards.
wrong_face Consecutive wrong faces.
wrong_finger_vein Consecutive wrong finger veins.
wrong_unlock Alert due to consecutive failed verification attempts.
tongue_bad Stuck bolt lock.
too_hot High-temperature alert.
unclosed_time Door left open beyond the expected time.
tongue_not_out Bolt lock not ejected.
pry Anti-pry alert.
key_in Notification of key insertion.
low_battery Alert due to low battery level.
power_off Out-of-battery alert.
shock Vibration alert.
defense Arming alert.
doorbell Doorbell alert.
stay_alarm Loitering alert.
modi_pass Notification of password modification.
add_finger Notification of fingerprint addition.
del_finger Notification of password initialization and fingerprint deletion.
try_open Alert due to an attempt to unlock the door after the door is locked remotely.

ILogType string

Example (they can be defined based on DP names.)

Value Meaning
dev_bind Device binding.
unlock_temporary Custom temporary password.
unlock_dynamic Dynamic password.
unlock_offline_pd Local password.
unlock_phone_remote Remote unlocking.
doorbell Ringing doorbell.

Get the latest log

getlogLatest

Request parameters

Parameter Type Description Required
device_id string The device ID. true

Response parameters

Parameter Type Description
current_user boolean Indicates whether the record belongs to the current user. This parameter is returned when combined unlocking methods are not used.
data string The details of the alert record or operations log.
dp_id number The DP ID.
exist boolean Indicates whether the latest log exists.
log_category string The log category. Valid values:
  • operation: operations log
  • unlock_record: unlocking record
  • close_record: locking record
  • alarm_record: alert record
log_id number The log ID.
log_type string The log type.
record_type number The record type. This parameter is returned only for unlocking records.
  • 1: common unlocking record
  • 2: alert record
time number The log event time.
un_read_count number The number of unread records.
unlock_name string The name of the unlocking method. It may be empty.
user_id string The user ID. This parameter is returned only for unlocking records, duress alarms, and operation logs.
user_name string The user name.
union_unlock_info IUnlockInfo[] The information about combined unlocking methods.