Socket
Socket
Sign inDemoInstall

comfoairq

Package Overview
Dependencies
71
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0 to 0.6.1

81

lib/bridge.js
'use strict';
const Buffer = require('safe-buffer').Buffer;
const udp = require('dgram');
const dgram = require('dgram');
const tcp = require('net');

@@ -123,54 +123,44 @@ const events = require('events');

// discovery of the ventilation unit / LAN C adapter
async discovery() {
const listener = udp.createSocket('udp4');
async discover(multicastAddr) {
const client = dgram.createSocket('udp4');
return new Promise((resolve, reject) => {
listener.bind(this._settings.port, () => {
const txdata = Buffer.from('0a00', 'hex');
client.on('error', (err) => {
reject(err);
});
client.on('message', (message, remote) => {
if (this._settings.debug) {
this.logger(' -> TX (UDP) : ' + txdata.toString('hex'));
this.logger(' <- RX (UDP) : ' + message.toString('hex'));
this.logger(' (' + remote.address + ':' + remote.port + ')');
}
if (this._settings.comfoair == null) {
listener.addMembership(this._settings.multicast);
listener.setBroadcast(true);
if (message.toString('hex') != '0a00') {
client.close();
listener.send(txdata, this._settings.port, null);
} else {
listener.send(txdata, this._settings.port, this._settings.comfoair);
const protoData = messages.DiscoveryOperation.decode(message);
resolve(
{
'comfouuid' : protoData.searchGatewayResponse.uuid,
'device' : protoData.searchGatewayResponse.ipaddress,
'port' : this._settings.port
}
);
}
});
listener.on('error', (err) => {
reject(err);
});
client.bind(this._settings.port, () => {
const txdata = Buffer.from('0a00', 'hex');
listener.on('close', () => {
// preparation of the TX header
this._settings.uuid.copy(this.txheader, 4);
this._settings.comfouuid.copy(this.txheader, 20);
const result = {
'localuuid' : this._settings.uuid,
'comfouuid' : this._settings.comfouuid,
'device' : this._settings.comfoair,
'port' : this._settings.port
};
resolve(result);
});
listener.on('message', (message, remote) => {
if (this._settings.debug) {
this.logger(' <- RX (UDP) : ' + message.toString('hex'));
this.logger(' (' + remote.address + ':' + remote.port + ')');
this.logger(' Dicovering... ' + multicastAddr);
this.logger(' -> TX (UDP) : ' + txdata.toString('hex'));
}
const protoData = messages.DiscoveryOperation.decode(message);
this._settings.comfoair = protoData.searchGatewayResponse.ipaddress;
this._settings.comfouuid = protoData.searchGatewayResponse.uuid;
client.setBroadcast(true);
listener.close();
client.send(txdata, this._settings.port, multicastAddr);
});
});

@@ -187,19 +177,2 @@ }

async discover() {
return new Promise((resolve,reject) => {
try {
this.discovery()
.then((result) => {
if (this._settings.debug) {
this.logger(' discovery complete -> ' + config.getTimestamp());
}
resolve(result);
});
}
catch (exc) {
reject(exc);
}
});
}
async transmit(data) {

@@ -206,0 +179,0 @@ if (!this.isconnected) {

@@ -17,11 +17,9 @@ 'use strict';

'pin' : options.pin,
'uuid' : Buffer.from(options.uuid, 'hex'),
'uuid' : Object.prototype.hasOwnProperty.call(options, 'uuid') ? Buffer.from(options.uuid, 'hex') : null,
'device' : options.device,
'comfoair' : options.comfoair,
'comfouuid': Buffer.from(options.comfouuid, 'hex'),
'multicast': options.multicast,
'comfouuid': Object.prototype.hasOwnProperty.call(options, 'comfouuid') ? Buffer.from(options.comfouuid, 'hex') : null,
'port' : options.port || 56747,
'debug' : options.debug,
'verbose' : options.verbose,
'logger' : options.logger,

@@ -190,3 +188,2 @@ 'keepalive': 15000

_reconnect() {
if (this._status.connected) {

@@ -198,10 +195,5 @@ return;

.then(() => {
//if (!this._status.resume) {
// re-register to all previously registered sensors
this.sensors.forEach(async sensor => {
const result = await this.RegisterSensor(sensor);
if (this._settings.verbose) {
this.logger('SENSID: ' + sensor.toString() + ' - ' + JSON.stringify(result));
}
await config.sleep(100);

@@ -227,28 +219,21 @@ });

});
}
// run a specific discovery of the comfoair device
async discover() {
async discover(multicastAddr) {
return new Promise((resolve, reject) => {
try {
this._bridge.discover(this._settings)
.then(async (options) => {
this.logger('comfoIP : ' + options.device + ':' + options.port);
this.logger('comfoUUID : ' + options.comfouuid.toString('hex') + ' --> ' + JSON.stringify(options.comfouuid));
this.logger('localUUID : ' + options.localuuid.toString('hex'));
this._bridge.discover(multicastAddr)
.then((result) => {
this.logger('comfoIP : ' + result.device + ':' + result.port);
this.logger('comfoUUID : ' + result.comfouuid.toString('hex') + ' --> ' + JSON.stringify(result.comfouuid));
resolve(
{
'comfoair': options.device,
'port': options.port,
'comfouuid': options.comfouuid.toString('hex')
}
);
});
}
catch (exc) {
reject(exc);
}
resolve(
{
'comfouuid': result.comfouuid.toString('hex'),
'comfoair': result.device,
'port': result.port
}
);
})
.catch(reject);
});

@@ -419,3 +404,2 @@ }

});
}

@@ -422,0 +406,0 @@

{
"name": "comfoairq",
"version": "0.6.0",
"version": "0.6.1",
"description": "NodeJS Zehnder ComfoAirQ implementation",

@@ -5,0 +5,0 @@ "main": "lib/comfoconnect.js",

# node-comfoairq
Library to control a Zehnder Comfoair Q series of ventilation devices
**This is a fork with a lot of changes - check original repo by herrJones**
A Zehnder ComfoConnect LAN C interface is required to make this work
[Changes since fork](https://github.com/klein0r/node-comfoairq/compare/c1655c659f66bf5a452f9df83a95c08c659ee5ed...master)
Development of this node.js plugin is heavily inspired on the work performed by:
Library to control a Zehnder Comfoair Q series of ventilation devices (e.g. Q350)
* Michael Arnauts (https://github.com/michaelarnauts/comfoconnect)
* Marco Hoyer (https://github.com/marco-hoyer/zcan) and its forks on github (djwlindenaar, decontamin4t0R)
## Requirements
An API is provided to connect and read sensor data from the ComfoAirQ-unit
1. *Zehnder Comfoair Q* series of ventilation device (e.g. Q350)
2. *Zehnder ComfoConnect LAN C* interface
Revision history:
* 0.5.0 : first working version
* 0.5.1 : general bugfixes
* 0.5.2 : better handling of (forced) disconnects
* 0.5.3 : complete dependencies in package.json
* 0.5.4 : fix bug with registering devices
* 0.5.5 : extra commands to send to the comfoconnect device
get time added
## Test Script

@@ -56,4 +46,2 @@

If a valid UUID is provided for the comfoconnect device, a discovery operation is no longer needed
## Quick-start

@@ -79,4 +67,5 @@

zehnder.discover();
const deviceInfo = await zehnder.discover('172.16.255.255');
await zehnder.StartSession(true);

@@ -87,2 +76,10 @@ // ..... do something ......

```
```
## Credits
Development of this node.js plugin is heavily inspired on the work performed by:
* Jan Van Belle (https://github.com/herrJones/node-comfoairq)
* Michael Arnauts (https://github.com/michaelarnauts/comfoconnect)
* Marco Hoyer (https://github.com/marco-hoyer/zcan) and its forks on github (djwlindenaar, decontamin4t0R)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc