You can use the Mongo database to apply changes to the BOS.



Introduction

There is a dedicated collection called "messages". Unless the other collections where the BOS creates the documents per asset, you, as a third party, will create documents in this collection.

One document is dedicated to one change request you want to apply to the BOS. The BOS is listening in real-time to every document you may create.

Once the document is created you can no longer modify it, it's pointless, only new documents are handled by the BOS 

Once the BOS learnt about a new document (== a demand for a change), the BOS will edit the document and add a new field "ack" with the current timestamp. This is meant to tell you "ok, got it" but it doesn't mean the change was applied correctly because there may be several communication layers to pass through to deliver your change request.

Only when the change is effectively applied and the BOS get the feedback value, it will update the associated document (in the points, schedules or alarms collection) so you can subscribe to it to receive the final value.

It would be possible for example that you request a change to a certain value, you receive a slightly different value. Example, on a control damper, there is usually a min opening value embedded in the controller. If you ask for 0%, the controller may allow only a minimum of 50%, so you would get "50" after a change request of "0".


The diagram below shows the sequence order:

Each type of of change request will require a specific document syntax as shown after.



Change a point value

Let's focus now on a Point data type value change.

This is the following format to create for the document to create to request a point value change:

{
    "type": "POINT_ACTION",
    "deviceId": "<DeviceId>",
    "pointId": "<PointId>",
    "payload": {
        "action": "<action>",   
        "value": <value to be set>,
        "duration": <override duration>
    }
 }


Two examples below. The ack field is added by the BOS.


A request for change could be denied by the BOS in the following conditions:



Create a schedule regular event

It's possible to create regular events on a Schedule. See Schedule data type for more information about regular events.

The document syntax to do so is as follow:

{
  "type": "CREATE_RECURRING_EVENT",
  "deviceId": "<DeviceId>",
  "scheduleId": "<ScheduleId>",
  "payload": {
    "eventId": "<Your own id>",
    "weekday": "<weekday>",
    "startTime": "<startTime>",
    "endTime": "<endTime>",
    "value": <value>
  }
}




Delete a schedule regular event

It's possible to delete a regular event on a Schedule if you know its unique id (the event id). See Schedule data type for more information about regular events.

The document syntax to do so is as follow:

{
  "type": "DELETE_RECURRING_EVENT",
  "deviceId": "<DeviceId>",
  "scheduleId": "<ScheduleId>",
  "eventId": "<Your own id>"
}



Create a schedule special event

It's possible to create special events on a Schedule. See Schedule data type for more information about special events.

The document syntax to do so is as follow:

{
  "type": "CREATE_SPECIAL_EVENT",
  "deviceId": "<DeviceId>",
  "scheduleId": "<ScheduleId>",
  "payload": {
    "eventId": "<Your own id>",
    "eventName": "<Your own event name>",
    "startDate": "<startDate>",
    "endDate": "<endDate>",
    "value": <value>
  }
}



Update a schedule special event

It's possible to update a special event if you know its unique id that was used to create it.

The document syntax to do so is as follow:

{
  "type": "UPDATE_SPECIAL_EVENT",
  "deviceId": "<DeviceId>",
  "scheduleId": "<ScheduleId>",
  "eventId": "<Your own id>",
    "payload": {
      "startDate": "<startDate>",
      "endDate": "<endDate>",
      "value": <value>
  }
}



Delete a schedule special event

It's possible to delete a special event on a Schedule if you know its unique id that was used to create it. See Schedule data type for more information about special events.

The document syntax to do so is as follow:

{
  "type": "DELETE_SPECIAL_EVENT",
  "deviceId": "<DeviceId>",
  "scheduleId": "<ScheduleId>",
  "eventId": "<Your own id>"
}



Ack an alarm

To acknowledge an alarm, you will need to retrieve its "uuid", this is the unique identifier of an alarm event.

{
    "type": "ACK_ALARM",
    "payload": {
        "uuid": "<uuid of the alarm to ack>"
    }
 }