Skip to content

Commit

Permalink
added filter check
Browse files Browse the repository at this point in the history
  • Loading branch information
karlg100 committed Jun 26, 2021
1 parent 99003ec commit 27d53ac
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cmdMap["getUnit"] = 'getUnit';
cmdMap["getCleanAir"] = 'getCleanAir';
cmdMap["getFanMode"] = 'getFanMode';
cmdMap["getTemp"] = 'getTemp';
cmdMap["getFilter"] = 'getFilter';
cmdMap["getRoomTemp"] = 'getRoomTemp';

cmdMap["off"] = 'mode';
Expand Down Expand Up @@ -104,6 +105,7 @@ switch (command) {
case 'getCoolingState':
case 'getUnit':
case 'getCleanAir':
case 'getFilter':
case 'getFanMode':
case 'getTemp':
case 'getRoomTemp':
Expand Down
33 changes: 32 additions & 1 deletion lib/frigidaire.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Frigidaire Appliance Node.js Module
*
* Author Karl Grindley <@karlg100>
Expand Down Expand Up @@ -973,6 +973,37 @@
debug("changing clean air for " + applianceObj.sn + " to " + mode);
this.sendAction(applianceObj, this.CLEANAIR, mode, callback);
};

Frigidaire.prototype.getFilter = function (applianceSn, callback, attempt = 0) {
debug("getFilter()");
var self = this;

++attempt;
if (attempt > MAX_RETRIES) {
callback("getCleanAir() - max retries exceeded", null);
return;
}

if (!this.telemPopulated()) {
debug("getCleanAir() - no telementry, exiting");
return callback("getCleanAir() - no telementry, exiting", null);
}

var applianceObj = this.getDevice(applianceSn);

if (!this.hasAttribute(applianceSn, this.FILTER)) {
debug("getFilter() - No filter attirbute, exiting gracefully...");
return callback(null, this.FILTER_GOOD);
}

debug("getting filter status for " + applianceObj.sn);
this.getValue(applianceObj.sn, this.FILTER, function (err, result) {
if (err) {
return callback(err);
}
return callback(null, result);
});
};

Frigidaire.prototype.fanMode = function (applianceSn, mode, callback, attempt = 0) {
debug("fanMode()");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frigidaire",
"version": "2.1.1",
"version": "2.1.2",
"description": "Frigidaire Appliance Node.js Module",
"main": "lib/frigidaire.js",
"scripts": {
Expand Down

0 comments on commit 27d53ac

Please sign in to comment.