Skip to content

Commit

Permalink
Refs Koenkk/zigbee2mqtt#12952: extend.light_onoff_brightness - allo…
Browse files Browse the repository at this point in the history
…w to exclude `power_on_behavior` converters since they can conflict with manufacturer-specific ones
  • Loading branch information
gorbunovav committed Jun 28, 2022
1 parent 74ae2fe commit e7b0c90
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions lib/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,38 @@ const extend = {
return {exposes, fromZigbee, toZigbee};
},
light_onoff_brightness: (options={}) => {
options = {disableEffect: false, ...options};
const exposes = [e.light_brightness(), ...(!options.disableEffect ? [e.effect()] : [])];
const fromZigbee = [fz.on_off, fz.brightness, fz.level_config, fz.power_on_behavior, fz.ignore_basic_report];
const toZigbee = [tz.light_onoff_brightness, tz.ignore_transition, tz.ignore_rate, tz.light_brightness_move,
tz.light_brightness_step, tz.level_config, tz.power_on_behavior, ...(!options.disableEffect ? [tz.effect] : [])];
options = {
disableEffect: false,
disablePowerOnBehavior: false,
...options
};

const exposes = [
e.light_brightness(),
...(!options.disableEffect ? [e.effect()] : [])
];

const fromZigbee = [
fz.on_off,
fz.brightness,
fz.level_config,
...(!options.disablePowerOnBehavior ? [fz.power_on_behavior] : []),
fz.ignore_basic_report
];

const toZigbee = [
tz.light_onoff_brightness,
tz.ignore_transition,
tz.ignore_rate,
tz.light_brightness_move,
tz.light_brightness_step,
tz.level_config,
...(!options.disablePowerOnBehavior ? [tz.power_on_behavior] : []),
...(!options.disableEffect ? [tz.effect] : [])
];

const result = {exposes, fromZigbee, toZigbee};

if (!options.noConfigure) {
result.configure = async (device, coordinatorEndpoint, logger) => {
await light.configure(device, coordinatorEndpoint, logger, true);
Expand Down

0 comments on commit e7b0c90

Please sign in to comment.