lametric-local
v1.0.1
Published
An asynchronous client library for the API of LaMetric Time devices in local network.
Readme
LaMetric Local 1.0.1
An asynchronous client library for the API of LaMetric Time devices in local network.
const LaMetricLocal = require('lametric-local');
const client = new LaMetricLocal({
base_url: '',
basic_authorization: ''
});
client.getWifiState()
.then(console.log)
.catch(console.error);Installation
npm install lametric-local
You will need to retrieve your basic authorization and internal ip (port is 8080). You can follow instructions here.
const LaMetricLocal = require('lametric-local');
const client = new LaMetricLocal({
base_url: 'http://<internal ip>:8080',
basic_authorization: '<basic authorization>'
});Requests
With endpoints
You now have the ability to make GET, POST, PUT and DELETE requests against the API via the convenience methods.
client.get(path, params);
client.post(path, params);
client.put(path, params);
client.delete(path, params);You simply need to pass the endpoint and parameters to one of convenience methods. Take a look at the documentation site to reference available endpoints.
client.get('device');With client methods
You can use the defined client methods to call endpoints.
client.getDeviceState();Promises
The request will return Promise.
client.getDeviceState()
.then(function (data) {
console.log(data)
})
.catch(function (e) {
throw e;
});