Skip to content

Commit

Permalink
Rename darkMode internal to darkModeOnStateChange to make things more…
Browse files Browse the repository at this point in the history
… clear for the upcoming darkModeOnModeChange flag
  • Loading branch information
Zer0x00 committed May 17, 2022
1 parent 17f4355 commit ab02aeb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MiLightHubPlatform {
this.forceHTTP = config.forceHTTP || false;
this.debug = config.debug || false;
this.darkMode = config.darkMode || false;
this.darkModeOnStateChange = this.darkMode;
this.host = config.host || 'milight-hub.local';
this.syncHubInterval = config.syncHubInterval || 10;
this.commandDelay = config.commandDelay || 100;
Expand Down Expand Up @@ -566,7 +567,7 @@ if(this.adaptiveLightingController && this.adaptiveLightingController.isAdaptive
command.state = 'On';

// Dark Mode
if (this.platform.darkMode) { // set cached level for dark mode
if (this.platform.darkModeOnStateChange) { // set cached level for dark mode
if (typeof dstate.level === 'undefined' && typeof cstate.cachedLevel !== 'undefined' && (dstate.state === true || cstate.state !== false)) {
dstate.level = cstate.cachedLevel;
} else if (typeof dstate.level === 'number') {
Expand All @@ -593,7 +594,7 @@ if(this.adaptiveLightingController && this.adaptiveLightingController.isAdaptive
command.state = 'Off';

// Dark Mode
if (this.platform.darkMode) {
if (this.platform.darkModeOnStateChange) {
if (cstate.level !== 1) {
cstate.cachedLevel = cstate.level;
}
Expand Down

1 comment on commit ab02aeb

@Zer0x00
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

darkMode was not renamed directly to don't disrupt any running configurations on a npm update

Please sign in to comment.