Cloud event message subscription

Bosma Cloud sends the events reported by the device to the MQTT message queue of AWS-IoT; partner Cloud subscribe to relevant messages from AWS-IoT, save them to their own database, and implement functions such as message push and event query. This article mainly introduces how to subscribe to device event messages and how to parse subscription data.

Requirements

  1. The customer has integrated the SDK in the APP, and added and controlled the device normally.
  2. The customer has applied for a message subscription certificate and it has been approved.

Message Subscription

AWS-IOT news subscription official document address:

https://docs.aws.amazon.com/iot/latest/developerguide/iot-sdks.html

https://amazonaws-china.com/cn/iot-core/resources/#AWS_IoT_device_SDKs

JAVA developers can refer to the bosma-cloud-sdk-event-subscriber-demo project.

Message subscription parameter configuration

Field nameValue description
clientEndpointMessage subscription address, provided by the developer platform
certificateFileClient certificate file, provided by the developer platform
privateKeyFileClient private key file, provided by the developer platform
clientIdClient id, format "P:${corp}", such as corp="bosma", the value is P:Bosma
topicFilterSubscribe topic, S2P/S:server/P:${corp}/event

Message content analysis

JSON format, including message id (msgId), message type (msgType), creation timestamp (createTimestamp), data packet (payload), etc. The message types are described as follows. Among them, the first four are IPC product news. IPC products include indoor cameras, video doorbells, and outdoor cameras.

An event video of an IPC product can correspond to multiple tags, such as "motion detection" or "family" and other tags. The concept of "tag" is added to this, and the relationship between the event and the tag is one For many, the two are related by the pid of the event and the eventPid of the tag. If there is no docking AI package function, just subscribe to EventDetected and RecordEnd events. If there is a docking AI package function, you need to subscribe to AIAnalysis (cloud AI detection results, such as Sentry, EX series) and EventTagReport (device-side AI, HomeStation + low-power products) events in order to push notifications to users in time. If you have docked the door lock series products, you need to subscribe to LockLogReport to receive the door lock switch lock log, abnormal log, etc.

Message typeValue description
EventDetectedIPC-Event Detection
RecordEndIPC-Record End
AIAnalysisIPC-AI Analysis News
EventTagReportIPC-Event Tag Report
LockLogReportLock-door lock log report

IPC EventDetected (EventDetected)

Return data sample

{
  "msgId": "5fbf53409257834cc88d45f79613e31e",
  "msgType": "EventDetected",
  "createTimestamp": 1606374327,
  "payload": {
    "alarmType": "10",
    "originalType": "10",
    "endpointId": "KH3GUSRCKBD4366Z111A",
    "gatewayId": "KH3GUSRCKBD4366Z111A",
    "occurTime": 1584170313,
    "offsetSeconds": 28800,
    "pid": "5e6c8558efb86434dddc4746a2979074",
    "thumbnailPath": "http://121.199.68.60/group1/M00/59/71/rBAgnF5shViAOU_lAAE9ORbXFB0013.jpg?token=0add279cb5eebda4d123737f23dbfcf2&ts=1584171228",
    "uploadTime": 1584170328,
    "localStatus": 1,
    "cloudStatus": 1,
    "cloudDays": 7,
    "cloudHours": 168,
    "tag": {
      "eventPid": "5e6c8558efb86434dddc4746a2979074",
      "pid": "5e6c8558efb86434dddc4746a2979074",
      "tagType": 10,
      "tagTime": 1584170328,
      "offsetSeconds": 28800,
      "subDeviceId": "KH3GUSRCKBD4366Z111A",
      "width": 1080,
      "high": "720",
      "snapUrl": "http://121.199.68.60/group1/M00/59/71/rBAgnF5shViAOU_lAAE9ORbXFB0013.jpg?token=0add279cb5eebda4d123737f23dbfcf2&ts=1584171228",
      "updateFlag": false,
      "data": [
        {
          "subDeviceId": "KH3GUSRCKBD4366Z111A",
          "subDeviceCode": "010501",
          "personName": "jack",
          "personType": "1",
          "precision": 0.98945,
          "location": {
            "left": 1,
            "right": 2,
            "top": 3,
            "bottom": 4
          }
        }
      ]
    }
  }
}

payload data description

Field NameData TypeRequiredDescription
alarmTypeStringYes(This field is obsolete) 10-motion detection, 20-sound detection, 30-human infrared sensor PIR 40-door magnetic event, 50-simple doorbell (thumbnailPath is null) 60-visual Doorbell incident 62-Video doorbell does not answer message 63-Video doorbell is busy message 95-Humanoid 103-Abnormal stay
originalTypeStringYes(New field) Original event type on the firmware side, used to retrieve local video files during local video playback. 10-Motion detection, 20-Voice detection, 30-Human infrared sensor PIR 40-Door sensor event, 50-Simple doorbell (thumbnailPath is null) 60-Visual doorbell event 62-Video doorbell no answer message 63-Yes The doorbell is busy leaving a message 95-humanoid 103-abnormal stay
endpointIdStringYesIPC device UID (the original UID representing the attachment has been moved to the label), if the ipc device does not have a gateway, it is the same as the gatewayId, otherwise it is different.
gatewayIdStringyesIf the IPC device has a gateway, it is the UID of the gateway device, otherwise the same as the endpointId
occurTimeLongYesOccurrence timestamp, seconds
offsetSecondsLongYes0 time zone offset, seconds
pidStringYesDatabase primary key
thumbnailPathStringNoScreenshot path
uploadTimeLongYesBackground upload time, seconds
durtTimeIntegerNoRecording time, seconds
localStatusIntegerYes1-SD recording exists Other-no SD recording
cloudStatusIntegerYes1-cloud video, 2 cloud video but dropped frames Other-no cloud video
cloudDaysIntegerNo(This field is obsolete) Cloud video retention days
cloudHoursIntegerNo(New field) Cloud video retention hours
tagobjectNo(new field) tag data, when the tag arrives first, this variable may not have data
eventPidStringYesEvent pid (pid when uploading EventDetected)
pidStringYesTag pid, database primary key
tagTypeIntegerYes10-motion detection, 20-sound detection, 30-human infrared sensor PIR 40-door magnetic event, 50-simple doorbell (thumbnailPath is null) 60-visual doorbell event 62-visual Doorbell no answer message 63-Video doorbell is busy leaving message, 95-humanoid, 97-delivering package, 98-suspected to steal package, 99-family, 103-abnormal stay in the follow-up business, may continue to increase the type value, please visit When processing tags, do not store them directly, but filter out tags that are not supported by your system.
TagTimeLongYesTag occurrence timestamp, seconds
offsetSecondsLongYes0 time zone offset, seconds
subDeviceIdStringNoWhen tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell
widthIntegerNoAnalyze the width of the picture when the label is analyzed by AI
highIntegerNoWhen the label is analyzed by AI, the high of the image is analyzed
snapUrlStringYesIdentify the address of the picture
updateFlagBooleanYesWhether to modify this label by pid
dataList<Object>NoThe data attached to the tags of individual events analyzed by AI
subDeviceIdStringNoWhen tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell
subDeviceCodeStringNoSub-device modelCode
personNameStringNoWhen the tag is 99 (family), the name of the family
personTypeStringNo0-human form, 1-stranger, 2-acquaintance
precisionFloatNoAccuracy of event labels analyzed by AI
locationObjectNoImage analysis rectangle position
leftIntegerNoLeft coordinate of rectangle
rightIntegerNoRight coordinate of the rectangular box
topIntegerNoThe top coordinate of the rectangle
bottomIntegerNoCoordinates of the bottom of the rectangle

IPC Event Detection End (EventRecordEnd)

Return data sample

{
  "msgId": "5fbf53409257834cc88d45f79613e31e",
  "msgType": "EventRecordEnd",
  "createTimestamp": 1606374327,
  "payload": {
    "alarmType": "10",
    "originalType": "10",
    "endpointId": "KH3GUSRCKBD4366Z111A",
    "gatewayId": "KH3GUSRCKBD4366Z111A",
    "occurTime": 1584170313,
    "offsetSeconds": 28800,
    "pid": "5e6c8558efb86434dddc4746a2979074",
    "thumbnailPath": "http://121.199.68.60/group1/M00/59/71/rBAgnF5shViAOU_lAAE9ORbXFB0013.jpg?token=0add279cb5eebda4d123737f23dbfcf2&ts=1584171228",
    "uploadTime": 1584170328,
    "durtTime": 21,
    "localStatus": 1,
    "cloudStatus": 1,
    "cloudDays": 7,
    "cloudHours": 168,
    "tag": {
      "eventPid": "5e6c8558efb86434dddc4746a2979074",
      "pid": "5e6c8558efb86434dddc4746a2979074",
      "tagType": 10,
      "tagTime": 1584170328,
      "offsetSeconds": 28800,
      "subDeviceId": "KH3GUSRCKBD4366Z111A",
      "width": 1080,
      "high": "720",
      "snapUrl": "http://121.199.68.60/group1/M00/59/71/rBAgnF5shViAOU_lAAE9ORbXFB0013.jpg?token=0add279cb5eebda4d123737f23dbfcf2&ts=1584171228",
      "updateFlag": false,
      "data": [
        {
          "subDeviceId": "KH3GUSRCKBD4366Z111A",
          "subDeviceCode": "010501",
          "personName": "jack",
          "personType": "1",
          "precision": 0.98945,
          "location": {
            "left": 1,
            "right": 2,
            "top": 3,
            "bottom": 4
          }
        }
      ]
    }
  }
}

Payload field description

Field NameData TypeRequiredDescription
alarmTypeStringYes(This field is obsolete) 10-motion detection, 20-sound detection, 30-human infrared sensor PIR 40-door magnetic event, 50-simple doorbell (thumbnailPath is null) 60-visual Doorbell incident 62-Video doorbell does not answer message 63-Video doorbell is busy message 95-Humanoid 103-Abnormal stay
originalTypeStringYes(New field) Original event type on the firmware side, used to retrieve local video files during local video playback. 10-Motion detection, 20-Voice detection, 30-Human infrared sensor PIR 40-Door sensor event, 50-Simple doorbell (thumbnailPath is null) 60-Visual doorbell event 62-Video doorbell no answer message 63-Yes The doorbell is busy leaving a message 95-humanoid 103-abnormal stay
endpointIdStringYesIPC device UID (the original UID representing the attachment has been moved to the label), if the ipc device does not have a gateway, it is the same as the gatewayId, otherwise different
gatewayIdStringyesIf the IPC device has a gateway, it is the UID of the gateway device, otherwise the same as the endpointId
occurTimeLongYesOccurrence timestamp, seconds
offsetSecondsLongYes0 time zone offset, seconds
pidStringYesDatabase primary key
thumbnailPathStringNoScreenshot path
uploadTimeLongYesBackground upload time, seconds
durtTimeIntegerNoRecording time, seconds
localStatusIntegerYes1-SD recording exists Other-no SD recording
cloudStatusIntegerYes1-cloud video, 2 cloud video but dropped frames Other-no cloud video
cloudDaysIntegerNo(This field is obsolete) Cloud video retention days
cloudHoursIntegerNo(New field) Cloud video retention hours
tagobjectNo(new field) tag data. When the tag arrives first, this variable may not have data.
eventPidStringYesEvent pid (pid when uploading EventDetected)
pidStringYesTag pid, database primary key
tagTypeIntegerYes10-motion detection, 20-sound detection, 30-human infrared sensor PIR 40-door magnetic event, 50-simple doorbell (thumbnailPath is null) 60-visual doorbell event 62-visual Doorbell no answer message 63-Video doorbell is busy leaving message, 95-humanoid, 97-delivering package, 98-suspected to steal package, 99-family, 103-abnormal stay in the follow-up business, may continue to increase the type value, please visit When processing tags, do not store them directly, but filter out tags that are not supported by your system.
TagTimeLongYesTag occurrence timestamp, seconds
offsetSecondsLongYes0 time zone offset, seconds
subDeviceIdStringNoWhen tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell
widthIntegerNoAnalyze the width of the picture when the label is analyzed by AI
highIntegerNoWhen the label is analyzed by AI, the high of the image is analyzed
snapUrlStringYesIdentify the address of the picture
updateFlagBooleanYesWhether to modify this label by pid
dataList<Object>NoThe data attached to the tags of individual events analyzed by AI
subDeviceIdStringNoWhen tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell
subDeviceCodeStringNoSub-device modelCode
personNameStringNoWhen the tag is 99 (family), the name of the family
personTypeStringNo0-human form, 1-stranger, 2-acquaintance
precisionFloatNoAccuracy of event labels analyzed by AI
locationObjectNoImage analysis rectangle position
leftIntegerNoLeft coordinate of rectangle
rightIntegerNoRight coordinate of the rectangular box
topIntegerNoThe top coordinate of the rectangle
bottomIntegerNoCoordinates of the bottom of the rectangle

AI Analysis Results (AIAnalysis)

Return data sample

{
    "msgId": "5fbf53409257834cc88d45f79613e31e",
    "msgType": "AIAnalysis",
    "createTimestamp": 1606374327,
    "payload": {
        "deviceId": "KH3GUSRCKBD4366Z111A",
        "identificationType": 99,
        "identificationDesc": “FAMILY MEMBER”,
        "isFamiliyMember": yes,
        "familyFaceId": "5e6c8558efb86434dddc4746a2979074",
        "familyFaceName": "Trump",
        "snapUrl": ”http: //121.199.68.60/group1/M00/59/71/rBAgnF5shViAOU_lAAE9ORbXFB0013.jpg?token=0add279cb5eebda4d123737f23dbfcf2&ts=1584171228”
    }
}

Payload field description

Field NameData TypeRequiredDescription
deviceIdStringYesDevice ID
identificationTypeStringYesType of detection result: 99 — FAMILY MEMBER 30 — STRANGER 31 — COURIER courier 32 — SUSPICIOUS STRANGER Suspicious stranger 10 — PEDESTRAIN pedestrian 0 — NON-HUMAN Non-pedestrian-1 — UNKOWN IDENTIFY TYPE fails to identify the type. The subsequent sequence may add other types of detection results due to business reasons. Please do not directly store them during processing, but filter out types that are not supported by your system.
identificationDescStringyesDetection type description
isFamilyMemberBooleanYesIs it a family member True-Yes False-No
familyFaceIdStringNoFamily member face ID
familyFaceNameStringNoFamily member face input name
snapUrlStringYesIdentify the address of the picture

Event Tag Report (EventTagReport)

Return data sample

{
  "msgId": "5fbf53409257834cc88d45f79613e31e",
  "msgType": "EventTagReport",
  "createTimestamp": 1606374327,
  "payload": {
    "eventPid": "5e6c8558efb86434dddc4746a2979074",
    "pid": "5e6c8558efb86434dddc4746a2979074",
    "tagType": 10,
    "tagTime": 1584170328,
    "offsetSeconds": 28800,

    "subDeviceId": "KH3GUSRCKBD4366Z111A",
    "width": 1080,
    "high": "720",
    "snapUrl": "http://121.199.68.60/group1/M00/59/71/rBAgnF5shViAOU_lAAE9ORbXFB0013.jpg?token=0add279cb5eebda4d123737f23dbfcf2&ts=1584171228",
    "updateFlag": false,
    "data": [
      {
        "subDeviceId": "KH3GUSRCKBD4366Z111A",
        "subDeviceCode": "010501",
        "personName": "jack",
        "personType": "1",
        "precision": 0.98945,
        "location": {
          "left": 1,
          "right": 2,
          "top": 3,
          "bottom": 4
        }
      }
    ]
  }
}

Payload field description

Field NameData TypeRequiredDescription
eventPidStringYesEvent pid (pid when uploading EventDetected)
pidStringYesTag pid, database primary key
tagTypeIntegerYes10-motion detection, 20-sound detection, 30-human infrared sensor PIR 40-door magnetic event, 50-simple doorbell (thumbnailPath is null) 60-visual doorbell event 62-visual The doorbell does not answer the message 63-the video doorbell is busy leaving a message, 95-humanoid, 97-parcel delivery, 98-suspected to steal the package, 99-family member, 103-abnormal stay in the follow-up business, may continue to increase the type value, please go to When processing tags, do not store them directly, but filter out tags that are not supported by your system.
TagTimeLongYesOccurrence timestamp, seconds
offsetSecondsLongYes0 time zone offset, seconds
subDeviceIdStringNoWhen tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell
widthIntegerNoWhen the label is analyzed by AI, the width of the image is analyzed
highIntegerNoWhen the label is analyzed by AI, the high of the image is analyzed
snapUrlStringYesIdentify the address of the picture
updateFlagBooleanYesWhether to modify this label by pid, the label reported by the device first will be analyzed by AI
dataList<Object>NoThe data attached to the tags of individual events analyzed by AI
subDeviceIdStringNoWhen tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell
subDeviceCodeStringNoSub-device modelCode
personNameStringNoWhen the tag is 99 (family), the name of the family
personTypeStringNo0-human form, 1-stranger, 2-acquaintance
precisionFloatNoAccuracy of event labels analyzed by AI
locationObjectNoImage analysis rectangle position
leftIntegerNoLeft coordinate of rectangle
rightIntegerNoRight coordinate of the rectangular box
topIntegerNoThe top coordinate of the rectangle
bottomIntegerNoCoordinates of the bottom of the rectangle

Lock Log Report (LockLogReport)

Return data sample

{
  "msgId": "5fbf53409257834cc88d45f79613e31e",
  "msgType": "LockLogReport",
  "createTimestamp": 1606374327,
  "payload": {
    "action": 255,
    "battery": 20,
    "deviceId": "KH3GUSRCKBD4366Z111A",
    "fid": "0",
    "fidName": "Fingerprint name-1",
    "linkName": "mark",
    "logId": "615522aadf1675a076c34b6db3de542f",
    "logTime": 1632969387,
    "tinyUid": "DEBB20C0",
    "uploadTime": 1632969387
  }
}

Payload field description

Field NameData TypeRequiredDescription
actionIntegerYesLock log types, including A. Unlock related: 0-local unlock, 1-remote unlock, 2-fingerprint unlock, 3-guest unlock, 4 -temporary web unlock, 5-voice unlock, 6 rules Engine unlock, 255 manual unlock; B. Lock related: 128 local lock, 129 remote lock, 131 guest lock, 132 temporary, web lock, 133 voice lock, 134 rule engine lock, 254 manual lock door C. Status change: 100: open the door, 101 close the door; D. Abnormal warning related: 64-impact, 65-blocking, 66-six-axis sensor abnormality, 67-flash abnormality, 68-the door has not been closed for a long time, 71- Three-axis sensor is abnormal, 72-photoelectric switch is abnormal
batteryIntegerNoThe remaining battery power of the lock device, range: 0-100
deviceIdStringYesLock device Uid
fidStringNoFingerprint Id
fidNameStringNoThe nickname corresponding to the fingerprint id
linkNameStringNoThe nickname of the web sharer when the lock is turned on and off through the web link
logIdStringYesDatabase primary key
logTimeStringYesOccurrence timestamp, seconds
tinyUidStringNoWhen the unlocking type is fingerprint unlocking, tinyuid records the fingerprint mac address
uploadTimeLongYesBackground upload time, seconds

Updated at January 12th, 2023