Ecosyste.ms: Awesome

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

https://github.com/hobbyquaker/homematic-rega

Node.js Homematic CCU ReGaHSS Remote Script Interface
https://github.com/hobbyquaker/homematic-rega

homematic interface node-module regahss remote script smarthome

Last synced: 22 days ago
JSON representation

Node.js Homematic CCU ReGaHSS Remote Script Interface

Lists

README

        

# homematic-rega

[![NPM version](https://badge.fury.io/js/homematic-rega.svg)](http://badge.fury.io/js/homematic-rega)
[![dependencies Status](https://david-dm.org/hobbyquaker/homematic-rega/status.svg)](https://david-dm.org/hobbyquaker/homematic-rega)
[![Build Status](https://travis-ci.org/hobbyquaker/homematic-rega.svg?branch=master)](https://travis-ci.org/hobbyquaker/homematic-rega)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![License][mit-badge]][mit-url]

> Node.js Homematic CCU ReGaHSS Remote Script Interface

This module encapsulates the communication with the "ReGaHSS" - the logic layer of the Homematic CCU.

* execute arbitrary scripts
* get names and ids of devices and channels
* get variables including their value und meta data
* set variable values
* get programs
* execute programs
* activate/deactivate programs
* get rooms and functions including assigned channels
* rename objects

i18n placeholders (e.g. `${roomKitchen}`) are translated by default.

You can find offical and inoffical documentation of the homematic scripting language at
[wikimatic.de](http://www.wikimatic.de/wiki/Script_Dokumentation).

Pull Requests welcome! :)

## Install

`$ npm install homematic-rega`

## Usage Example

```javascript
const Rega = require('homematic-rega');

const rega = new Rega({host: '192.168.2.105'});

rega.exec('string x = "Hello";\nWriteLine(x # " World!");', (err, output, objects) => {
if (err) {
throw err;
}
console.log('Output:', output);
console.log('Objects:', objects);
});

rega.getVariables((err, res) => {
console.log(res);
});
```

## API

## Rega
**Kind**: global class

* [Rega](#Rega)
* [new Rega(options)](#new_Rega_new)
* _instance_
* [.exec(script, [callback])](#Rega+exec)
* [.script(file, [callback])](#Rega+script)
* [.getChannels(callback)](#Rega+getChannels)
* [.getValues(callback)](#Rega+getValues)
* [.getPrograms(callback)](#Rega+getPrograms)
* [.getVariables(callback)](#Rega+getVariables)
* [.getRooms(callback)](#Rega+getRooms)
* [.getFunctions(callback)](#Rega+getFunctions)
* [.setVariable(id, val, [callback])](#Rega+setVariable)
* [.startProgram(id, [callback])](#Rega+startProgram)
* [.setProgram(id, active, [callback])](#Rega+setProgram)
* [.setName(id, name, [callback])](#Rega+setName)
* _inner_
* [~scriptCallback](#Rega..scriptCallback) : function

### new Rega(options)

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| options | object | | |
| options.host | string | | hostname or IP address of the Homematic CCU |
| [options.language] | string | "de" | language used for translation of placeholders in variables/rooms/functions |
| [options.disableTranslation] | boolean | false | disable translation of placeholders |
| [options.tls] | boolean | false | Connect using TLS |
| [options.inSecure] | boolean | false | Ignore invalid TLS Certificates |
| [options.auth] | boolean | false | Use Basic Authentication |
| [options.user] | string | | Auth Username |
| [options.pass] | string | | Auth Password |
| [options.port] | number | 8181 | rega remote script port. Defaults to 48181 if options.tls is true |

### rega.exec(script, [callback])
Execute a rega script

**Kind**: instance method of [Rega](#Rega)

| Param | Type | Description |
| --- | --- | --- |
| script | string | string containing a rega script |
| [callback] | [scriptCallback](#Rega..scriptCallback) | |

### rega.script(file, [callback])
Execute a rega script from a file

**Kind**: instance method of [Rega](#Rega)

| Param | Type | Description |
| --- | --- | --- |
| file | string | path to script file |
| [callback] | [scriptCallback](#Rega..scriptCallback) | |

### rega.getChannels(callback)
Get all devices and channels

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| callback | Rega~channelCallback |

### rega.getValues(callback)
Get all devices and channels values

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| callback | Rega~valuesCallback |

### rega.getPrograms(callback)
Get all programs

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| callback | Rega~programsCallback |

### rega.getVariables(callback)
Get all variables

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| callback | Rega~variablesCallback |

### rega.getRooms(callback)
Get all rooms

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| callback | Rega~roomsCallback |

### rega.getFunctions(callback)
Get all functions

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| callback | Rega~functionsCallback |

### rega.setVariable(id, val, [callback])
Set a variables value

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| id | number |
| val | number \| boolean \| string |
| [callback] | function |

### rega.startProgram(id, [callback])
Execute a program

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| id | number |
| [callback] | function |

### rega.setProgram(id, active, [callback])
Activate/Deactivate a program

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| id | number |
| active | boolean |
| [callback] | function |

### rega.setName(id, name, [callback])
Rename an object

**Kind**: instance method of [Rega](#Rega)

| Param | Type |
| --- | --- |
| id | number |
| name | string |
| [callback] | function |

### Rega~scriptCallback : function
**Kind**: inner typedef of [Rega](#Rega)

| Param | Type | Description |
| --- | --- | --- |
| err | Error | |
| output | string | the scripts output |
| variables | Object.<string, string> | contains all variables that are set in the script (as strings) |

## Related projects

* [node-red-contrib-ccu](https://github.com/hobbyquaker/node-red-contrib-ccu) - Node-RED nodes for the Homematic CCU.
* [homematic-manager](https://github.com/hobbyquaker/homematic-manager) - Cross-platform App to manage Homematic devices
and links.
* [hm2mqtt.js](https://github.com/hobbyquaker/hm2mqtt.js) - Interface between Homematic and MQTT.
* [binrpc](https://github.com/hobbyquaker/binrpc) - Node.js client/server for the Homematic BINRPC protocol.
* [homematic-xmlrpc](https://github.com/hobbyquaker/homematic-xmlrpc) - Node.js client/server for the Homematic XMLRPC
protocol.

## License

MIT (c) Sebastian Raff

[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat
[mit-url]: LICENSE