Skip to content

Latest commit

 

History

History
121 lines (96 loc) · 4.32 KB

endpoints.md

File metadata and controls

121 lines (96 loc) · 4.32 KB

🗀 endpointS

C_ENDPOINTS extends COMMON_COMPONENT

Component to manage/update endpoints, which should represent your phiscal building.


Table of contents


Schema

Name Type Required Default value Description
_id String ObjectId MongoDB ObjectID converted to a String
name String x Human friendly name
room String ObjectId ObjectID of a room
device String x ObjectId ObjectID of a device
commands Array [] Array of commands which can issued to control the deivce. See class.commands.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":"604a75e6eb5de037846df24f",
  "name":"AV - Receiver",
  "room":"604a62e292c9d22044003c84",
  "device":"603fe5d18791152879a9babc",
  "commands":[
    {
      "name":"Power On",
      "payload":"PWR01",
      "interface":"603fe5d18791152879a9babd",
      "_id":"604a75e6eb5de037846df24c"
    },
    {
      "name":"Power Off",
      "payload":"PWR00",
      "interface":"603fe5d18791152879a9babd",
      "_id":"604a75e6eb5de037846df24d"
    },
    {
      "name":"Mute Toggle",
      "payload":"AMTTG",
      "interface":"603fe5d18791152879a9babd",
      "_id":"604a75e6eb5de037846df24e"
    },
    {
      "name":"Power Toggle",
      "payload":"POWER",
      "interface":"603fe5d18791152879a9babd",
      "_id":"604a75e6eb5de037846df24f"
    }
  ],
  "timestamps":{
    "created":1615492582995,
    "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 endpoint to the database and creates a endpoint instance

get(id[,cb])

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

Get a endpoint from the .items array

remove(id[,cb])

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

Removes a endpoint from the database

update(id, data[,cb])

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

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

find(obj[,cb])

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

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


Classes

class.endpoints.js

Represent a endpoint instance