Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
haywirecoder authored Jul 16, 2023
1 parent cd1519c commit 659f854
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
3 changes: 0 additions & 3 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@
"type": "string",
"description": "Device IDs"
}
},
"cid": {
"encoded": "101,57,99,52,97,99,55,51,45,101,57,52,101,45,52,98,51,55,45,98,49,102,101,45,98,57,53,54,102,53,54,56,100,97,97,48"
}
}
},
Expand Down
45 changes: 28 additions & 17 deletions frigidairmain.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const COUNTRY = 'US'

const CHILDMODE_OFF = 0
const CHILDMODE_ON = 1
const TARGETHUM = 40;

const DEHUMIDIFIERMODES = new Set([DEHMODE_DRY,DEHMODE_AUTO,DEHMODE_CONTINUOUS,DEHMODE_QUIET]);
const DEHUMIDIFIERFANMODES = new Set([FANMODE_MED,FANMODE_LOW,FANMODE_HIGH]);
Expand Down Expand Up @@ -231,6 +232,7 @@ class Frigidaire extends EventEmitter {
device.cpv = deviceJSON[i]['cpv'];
device.destination = "";
device.monitoredValues = "";
device.targetHumidity = TARGETHUM;
device.lastUpdate = Date.now();
this.frig_devices.push(device);
await this.getDetailForDevice(i);
Expand Down Expand Up @@ -381,7 +383,8 @@ class Frigidaire extends EventEmitter {
this.frig_devices[deviceIndex].mode = onValue;
return onValue;
}

else
this.log.error('Setting Power Mode unsuccessful returned code: ', returnCode);
return -1;
}

Expand All @@ -400,7 +403,8 @@ class Frigidaire extends EventEmitter {
this.frig_devices[deviceIndex].mode = DehumMode;
return DehumMode;
}

else
this.log.error('Setting Dehumdifier mode unsuccessful returned code: ', returnCode);
return -1;
}

Expand All @@ -421,6 +425,8 @@ class Frigidaire extends EventEmitter {
this.frig_devices[deviceIndex].fanMode = fanModeValue;
return fanModeValue;
}
else
this.log.error('Setting Fan Mode unsuccessful returned code: ', returnCode);
return -1;
}

Expand All @@ -429,22 +435,25 @@ class Frigidaire extends EventEmitter {
if(this.frig_devices.length <= deviceIndex) return false;
// Is a dehumidifier appliance?
if(this.frig_devices[deviceIndex].destination != DEHUMIDIFIER) return false;
// check if appliance is in auto model? If auto fam mode is automatically and can't be adjusted.
if (this.frig_devices[deviceIndex].mode == DEHMODE_AUTO) return false;

var returnCode = 0;
// determine if the humidity level is within acceptable range.
if (humidityLevel >= 35 && humidityLevel <= 85) {
// round to nearest multiple of 5.
humidityLevel = Math.ceil(humidityLevel/5)*5;
// If mode is not in auto mode that change set humidity level.
// check if appliance is in auto model? If auto fam mode is automatically and can't be adjusted.
if (this.frig_devices[deviceIndex].mode == DEHMODE_AUTO) return false;
returnCode = await this.sendDeviceCommand(deviceIndex,TARGET_HUMIDITY, humidityLevel);
if (returnCode == 200)
{
this.frig_devices[deviceIndex].targetHumidity = humidityLevel;
return humidityLevel;
}
if (humidityLevel < 35) humidityLevel = 35;
if (humidityLevel > 85) humidityLevel = 85;

// round to nearest multiple of 5.
humidityLevel = Math.ceil(humidityLevel/5)*5;

returnCode = await this.sendDeviceCommand(deviceIndex,TARGET_HUMIDITY, humidityLevel);
if (returnCode == 200)
{
this.frig_devices[deviceIndex].targetHumidity = humidityLevel;
return humidityLevel;
}
this.log.error('Dehumidifier Humidity Level not within acceptable range. Value must be between 35 and 85.', err);
else
this.log.error('Setting Relative Humidity unsuccessful returned code: ', returnCode);
return -1;
}

Expand All @@ -463,7 +472,8 @@ class Frigidaire extends EventEmitter {
this.frig_devices[deviceIndex].clearAirMode = modeValue;
return modeValue;
}

else
this.log.error('Setting Air Purifier unsuccessful returned code: ', returnCode);
return -1;
}

Expand All @@ -481,7 +491,8 @@ class Frigidaire extends EventEmitter {
this.frig_devices[deviceIndex].childMode = modeValue;
return modeValue;
}

else
this.log.error('Setting child unsuccessful returned code: ', returnCode);
return -1;
}

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "homebridge-frigidaire-dehumidifier",
"displayName": "Homebridge Frigidaire Dehumidifier ",
"version": "1.0.7",
"version": "1.0.10",
"description": "Frigidaire Dehumidifier Appliance",
"author": "Haywirecoder",
"license": "MIT",
Expand All @@ -19,7 +19,8 @@
"dependencies": {
"node-persist": "^3.1.0",
"superagent": "^8.0.6",
"uuid4": "^2.0.3"
"uuid4": "^2.0.3",
"crypto-js": "^4.1.1"
},
"keywords": [
"homebridge-plugin",
Expand Down

0 comments on commit 659f854

Please sign in to comment.