Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/antonfisher/node-logicmachine-api

LogicMachine Remote services API
https://github.com/antonfisher/node-logicmachine-api

logic-machine nodejs

Last synced: about 1 month ago
JSON representation

LogicMachine Remote services API

Awesome Lists containing this project

README

        

# node-logicmachine-api

[![build](https://travis-ci.org/antonfisher/node-logicmachine-api.svg)](https://travis-ci.org/antonfisher/node-logicmachine-api)
[![npm](https://img.shields.io/npm/dt/node-logicmachine-api.svg?maxAge=86400)](https://www.npmjs.com/package/node-logicmachine-api)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
![status](https://img.shields.io/badge/status-beta-lightgray.svg)

NodeJS API module for LogicMachine Remote services

![Logo](https://raw.githubusercontent.com/antonfisher/node-logicmachine-api/docs/images/node-lm-api.png)

## LogicMahine Versions

Tested on v3 (LogicMachine3 Light).

## Installation

`npm install --save node-logicmachine-api`

## Usage

Module init params:

```javascript
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
})
```

```javascript
var logicmachineApiDefault = require('node-logicmachine-api')();

logicmachineApiDefault.setObjectValue('1/1/1/', '1', function (err, data) {
if (err) {
console.log('Error: ' + err);
}
// do stuff
});
```

```javascript
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:
* [http://evika.ru/](http://evika.ru/)

## License
Copyright (c) 2016 Anton Fisher

MIT License. Free use and change.