node-logicmachine-api
v0.1.2
Published
LogicMachine Remote services API (evika.ru)
Downloads
5
Readme
node-logicmachine-api
NodeJS API module for LogicMachine Remote services
LogicMahine Versions
Tested on v3 (LogicMachine3 Light).
Installation
npm install --save node-logicmachine-api
Usage
Module init params:
var logicmachineApi = require('node-logicmachine-api')({
host: '10.10.10.10', // {String} default '192.168.0.10:80'
username: 'bob', // {String} default 'remote'
password: 'sponge', // {String} default 'remote'
protocol: 'https', // {String} default 'http'
format: 'json', // {String} default 'json' ['json', 'xml', 'rss']
apiPath: '/secret-path', // {String} default '/cgi-bin/scada-remote/request.cgi'
logger: logger.debug // {Function|Boolean} default console.log
})
var logicmachineApiDefault = require('node-logicmachine-api')();
logicmachineApiDefault.setObjectValue('1/1/1/', '1', function (err, data) {
if (err) {
console.log('Error: ' + err);
}
// do stuff
});
var logicmachineApiCustom = require('node-logicmachine-api')({
host: '10.10.10.10:8080',
username: 'bob',
password: 'sponge',
logger: false
});
logicmachineApiCustom.getObjects(function (err, data) {
if (err) {
console.log('Error: ' + err);
}
// do stuff
});
Methods
All methods with callback will call it with (err, data) params:
err {Error|undefined}
;
data {Object|Array|Boolean|undefined}
.
Objects address format:
1/1/1
.
|Method|Description|
|---|---|
| getAlerts(callback)
| callback {Function} Returns last 50 alerts |
| getErrors(callback)
| callback {Function} Returns last 50 errors |
| getObjects(callback)
| callback {Function} Returns objects marked as export sorted by last update time |
| findObject(address, callback)
| address {String} [required] callback {Function} Returns object value by address |
| getObjectValue(address, callback)
| address {String} [required] callback {Function} Returns current object value by address |
| setObjectValue(address, value, callback)
| address {String} [required] value {String} [required] callback {Function} Set object value by address |
| setObjectValueWithoutKNX(address, value, callback)
| address {String} [required] value {String} [required] callback {Function} Set object value by address without sending message to KNX |
| sendResponseToKNXObject(address, value, callback)
| address {String} [required] value {String} [required] callback {Function} Send response to KNX by object address |
| sendReadToKNXObject(address, value, callback)
| address {String} [required] callback {Function} Send read message to KNX by object address |
| createUrl(query)
| query {Object} object of URL params Create custom API url |
Development
Run tests: npm test
;
Run Grunt watch: grunt watch
.
Contributing
Please take care to maintain the existing coding style, unit tests for any changed functionality.
Use npm run lint
and npm test
your code.
Release History
- 0.1.2 Migrate to NodeJs v5, update dependencies, use standard code style
- 0.1.1 Update initial params, add logger configuration
- 0.1.0 Initial release
Links:
License
Copyright (c) 2016 Anton Fisher
MIT License. Free use and change.