From f629b5678e10bd6d7dbfee5c172298d69302aed6 Mon Sep 17 00:00:00 2001 From: spddl Date: Sun, 25 Oct 2020 15:31:00 +0100 Subject: [PATCH 1/2] Update maxcube.js if rf_address == '000000' all temperature for all devices are set --- maxcube.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/maxcube.js b/maxcube.js index 6110a98..794cb94 100644 --- a/maxcube.js +++ b/maxcube.js @@ -270,8 +270,12 @@ MaxCube.prototype.setTemperature = function(rf_address, degrees, mode, untilDate checkInitialised.call(this); var self = this; + var room_id = this.deviceCache[rf_address].room_id; + if (rf_address === '000000') { + room_id = '00'; // '00' sets all temperature for all devices + } degrees = Math.max(2, degrees); - var command = MaxCubeCommandFactory.generateSetTemperatureCommand (rf_address, this.deviceCache[rf_address].room_id, mode || 'MANUAL', degrees, untilDate); + var command = MaxCubeCommandFactory.generateSetTemperatureCommand (rf_address, room_id, mode || 'MANUAL', degrees, untilDate); return send.call(this, command, 'S', timeout).then(function (res) { self.commStatus.duty_cycle = res.duty_cycle; self.commStatus.free_memory_slots = res.free_memory_slots; From ffed3b99a209af529ebe103843af3f26bd151b2f Mon Sep 17 00:00:00 2001 From: spddl Date: Mon, 2 Nov 2020 15:43:50 +0100 Subject: [PATCH 2/2] add commStatus event --- README.md | 1 + maxcube.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 90feabc..8d2f1c5 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ myMaxCube.on('closed', function () { * closed * error * hello (arg = hello object) +* commStatus (arg = { duty_cycle, free_memory_slots }) * meta_data (arg = meta data object) * device_list (arg = list of devices) * configuration (arg = configuration object for a single device) diff --git a/maxcube.js b/maxcube.js index 794cb94..7065635 100644 --- a/maxcube.js +++ b/maxcube.js @@ -74,6 +74,7 @@ function MaxCube(ip, port) { self.metaInfo.serial_number = parsedCommand.serial_number; self.metaInfo.firmware_version = parsedCommand.firmware_version; self.emit('hello', parsedCommand); + self.emit('commStatus', { duty_cycle: parsedCommand.duty_cycle, free_memory_slots: parsedCommand.free_memory_slots }); break; } case 'M': { @@ -93,6 +94,10 @@ function MaxCube(ip, port) { self.emit('configuration', parsedCommand); break; } + case 'S': { + self.emit('commStatus', { duty_cycle: parsedCommand.duty_cycle, free_memory_slots: parsedCommand.free_memory_slots }); + break + } } } catch (e) { self.emit('error', "Problem while parsing the command '" +command.type+"': " + e.stack); @@ -270,9 +275,9 @@ MaxCube.prototype.setTemperature = function(rf_address, degrees, mode, untilDate checkInitialised.call(this); var self = this; - var room_id = this.deviceCache[rf_address].room_id; - if (rf_address === '000000') { - room_id = '00'; // '00' sets all temperature for all devices + var room_id = '00' // '00' sets all temperature for all devices + if (this.deviceCache[rf_address]) { + room_id = this.deviceCache[rf_address].room_id } degrees = Math.max(2, degrees); var command = MaxCubeCommandFactory.generateSetTemperatureCommand (rf_address, room_id, mode || 'MANUAL', degrees, untilDate);