Skip to content

Commit

Permalink
Add support for reading the appliance info
Browse files Browse the repository at this point in the history
  • Loading branch information
rudybrian committed Oct 12, 2014
1 parent faf1c44 commit 7ee1a1b
Showing 1 changed file with 211 additions and 63 deletions.
274 changes: 211 additions & 63 deletions greenBean.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ laundryVals = {
delayTimeRemainingInMinutes: "Unknown"
};

applianceVals = {
address: "Unknown",
version: "Unknown",
type: "Unknown",
modelNumber: "Unknown",
serialNumber: "Unknown"
}

// Get the initial value
function delayTimeRemainingInMinutes_setval(value) {
Expand Down Expand Up @@ -449,73 +456,214 @@ function machineStatus_setval(value) {
poster(laundryVals.machineStatus);
}

greenBean.connect("laundry", function (laundry) {
laundry.delayTimeRemainingInMinutes.subscribe(function (value) {
delayTimeRemainingInMinutes_setval(value);
});

laundry.dryerCriticalResponseEnabled.subscribe(function (value) {
dryerCriticalResponseEnabled_setval(value);
});

laundry.operatingMode.subscribe(function (value) {
operatingMode_setval(value);
});

laundry.washerMainControlServiceErrorCodes.subscribe(function (value) {
washerMainControlServiceErrorCodes_setval(value);
});

laundry.washerInverterServiceErrorCodes.subscribe(function (value) {
washerInverterServiceErrorCodes_setval(value);
});

laundry.washerUserInterfaceServiceErrorCodes.subscribe(function (value) {
washerUserInterfaceServiceErrorCodes_setval(value);
});

laundry.cycleSelected.subscribe(function (value) {
cycleSelected_setval(value);
});

laundry.tankSelected.subscribe(function (value) {
tankSelected_setval(value);
});

laundry.tankStatus.subscribe(function (value) {
tankStatus_setval(value);
});

laundry.timeRemainingInSeconds.subscribe(function (value) {
timeRemainingInSeconds_setval(value);
});

laundry.maximumWaterTemperature.subscribe(function (value) {
maximumWaterTemperature_setval(value);
});

laundry.dsmOverridesAllowed.subscribe(function (value) {
dsmOverridesAllowed_setval(value);
});

laundry.dryerServiceErrorCodes.subscribe(function (value) {
dryerServiceErrorCodes_setval(value);
});

laundry.cycleCount.subscribe(function (value) {
cycleCount_setval(value);
});
function applianceType_setval(value) {
console.log("appliance type is:", value);
var stat = "Water heater";
switch (value) {
case 0:
stat = "Water heater";
break;
case 1:
stat = "Clothes dryer";
break;
case 2:
stat = "Clothes washer";
break;
case 3:
stat = "Refrigerator";
break;
case 4:
stat = "Microwave";
break;
case 5:
stat = "Advantium";
break;
case 6:
stat = "Dishwasher";
break;
case 7:
stat = "Oven";
break;
case 8:
stat = "Electric range";
break;
case 9:
stat = "Gas range";
break;
}
applianceVals.type = stat;
}

laundry.endOfCycle.subscribe(function (value) {
endOfCycle_setval(value);
greenBean.connect("laundry", function (laundry) {
var pacingInterval = 250; //500ms
var timeout = 0;
// Get the appliance info
applianceVals.address = laundry.address;
console.log("address is: ", applianceVals.address);
applianceVals.version = laundry.version.join(".");
console.log("version is: ", applianceVals.version);

console.log("Reading data and setting up subscriptions...");
laundry.applianceType.read(function (value) {

This comment has been minimized.

Copy link
@rudybrian

rudybrian Oct 14, 2014

Author Owner

Unfortunately this never returns due to an apparent bug in the applianceType.read() function as referenced in GEMakers/gea-sdk#4

applianceType_setval(value);
});

laundry.machineSubCycle.subscribe(function (value) {
machineSubCycle_setval(value);
});
timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.modelNumber.read()");
laundry.modelNumber.read(function (modelNumber) {
applianceVals.modelNumber = modelNumber.trim();
console.log("model number is: ", applianceVals.modelNumber);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.serialNumber.read()");
laundry.serialNumber.read(function (serialNumber) {
applianceVals.serialNumber = serialNumber.trim();
console.log("serial number is: ", applianceVals.serialNumber);
});
}, timeout);

// Setup subscriptions for all updates
timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.delayTimeRemainingInMinutes.subscribe()");
laundry.delayTimeRemainingInMinutes.subscribe(function (value) {
delayTimeRemainingInMinutes_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.dryerCriticalResponseEnabled.subscribe()");
laundry.dryerCriticalResponseEnabled.subscribe(function (value) {
dryerCriticalResponseEnabled_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.operatingMode.subscribe()");
laundry.operatingMode.subscribe(function (value) {
operatingMode_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.washerMainControlServiceErrorCodes.subscribe()");
laundry.washerMainControlServiceErrorCodes.subscribe(function (value) {
washerMainControlServiceErrorCodes_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.washerInverterServiceErrorCodes.subscribe()");
laundry.washerInverterServiceErrorCodes.subscribe(function (value) {
washerInverterServiceErrorCodes_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.washerUserInterfaceServiceErrorCodes.subscribe()");
laundry.washerUserInterfaceServiceErrorCodes.subscribe(function (value) {
washerUserInterfaceServiceErrorCodes_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.cycleSelected.subscribe()");
laundry.cycleSelected.subscribe(function (value) {
cycleSelected_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.tankSelected.subscribe()");
laundry.tankSelected.subscribe(function (value) {
tankSelected_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.tankStatus.subscribe()");
laundry.tankStatus.subscribe(function (value) {
tankStatus_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.timeRemainingInSeconds.subscribe()");
laundry.timeRemainingInSeconds.subscribe(function (value) {
timeRemainingInSeconds_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.maximumWaterTemperature.subscribe()");
laundry.maximumWaterTemperature.subscribe(function (value) {
maximumWaterTemperature_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.dsmOverridesAllowed.subscribe()");
laundry.dsmOverridesAllowed.subscribe(function (value) {
dsmOverridesAllowed_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.dryerServiceErrorCodes.subscribe()");
laundry.dryerServiceErrorCodes.subscribe(function (value) {
dryerServiceErrorCodes_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.cycleCount.subscribe()");
laundry.cycleCount.subscribe(function (value) {
cycleCount_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.endOfCycle.subscribe()");
laundry.endOfCycle.subscribe(function (value) {
endOfCycle_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.machineSubCycle.subscribe()");
laundry.machineSubCycle.subscribe(function (value) {
machineSubCycle_setval(value);
});
}, timeout);

timeout += pacingInterval;
setTimeout(function() {
console.log("laundry.machineStatus.subscribe()");
laundry.machineStatus.subscribe(function (value) {
machineStatus_setval(value);
});
console.log("Setup complete!");
}, timeout);

laundry.machineStatus.subscribe(function (value) {
machineStatus_setval(value);
});
});

0 comments on commit 7ee1a1b

Please sign in to comment.