Skip to content

Latest commit

 

History

History
115 lines (87 loc) · 3.94 KB

devices.md

File metadata and controls

115 lines (87 loc) · 3.94 KB

🗀 DEVICES

C_DEVICES extends COMMON_COMPONENT

Component to manage/update devices, which are used to implement the underlying connectivity of OpenHaus.


Table of contents


Schema

Name Type Required Default value Description
_id String ObjectId MongoDB ObjectID convert to a String
name String x Human friendly name that represents the device
interfaces Array x Interfaces that OpenHaus can connect to, see class.interfaces.js
timestamps Object Timestamps, when something was done to the object e.g. created/updated
timestamps.created Number Date.now() Unix timestamp, set when .add is called to Date.now()
timestamps.updated Number null Unix timestamp, set to Date.now() when .update is called
enabled Boolean true Indicates if the device should be handeld

Example

{
  "_id":"603fe5d18791152879a9babc",
  "name":"AV - Receiver",
  "interfaces":[
    {
      "type":"ETHERNET",
      "transport":"tcp",
      "settings":{
        "host":"172.16.0.121",
        "port":60128
      },
      "_id":"603fe5d18791152879a9babd",
      "adapter":[
        "eiscp"
      ]
    }
  ],
  "timestamps":{
    "created":1614800337353,
    "updated":null
  },
  "enabled":true
}

Methods

add(data[,cb])

  • data {Object} Object structure as defined in schema.
  • cb {Function} Callback function, if absent, a promise is returned.

Add a new device to the database and creates a device instance

get(id[,cb])

  • id {String} Device id as defined in schema.
  • cb {Function} Callback function, if absent, a promise is returned.

Get a device from the .items array

remove(id[,cb])

  • id {String} Device id as defined in schema.
  • cb {Function} Callback function, if absent, a promise is returned.

Removes a device from the database

update(id, data[,cb])

  • id {String} Device id as defined in schema.
  • data {Object} Properties to update on device id object/instance.
  • cb {Function} Callback function, if absent, a promise is returned.

Updates a device object in database & device instance in .items array

find(obj[,cb])

  • obj {Object} Key/value to look for devices.
  • cb {Function} Callback function, if absent, a promise is returned.

Find device with mathing key/values pair in the .items array


Classes

🗀 class.adapter.js

Implements a adapter instance

🗀 class.device.js

Represent a device instance

🗀 class.interface.js

Represent a device instance

🗀 class.interfaceStream.js

Represent a device instance