Skip to content

Latest commit

 

History

History
92 lines (67 loc) · 3.33 KB

plugins.md

File metadata and controls

92 lines (67 loc) · 3.33 KB

🗀 PLUGINS

C_PLUGINS extends COMMON_COMPONENT

Component to manage/update plugins that extend the functionlity of OpenHaus


Table of contents

  • Schema
  • Methods
    • Add Add new plugin
    • Get Get existing plugin
    • Remove Removes exisiting plugin
    • Update Update plugin
    • Find Find plugin in database
  • Classes

Schema

Name Type Required Default value Description
_id String ObjectId MongoDB ObjectID converted to a String
name String x Human friendly name e.g. "Smasung Smart TV", "Pioneer AV Receiver"
uuid String uuid v4 UUIDv4, which is used as filename
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
autostart Boolean true Autostart/boot the plugin automaticly on start
enabled Boolean true Indicates if user accounts can be used to login/is enabled for use

Example

{
  "_id":"60ede907953fe23d3c585852",
  "name":"ZigBee Gateway (DeCONz)",
  "uuid":"d11e7f38-91cb-4f32-89e8-3452f624bb47",
  "timestamps":{
    "created":1628451824939,
    "updated":null
  },
  "enabled":true,
  "autostart":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 plugin to the database and creates a plugin instance

get(id[,cb])

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

Get a plugin from the .items array

remove(id[,cb])

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

Removes a plugin from the database

update(id, data[,cb])

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

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

find(obj[,cb])

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

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


Classes

class.plugins.js

Represent a plugin instance