Skip to content

Commit

Permalink
First Release of set functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mreschka committed Jan 1, 2018
1 parent 7ab451f commit 5872110
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ helios2mqtt listens to get requests here. You can request status updates for spe
* `2` means connected to both, mqtt and helios KWL

* `helios/set/xxx`:
Will be used for changing variables in helios KWL. Not implmented (yet).
Can be used for changing variables in helios KWL. Set is now implemented but without any checks. The published value will be wirtten as it is. Please read [Helios easyControls Modbus Gateway TCP/IP](https://www.heliosventilatoren.de/mbv/kwl_modbus_easycontrols_82269-001_0917.pdf) for the correct format and/or use the information in helios_Vers.json.

### FHEM integration

Expand Down
14 changes: 7 additions & 7 deletions helios.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Helios.prototype.set = function(varName, value) {
log.err(err);
} else {
log.debug('Helios set succeded for ' + task.heliosVar.name + ' now schedule reading it back.');
this.get(task.heliosVar.name, null);
self.get(task.heliosVar.name, null);
}
});
}
Expand Down Expand Up @@ -207,22 +207,22 @@ function queueWorker(task, callback) {

} else if (task.method == 'set') {

log.debug('Helios set task executing modbus write for varname ' + task.heliosVar.variable + ' with value ' + task.value.toString);
log.debug('Helios set task executing modbus write for varname ' + task.heliosVar.variable + ' with value ' + task.value.toString('ascii'));

const buf = Buffer.alloc(task.heliosVar.modbuslen*2);
buf.fill(0);
Buffer.write(task.heliosVar.variable + '=', 0, 7, 'ascii');
buf.write(task.heliosVar.variable + '=', 0, 7, 'ascii');

Buffer.write(7, value.toString, value.toString.length, 'ascii');
buf.write(task.value.toString('ascii'), 7, task.value.toString('ascii').length, 'ascii');

log.debug('Helios set task modbus write raw value: ' + buf.toString);
log.debug('Helios set task modbus write raw value: ' + buf.toString('ascii'));
task.self.modbusClient.writeMultipleRegisters(1, buf).then(function (resp) {

log.debug('Helios set task modbus write for varname ' + task.heliosVar.variable + ' with value ' + task.value.toString + ' fininshed: ' + JSON.stringify(resp));
log.debug('Helios set task modbus write for varname ' + task.heliosVar.variable + ' with value ' + task.value.toString('ascii') + ' fininshed: ' + JSON.stringify(resp));
callback();

}, function (error) {
log.debug('Helios set task modbus write error varname ' + task.heliosVar.variable + ' with value ' + task.value.toString + ': ' + error);
log.debug('Helios set task modbus write error varname ' + task.heliosVar.variable + ' with value ' + task.value.toString('ascii') + ': ' + error);
task.self.modbusConnected = false;
task.self.emit('disconnect');
callback(error);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "helios2mqtt",
"private": false,
"version": "0.0.9",
"version": "0.0.10",
"description": "Helios Easy Controls modbus tcp to mqtt-smarthome daemon.",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit 5872110

Please sign in to comment.