# lxcommunicator

> Communicate securily with the Loxone Miniserver via Websocket or HTTP requests

Latest version **1.1.1** (published 2020-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install lxcommunicator
pnpm add lxcommunicator
yarn add lxcommunicator
bun add lxcommunicator
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2020-03-08 |
| First published | 2018-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 317 KB |
| Known vulnerabilities | 0 (+26 in 2 direct dependencies) |
| Install scripts | yes |
| GitHub stars | 65 |
| Author | Loxone Electronics GmbH |
| Maintainers | loxone |
| Keywords | Loxone, Miniserver, Loxone Miniserver, Smart Home, Loxone Smart Home, Automation, Home Automation |

## Links

- npm: https://www.npmjs.com/package/lxcommunicator
- Repository: https://www.github.com/Loxone/LxCommunicator
- Homepage: https://www.loxone.com
- npm.io page: https://npm.io/package/lxcommunicator

## Dependencies (12)

- [q](https://npm.io/package/q.md) ^1.5.1
- [when](https://npm.io/package/when.md) ^3.7.8
- [axios](https://npm.io/package/axios.md) ^0.18.1
- [moment](https://npm.io/package/moment.md) ^2.22.2
- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.9-1
- [derequire](https://npm.io/package/derequire.md) ^2.0.6
- [uglify-js](https://npm.io/package/uglify-js.md) ^3.4.9
- [websocket](https://npm.io/package/websocket.md) ^1.0.28
- [browserify](https://npm.io/package/browserify.md) ^16.2.3
- [sprintf-js](https://npm.io/package/sprintf-js.md) ^1.1.1
- [object.values](https://npm.io/package/object.values.md) ^1.0.4
- [node-jsencrypt](https://npm.io/package/node-jsencrypt.md) ^1.0.0

## Recent versions

- 1.1.1 (latest) — 2020-03-08
- 1.0.1 — 2019-07-24
- 0.9.0 — 2018-04-23

## README

# Deprecation Notice ⚠️

This project is no longer maintained and is not up to date with the latest additions to our API, including security improvements. 
For future projects, please refer to the official [API Documentation](https://www.loxone.com/wp-content/uploads/datasheets/CommunicatingWithMiniserver.pdf) for the latest guidelines and updates.
This repository will be archived and made read-only by the end of November 2024.


# LxCommunicator v1.0.1
This module exposes all necessary modules to establish a secure and encrypted connection to a Loxone Miniserver.
<br>
LxCommunicator can be installed using **[npm](http://npmjs.com/)** (``npm i lxcommunicator``) or **[bower](https://bower.io/)** (``bower install lxcommunicator``)

## Disclaimer
- Loxone Electronics GmbH doesn't provide any support for this module
- Please submit an issue or file an pull request if you find any issue

## Support
| Native                              | Supported  |
|:------------------------------------|:-----------|
| Node.js                             | [x]        |
| [Browserify](http://browserify.org/)| [x]        |

| Browser         | Supported   |
|:----------------|:------------|
| Safari (Mobile) | [x]         |
| Chrome (Mobile) | [x]         |
| Firefox         | [x]         |
| Edge            | [x]         |
| IE              | [ ]         |

## Use LxCommunicator
#### Node.js and Browserify
*Example:* `./test/index.js`

> **Note for Browserify**<br>Please make sure [Browserify is correctly configured](http://browserify.org/#install)!
- Add LxCommunicator as a local module
````
npm install lxcommunicator --save
````
- Require LxCommunicator
````
var LxCommunicator = require('lxcommunicator');
````

#### Browser
*Example:* `./test/index.html`
- Add LxCommunicator as a local module
```
npm install lxcommunicator --save
```

- Reference ``LxCommunicator~Browser.js`` in your ``index.html``
```
<script src="{PATH_TO_LXCOMMUNICATOR}/LxCommunicator~Browser.min.js"></script>
```
- LxCommunicator is exposed as a global object

# Developer Notes

## Example
**Please take a look in the `./test` folder and run `npm test` to run `./test/index.js` in Node.js**

## Establish a TLS connection (`https://` and `wss://`)
- A TLS connection is *only* supported by the Miniserver Generation 2
- It is mandatory to enter the URL in the following format to ensure the Certificate matches the domain.
    - This prevents the `ERR_CERT_COMMON_NAME_INVALID` error.
- Both a local and remote connection can be established via the URL below (IPv4 and IPv6)
 
 | IP of the Miniserver                   | Serial Number of the Miniserver | Resulting URL                                            |
 |:---------------------------------------|:--------------------------------|:---------------------------------------------------------|
 | 89.23.45.12                            | 504f94a00001                    | https://89-23-45-12.504f94a00001.dyndns.loxonecloud.com  |
 | 192.168.0.77                           | 504f94a00001                    | https://192-168-0-77.504f94a00001.dyndns.loxonecloud.com |
 | [2001:db8:85a3:8d3:1319:8a2e:370:7348] | 504f94a00001                    | https://2001-db8-85a3-8d3-1319-8a2e-370-7348.504f94a00001.dyndns.loxonecloud.com |
 
 **Further information on on how to establish a TLS connection to a Miniserver Generation 2 can be found [here](https://www.loxone.com/enen/kb/api/)**
 
 **Common issues when using TLS (`https://` and `wss://`)**
 - Expired Certificate
   - Verify your expiration date
 - Common name won't match
   - Verify that your domain matches the common name defined in the certificate
 - Wrong HTTPS port
   - Verify that you port forward the Miniserver Generations 2 port `443` on your router. The external port can be defined as you wish.
   
> **Tip:**<br>Validate your url in the browser, it allows you to easily verify the Certificate against the URL and view the browsers error message.

## Create Browser module
- Execute the `browserify.js` script, it will create the browser modules
````
node ./browserify.js
````

## Set Debug flags
Go to `./vendor/Debug.js` and adopt the flags to your needs.<br>
> **Note:**<br>Don't forget to execute the browserify script every time you make a change in this module!

---
_Source: https://npm.io/package/lxcommunicator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
