Skip to content

MartenWibom/gluelockjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interface for controlling and getting updates from lock "GlueLock".

Node.js Package

Requirement

  • Gluelock with WiFi module
  • Key owner's mail address and password (for getting API key)

Get started

Install module

npm install gluelock

Get API key

curl --request POST 'https://user-api.gluehome.com/v1/api-keys' \
--header 'Content-Type: application/json' \
-u your_email@example.com:your_password \
--data-raw '{
    "name": "Glue Key",
    "scopes": ["events.read", "locks.read", "locks.write"]
}'

API

Methods

  • GlueLockManager.init()
  • GlueLock.lock()
  • GlueLock.unlock()

Attributes

  • GlueLockManager.locks
  • GlueLock.data
  • GlueLock.status

Events

  • locked
  • unlocked

Data

Data & event data payload

{
    data: {
        battery: 87, 
        serialNumber: 'GLXXA.ALXXXX.XXXX', 
        firmwareVersion: '1.30', 
        connectionStatus: 'connected', 
        description: 'Door X'
    },
    event: 'localUnlock',
    state: 'completed',
    status: 'unlocked',
    updated: '2021-10-24T22:24:21+02:00'
}

Example usage

const { GlueLockManager } = require('gluelock')

const apiKey = '<api key from curl/http request above>'
const lockManager = new GlueLockManager({ apiKey })

    ;
(async () => {
    const locks = await lockManager.init()

    const lock = locks[0]

    lock.on('locked', (evt) => {
        console.log(evt)
    })

    lock.on('unlocked', (evt) => {
        console.log(evt)
    })

    setTimeout(async () => {
        console.log('Lock yourself in!')
        await lock.lock()
    }, 1000)
})()