Skip to content

Commit

Permalink
Merge branch 'master' into fix-jet-focus
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-ng committed Apr 12, 2019
2 parents efbb1e8 + d25dbcb commit b4b82b4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
43 changes: 30 additions & 13 deletions DysonLinkAccessory.js
Expand Up @@ -41,11 +41,16 @@ class DysonLinkAccessory {

initSensor() {
this.log("Init Sensor for " + this.displayName);
this.temperatureSensor = this.getService(Service.TemperatureSensor);
this.temperatureSensor
.getCharacteristic(Characteristic.CurrentTemperature)
.setProps({ minValue: -50, maxValue: 100, unit: "celsius" })
.on("get", this.device.getTemperture.bind(this.device));

if (this.device.model !== '527') {
// Don't add temperature sensor on HP04 since heater already acts as temperature sensor
// TODO: maybe we could do this to all devices that have heatAvailable?
this.temperatureSensor = this.getService(Service.TemperatureSensor);
this.temperatureSensor
.getCharacteristic(Characteristic.CurrentTemperature)
.setProps({minValue: -50, maxValue: 100, unit: "celsius"})
.on("get", this.device.getTemperture.bind(this.device));
}

this.humiditySensor = this.getService(Service.HumiditySensor);
this.humiditySensor
Expand All @@ -59,7 +64,7 @@ class DysonLinkAccessory {
.on("get", this.device.getAirQuality.bind(this.device));


if (this.device.model == "438" || this.device.model == "520") {
if (this.device.model == "438" || this.device.model == "520" || this.device.model == "527") {
this.airSensor.getCharacteristic(Characteristic.PM2_5Density)
.on("get", this.device.getPM2_5Density.bind(this.device));
this.airSensor.getCharacteristic(Characteristic.PM10Density)
Expand All @@ -73,7 +78,9 @@ class DysonLinkAccessory {
// Updates the accessory information
var accessoryInformationService = this.getService(Service.AccessoryInformation);
accessoryInformationService.setCharacteristic(Characteristic.Manufacturer, "Dyson");
if (this.device.model == "438" || this.device.model == "520") {
if (this.device.model == "527") {
accessoryInformationService.setCharacteristic(Characteristic.Model, "Dyson Pure Hot + Cool " + this.device.model);
} else if (this.device.model == "438" || this.device.model == "520") {
accessoryInformationService.setCharacteristic(Characteristic.Model, "Dyson Pure Cool " + this.device.model);
} else {
accessoryInformationService.setCharacteristic(Characteristic.Model, "Dyson " + this.device.model);
Expand Down Expand Up @@ -167,11 +174,20 @@ class DysonLinkAccessory {
this.heater.getCharacteristic(Characteristic.CurrentHeaterCoolerState)
.on("set", this.device.setCurrentHeaterCoolerState.bind(this.device))
.on("get", this.device.getCurrentHeaterCoolerState.bind(this.device));


this.heater.getCharacteristic(Characteristic.TargetHeaterCoolerState)
.on("get", this.device.getHeaterCoolerState.bind(this.device))
.on("set", this.device.setHeaterCoolerState.bind(this.device));
if (this.device.model === '527') {
this.heater.getCharacteristic(Characteristic.TargetHeaterCoolerState)
.on("get", this.device.getHeaterCoolerState.bind(this.device))
.on("set", this.device.setHeaterCoolerState.bind(this.device))
.setProps({
// Disable COOL and AUTO, leave only HEAT
validValues: [1],
});
} else {
this.heater.getCharacteristic(Characteristic.TargetHeaterCoolerState)
.on("get", this.device.getHeaterCoolerState.bind(this.device))
.on("set", this.device.setHeaterCoolerState.bind(this.device));
}

this.heater.getCharacteristic(Characteristic.CurrentTemperature)
.on("get", this.device.getTemperture.bind(this.device));
Expand Down Expand Up @@ -233,7 +249,8 @@ class DysonLinkAccessory {
}

// Add jet focus for Cool/Heat and 2018 Cool device
if(this.device.heatAvailable || this.device.Is2018Dyson) {
if((this.device.heatAvailable && this.device.model !== '527') || this.device.Is2018Dyson) {

if(this.focusModeVisible) {
this.log.info("Jet Focus mode button is added");
this.focusSwitch = this.getServiceBySubtype(Service.Switch, "Jet Focus - " + this.displayName, "Jet Focus");
Expand Down Expand Up @@ -294,4 +311,4 @@ class DysonLinkAccessory {

module.exports = {
DysonLinkAccessory, setHomebridge
}
}
28 changes: 22 additions & 6 deletions DysonLinkDevice.js
Expand Up @@ -152,9 +152,18 @@ class DysonLinkDevice {
}

setHeaterOn(value, callback) {
this.setState({ fmod: value==1 ? "FAN" : "OFF" });
if(value && this.fanState.heaterCoolerState == 2) {
if (this.model === '527') {
if (value == 1) {
this.setState({ hmod: "HEAT" });
} else {
this.setState({ fmod: "FAN" });
this.setState({ hmod: "OFF" });
}
} else {
this.setState({ fmod: value == 1 ? "FAN" : "OFF" });
if(value && this.fanState.heaterCoolerState == 2) {

}
}
this.isFanOn(callback);
}
Expand All @@ -178,7 +187,13 @@ class DysonLinkDevice {
}

setThresholdTemperture(value, callback) {
this.setState({hmax: (value + 273)*10 });
var kelvin = (value + 273) * 10;
if (this.model === '527') {
this.setState({hmax: kelvin.toString()});
} else {
this.setState({hmax: kelvin});
}

this.getThresholdTemperture(callback);

}
Expand Down Expand Up @@ -470,10 +485,11 @@ class DysonLinkDevice {
}

get valid() { return this._valid; }
get heatAvailable() { return this.model === "455"; }
// 455 is Dyson Pure Hot + Cool Link, 527 is Dyson Pure Hot + Cool 2018
get heatAvailable() { return this.model === "455" || this.model === "527"; }

// TP04 is 438, DP04 is 520
get Is2018Dyson() { return this.model === "438" || this.model === "520" ;}
// TP04 is 438, DP04 is 520, HP04 is 527
get Is2018Dyson() { return this.model === "438" || this.model === "520" || this.model === "527"; }

get accessory() { return this._accessory ;}
set accessory(acce) { this._accessory = acce; }
Expand Down

0 comments on commit b4b82b4

Please sign in to comment.