Skip to content

Commit

Permalink
fix: Improve position reporting for Bosch BMCT-SLZ (#7438)
Browse files Browse the repository at this point in the history
* fix: Add custom `cover_position_tilt` for Bosch BMCT-SLZ

Custom converter that does not return the set value because BMCT-SLZ has reporting configured.

* fix: Silly typo

lol 😅

* fix: `0` be gone!

Where did that come from?

* Add `coverPositionTiltDisableReport`

* Restore previous behavior for BCMT-SLZ

* Add `coverPositionTiltDisableReport` definition

* Add `coverPositionTiltDisableReport` test

* Add missing trailing comma
Happy?
  • Loading branch information
burmistrzak committed Apr 28, 2024
1 parent df05493 commit badb0e5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/converters/toZigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,11 @@ const converters2 = {
isPosition ? {percentageliftvalue: position} : {percentagetiltvalue: position},
utils.getOptions(meta.mapped, entity),
);

return {state: {[isPosition ? 'position' : 'tilt']: value}};
if (utils.getMetaValue(entity, meta.mapped, 'coverPositionTiltDisableReport', 'allEqual', true)) {
return;
} else {
return {state: {[isPosition ? 'position' : 'tilt']: value}};
}
},
convertGet: async (entity, key, meta) => {
const isPosition = (key === 'position');
Expand Down
18 changes: 15 additions & 3 deletions src/devices/bosch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1505,9 +1505,21 @@ const definitions: Definition[] = [
model: 'BMCT-SLZ',
vendor: 'Bosch',
description: 'Light/shutter control unit II',
fromZigbee: [fzLocal.bmct, fz.cover_position_tilt, fz.on_off, fz.power_on_behavior],
toZigbee: [tzLocal.bmct, tz.cover_position_tilt, tz.power_on_behavior],
meta: {multiEndpoint: true},
fromZigbee: [
fz.on_off,
fz.power_on_behavior,
fz.cover_position_tilt,
fzLocal.bmct,
],
toZigbee: [
tz.power_on_behavior,
tz.cover_position_tilt,
tzLocal.bmct,
],
meta: {
multiEndpoint: true,
coverPositionTiltDisableReport: false,
},
endpoint: (device) => {
return {'left': 2, 'right': 3};
},
Expand Down
6 changes: 6 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ export interface DefinitionMeta {
* @defaultValue true
*/
supportsHueAndSaturation?: boolean,
/**
* Do not set `position` or `tilt` to target value on /set. See `toZigbee.cover_position_tilt`
*
* @defaultValue false
*/
coverPositionTiltDisableReport?: boolean,
}

export type Configure = (device: Zh.Device, coordinatorEndpoint: Zh.Endpoint, definition: Definition) => Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe('index.js', () => {


if (device.meta) {
containsOnly(['disableActionGroup', 'multiEndpoint', 'multiEndpointSkip', 'multiEndpointEnforce', 'applyRedFix', 'disableDefaultResponse', 'supportsEnhancedHue', 'timeout', 'supportsHueAndSaturation', 'battery', 'coverInverted', 'turnsOffAtBrightness1', 'coverStateFromTilt', 'pinCodeCount', 'tuyaThermostatSystemMode', 'tuyaThermostatPreset', 'tuyaDatapoints', 'tuyaThermostatPresetToSystemMode', 'thermostat', 'separateWhite', 'publishDuplicateTransaction', 'tuyaSendCommand'], Object.keys(device.meta));
containsOnly(['disableActionGroup', 'multiEndpoint', 'multiEndpointSkip', 'multiEndpointEnforce', 'applyRedFix', 'disableDefaultResponse', 'supportsEnhancedHue', 'timeout', 'supportsHueAndSaturation', 'battery', 'coverInverted', 'turnsOffAtBrightness1', 'coverStateFromTilt', 'pinCodeCount', 'tuyaThermostatSystemMode', 'tuyaThermostatPreset', 'tuyaDatapoints', 'tuyaThermostatPresetToSystemMode', 'thermostat', 'separateWhite', 'publishDuplicateTransaction', 'tuyaSendCommand', 'coverPositionTiltDisableReport'], Object.keys(device.meta));
}

if (device.zigbeeModel) {
Expand Down

0 comments on commit badb0e5

Please sign in to comment.