Skip to content

Commit

Permalink
cheap and cheerful: multiple devices
Browse files Browse the repository at this point in the history
  • Loading branch information
joelk committed Jan 15, 2021
1 parent ec0976f commit 8fc0b2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
7 changes: 7 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
"default": "",
"description": "Password for FGLair App"
},
"deviceIndex": {
"title": "Device Index",
"type": "string",
"required": false,
"default": "0",
"description": "The index of the device this plugin will control (in the order in which you added them to your FGLair account)"
},
"interval": {
"title": "Update Interval",
"type": "string",
Expand Down
20 changes: 2 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function Thermostat(log, config) {
this.token = config.token || "";
this.region = config.region || 'us'
this.temperatureDisplayUnits = config.temperatureDisplayUnits || 0;
this.deviceIndex = config.deviceIndex || 0;

this.currentHumidity = config.currentHumidity || false;
this.targetHumidity = config.targetHumidity || false;
Expand Down Expand Up @@ -66,7 +67,7 @@ function Thermostat(log, config) {
else
{

this.serial = data[0]; //Only one thermostat is supported
this.serial = data[this.deviceIndex]; //Only one thermostat is supported
this.updateAll(that);
setInterval( this.updateAll, this.interval, that );
}
Expand Down Expand Up @@ -120,23 +121,6 @@ Thermostat.prototype.updateAll = function(ctx)
break;
}

switch(mode)
{
case "off":
ctx.currentHeatingCoolingState = Characteristic.CurrentHeatingCoolingState.OFF;
break;
case "heat":
ctx.currentHeatingCoolingState = Characteristic.CurrentHeatingCoolingState.HEAT;
break;
case "cool":
case "fan":
ctx.currentHeatingCoolingState = Characteristic.CurrentHeatingCoolingState.COOL;
break;
default:
ctx.currentHeatingCoolingState = Characteristic.CurrentHeatingCoolingState.OFF;
break;
}

this.keyCurrentHeatingCoolingState = prop['property']['key'];

//ctx.log("[" + ctx.serial + "] Got HeatingCooling State: "+ ctx.targetHeatingCoolingState);
Expand Down

0 comments on commit 8fc0b2c

Please sign in to comment.