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

Add experimental SKIP_BRIGHTNESS_UPDATE option #931

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
1 change: 1 addition & 0 deletions src/experimental.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const EXP_COLOR_MODE = 'COLOR_MODE';
export const EXP_AVAILABILITY = 'AVAILABILITY';
export const EXP_SKIP_BRIGHTNESS_UPDATE = 'SKIP_BRIGHTNESS_UPDATE';
8 changes: 6 additions & 2 deletions src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { BaseDeviceConfiguration, isDeviceConfiguration } from './configModels';
import { QoS } from 'mqtt-packet';
import { sanitizeAndFilterExposesEntries } from './helpers';
import { EXP_AVAILABILITY } from './experimental';
import { EXP_AVAILABILITY, EXP_SKIP_BRIGHTNESS_UPDATE } from './experimental';

export class Zigbee2mqttAccessory implements BasicAccessory {
private readonly updateTimer: ExtendedTimer;
Expand Down Expand Up @@ -294,12 +294,16 @@ export class Zigbee2mqttAccessory implements BasicAccessory {
}

private queueAllKeysForGet(): void {
const keys = [...this.serviceHandlers.values()]
let keys = [...this.serviceHandlers.values()]
.map((h) => h.getableKeys)
.reduce((a, b) => {
return a.concat(b);
}, []);
if (keys.length > 0) {
// Do not ask Zigbee2MQTT for brightness, otherwise the cached brightness level gets lost when a given bulb's state is OFF.
if (this.platform.isExperimentalFeatureEnabled(EXP_SKIP_BRIGHTNESS_UPDATE) && keys.includes('brightness')) {
keys = keys.filter((key) => key !== 'brightness');
}
this.queueKeyForGetAction(keys);
}
}
Expand Down