Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
Added fan speed and fan state updates as prepared in a pull request by @systemx-xx sj26#2
  • Loading branch information
DevOutOnGit authored Sep 10, 2023
1 parent 442893f commit 8365c07
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,92 @@ class Intesisbox extends EventEmitter {
// Characteristic.CoolingThresholdTemperature
// Characteristic.HeatingThresholdTemperature

this.fanService = new Service.Fan();

this.fanService.getCharacteristic(Characteristic.TargetFanState)
.on("get", function(callback) {

if (this.state.fansp) {
switch (this.state.fansp) {
case 'AUTO': // auto
callback(null, '1');
break;
default:
callback(null, '0');
}
} else {
callback(communicationError);
}

}.bind(this))
.on("set", function(state, callback, context) {

var FANSP;

if (state == '1') {
this.fanService.updateCharacteristic(Characteristic.RotationSpeed, 100);
FANSP = 'AUTO';
} else {
this.fanService.updateCharacteristic(Characteristic.RotationSpeed, 100);
FANSP = '4';
}

this.sendSET("FANSP", FANSP, function() { callback(); });

}.bind(this));

this.fanService.getCharacteristic(Characteristic.RotationSpeed)
.setProps({
minStep: 25
})
.on("get", function(callback) {

if (this.state.fansp) {
switch (this.state.fansp) {
case '1': // low
callback(null, 25);
break;
case '2': // normal
callback(null, 50);
break;
case '3': // high
callback(null, 75);
break;
case '4': // max
callback(null, 100);
break;
default:
callback(null, 0);
}
} else {
callback(communicationError);
}

}.bind(this))
.on("set", function(speed, callback, context) {

var FANSP;

if (speed <= 25) {
FANSP = '1';
} else if (speed <= 50) {
FANSP = '2';
} else if (speed <= 75) {
FANSP = '3';
} else if (speed <= 100) {
FANSP = '4';
}

this.fanService.updateCharacteristic(Characteristic.TargetFanState, 0);

this.sendSET("FANSP", FANSP, function() { callback(); });

}.bind(this));

this.services = [
this.informationService,
this.thermostatService,
this.fanService,
];

// Device communications and handlers
Expand Down

0 comments on commit 8365c07

Please sign in to comment.