Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion maxcube.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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);
Expand Down Expand Up @@ -270,8 +275,12 @@ MaxCube.prototype.setTemperature = function(rf_address, degrees, mode, untilDate
checkInitialised.call(this);

var self = this;
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, 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;
Expand Down