Skip to content

Commit

Permalink
New: Introduce Adaptive Lightning 馃帀
Browse files Browse the repository at this point in the history
To use Adaptive Lightning feature, make sure you're using Homebridge >=1.3.0-beta.23
  • Loading branch information
Andrey Okonetchnikov committed Feb 7, 2021
1 parent 2952d14 commit 24b275e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bulbs/temperature.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ const Temperature = Device =>
)
.on('set', async (value, callback) => {
try {
await this.setTemperature(value);
/* In moonlight mode do not attempt to change the temperature
* on device since it will switch it back to daylight mode
*/
if (this.activeMode === 0) {
await this.setTemperature(value);
}
callback(null, value);
} catch (err) {
callback(err, this.temperature);
Expand All @@ -23,6 +28,17 @@ const Temperature = Device =>
maxValue: this.model.startsWith('bslamp') ? 588 : 370, // ~1700K or ~2700K
})
.updateValue(this.temperature);

// Setup the adaptive lighting controller if available
if (
platform.api.versionGreaterOrEqual &&
platform.api.versionGreaterOrEqual('1.3.0-beta.23')
) {
this.alController = new platform.api.hap.AdaptiveLightingController(
this.service
);
this.accessory.configureController(this.alController);
}
}

get temperature() {
Expand Down

1 comment on commit 24b275e

@vieira
Copy link
Owner

@vieira vieira commented on 24b275e Feb 7, 2021

Choose a reason for hiding this comment

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

鉂わ笍

Please sign in to comment.