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
- The customer has integrated the SDK in the APP, and added and controlled the device normally.
- 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 name | Value description |
---|---|
clientEndpoint | Message subscription address, provided by the developer platform |
certificateFile | Client certificate file, provided by the developer platform |
privateKeyFile | Client private key file, provided by the developer platform |
clientId | Client id, format "P:${corp}", such as corp="bosma", the value is P:Bosma |
topicFilter | Subscribe 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 type | Value description |
---|---|
EventDetected | IPC-Event Detection |
RecordEnd | IPC-Record End |
AIAnalysis | IPC-AI Analysis News |
EventTagReport | IPC-Event Tag Report |
LockLogReport | Lock-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 Name | Data Type | Required | Description |
---|---|---|---|
alarmType | String | Yes | (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 |
originalType | String | Yes | (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 |
endpointId | String | Yes | IPC 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. |
gatewayId | String | yes | If the IPC device has a gateway, it is the UID of the gateway device, otherwise the same as the endpointId |
occurTime | Long | Yes | Occurrence timestamp, seconds |
offsetSeconds | Long | Yes | 0 time zone offset, seconds |
pid | String | Yes | Database primary key |
thumbnailPath | String | No | Screenshot path |
uploadTime | Long | Yes | Background upload time, seconds |
durtTime | Integer | No | Recording time, seconds |
localStatus | Integer | Yes | 1-SD recording exists Other-no SD recording |
cloudStatus | Integer | Yes | 1-cloud video, 2 cloud video but dropped frames Other-no cloud video |
cloudDays | Integer | No | (This field is obsolete) Cloud video retention days |
cloudHours | Integer | No | (New field) Cloud video retention hours |
tag | object | No | (new field) tag data, when the tag arrives first, this variable may not have data |
eventPid | String | Yes | Event pid (pid when uploading EventDetected) |
pid | String | Yes | Tag pid, database primary key |
tagType | Integer | Yes | 10-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. |
TagTime | Long | Yes | Tag occurrence timestamp, seconds |
offsetSeconds | Long | Yes | 0 time zone offset, seconds |
subDeviceId | String | No | When tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell |
width | Integer | No | Analyze the width of the picture when the label is analyzed by AI |
high | Integer | No | When the label is analyzed by AI, the high of the image is analyzed |
snapUrl | String | Yes | Identify the address of the picture |
updateFlag | Boolean | Yes | Whether to modify this label by pid |
data | List<Object> | No | The data attached to the tags of individual events analyzed by AI |
subDeviceId | String | No | When tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell |
subDeviceCode | String | No | Sub-device modelCode |
personName | String | No | When the tag is 99 (family), the name of the family |
personType | String | No | 0-human form, 1-stranger, 2-acquaintance |
precision | Float | No | Accuracy of event labels analyzed by AI |
location | Object | No | Image analysis rectangle position |
left | Integer | No | Left coordinate of rectangle |
right | Integer | No | Right coordinate of the rectangular box |
top | Integer | No | The top coordinate of the rectangle |
bottom | Integer | No | Coordinates 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 Name | Data Type | Required | Description |
---|---|---|---|
alarmType | String | Yes | (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 |
originalType | String | Yes | (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 |
endpointId | String | Yes | IPC 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 |
gatewayId | String | yes | If the IPC device has a gateway, it is the UID of the gateway device, otherwise the same as the endpointId |
occurTime | Long | Yes | Occurrence timestamp, seconds |
offsetSeconds | Long | Yes | 0 time zone offset, seconds |
pid | String | Yes | Database primary key |
thumbnailPath | String | No | Screenshot path |
uploadTime | Long | Yes | Background upload time, seconds |
durtTime | Integer | No | Recording time, seconds |
localStatus | Integer | Yes | 1-SD recording exists Other-no SD recording |
cloudStatus | Integer | Yes | 1-cloud video, 2 cloud video but dropped frames Other-no cloud video |
cloudDays | Integer | No | (This field is obsolete) Cloud video retention days |
cloudHours | Integer | No | (New field) Cloud video retention hours |
tag | object | No | (new field) tag data. When the tag arrives first, this variable may not have data. |
eventPid | String | Yes | Event pid (pid when uploading EventDetected) |
pid | String | Yes | Tag pid, database primary key |
tagType | Integer | Yes | 10-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. |
TagTime | Long | Yes | Tag occurrence timestamp, seconds |
offsetSeconds | Long | Yes | 0 time zone offset, seconds |
subDeviceId | String | No | When tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell |
width | Integer | No | Analyze the width of the picture when the label is analyzed by AI |
high | Integer | No | When the label is analyzed by AI, the high of the image is analyzed |
snapUrl | String | Yes | Identify the address of the picture |
updateFlag | Boolean | Yes | Whether to modify this label by pid |
data | List<Object> | No | The data attached to the tags of individual events analyzed by AI |
subDeviceId | String | No | When tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell |
subDeviceCode | String | No | Sub-device modelCode |
personName | String | No | When the tag is 99 (family), the name of the family |
personType | String | No | 0-human form, 1-stranger, 2-acquaintance |
precision | Float | No | Accuracy of event labels analyzed by AI |
location | Object | No | Image analysis rectangle position |
left | Integer | No | Left coordinate of rectangle |
right | Integer | No | Right coordinate of the rectangular box |
top | Integer | No | The top coordinate of the rectangle |
bottom | Integer | No | Coordinates 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 Name | Data Type | Required | Description |
---|---|---|---|
deviceId | String | Yes | Device ID |
identificationType | String | Yes | Type 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. |
identificationDesc | String | yes | Detection type description |
isFamilyMember | Boolean | Yes | Is it a family member True-Yes False-No |
familyFaceId | String | No | Family member face ID |
familyFaceName | String | No | Family member face input name |
snapUrl | String | Yes | Identify 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 Name | Data Type | Required | Description |
---|---|---|---|
eventPid | String | Yes | Event pid (pid when uploading EventDetected) |
pid | String | Yes | Tag pid, database primary key |
tagType | Integer | Yes | 10-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. |
TagTime | Long | Yes | Occurrence timestamp, seconds |
offsetSeconds | Long | Yes | 0 time zone offset, seconds |
subDeviceId | String | No | When tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell |
width | Integer | No | When the label is analyzed by AI, the width of the image is analyzed |
high | Integer | No | When the label is analyzed by AI, the high of the image is analyzed |
snapUrl | String | Yes | Identify the address of the picture |
updateFlag | Boolean | Yes | Whether to modify this label by pid, the label reported by the device first will be analyzed by AI |
data | List<Object> | No | The data attached to the tags of individual events analyzed by AI |
subDeviceId | String | No | When tagType is equal to 40 or 50, subDeviceId is equal to the device ID of the door sensor or doorbell |
subDeviceCode | String | No | Sub-device modelCode |
personName | String | No | When the tag is 99 (family), the name of the family |
personType | String | No | 0-human form, 1-stranger, 2-acquaintance |
precision | Float | No | Accuracy of event labels analyzed by AI |
location | Object | No | Image analysis rectangle position |
left | Integer | No | Left coordinate of rectangle |
right | Integer | No | Right coordinate of the rectangular box |
top | Integer | No | The top coordinate of the rectangle |
bottom | Integer | No | Coordinates 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 Name | Data Type | Required | Description |
---|---|---|---|
action | Integer | Yes | Lock 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 |
battery | Integer | No | The remaining battery power of the lock device, range: 0-100 |
deviceId | String | Yes | Lock device Uid |
fid | String | No | Fingerprint Id |
fidName | String | No | The nickname corresponding to the fingerprint id |
linkName | String | No | The nickname of the web sharer when the lock is turned on and off through the web link |
logId | String | Yes | Database primary key |
logTime | String | Yes | Occurrence timestamp, seconds |
tinyUid | String | No | When the unlocking type is fingerprint unlocking, tinyuid records the fingerprint mac address |
uploadTime | Long | Yes | Background upload time, seconds |