Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse NightMode switch state in HomeKit #63

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DysonFanState.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DysonFanState {
(this.getFieldValue(newState, "auto") === "ON" && this._fan);

this._rotate = this.getFieldValue(newState, "oson") === "ON";
this._nightMode = this.getFieldValue(newState, "nmod") === "ON";
this._nightMode = this.getFieldValue(newState, "nmod") === "ON" ? false : true;
this._speed = (Number.parseInt(this.getFieldValue(newState, "fnsp"))||5) * 10;
if (this.heatAvailable) {
this._heat = this.getFieldValue(newState, "hmod") === "HEAT";
Expand Down
4 changes: 2 additions & 2 deletions DysonLinkAccessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class DysonLinkAccessory {

if(this.nightModeVisible) {
this.log.info("Night mode button is added");
this.nightModeSwitch = this.getServiceBySubtype(Service.Switch, "Night Mode - " + this.displayName, "Night Mode");
this.nightModeSwitch = this.getServiceBySubtype(Service.Switch, "LED - " + this.displayName, "LED");//changed name to LED (and reversing the Night Mode switch to function as a normal light. Either the Fan LED Light is ON or OFF.

this.nightModeSwitch
.getCharacteristic(Characteristic.On)
Expand Down Expand Up @@ -294,4 +294,4 @@ class DysonLinkAccessory {

module.exports = {
DysonLinkAccessory, setHomebridge
}
}
4 changes: 2 additions & 2 deletions DysonLinkDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ class DysonLinkDevice {
}

setNightMode(value, callback) {
this.setState({ nmod: value ? "ON" : "OFF" });
this.setState({ nmod: value ? "OFF" : "ON" });
this.isNightMode(callback);
}

isNightMode(callback) {
this.mqttEvent.once(this.STATE_EVENT, () => {
this.log.info(this.displayName + " - Night Mode: " + this.fanState.nightMode);
this.log.info(this.displayName + " - Night Mode: " + this.fanState.nightMode);//this.fanState.nightMode has been reversed to function in HomeKit as an LED light on/off.
callback(null, this.fanState.nightMode);
});
// Request for update
Expand Down