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

feat: Legrand 067776(A): Improved PR#7412 #7413

Merged
merged 1 commit into from
Apr 20, 2024
Merged
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
4 changes: 2 additions & 2 deletions src/devices/legrand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const definitions: Definition[] = [
toZigbee: [tz.cover_state, tz.cover_position_tilt, tzLegrand.identify, tzLegrand.led_mode, tzLegrand.calibration_mode(false)],
exposes: (device, options) => {
return [
_067776.getCover(options),
_067776.getCover(device),
e.action(['moving', 'identify']),
eLegrand.identify(),
eLegrand.ledInDark(),
Expand Down Expand Up @@ -187,7 +187,7 @@ const definitions: Definition[] = [
toZigbee: [tz.cover_state, tz.cover_position_tilt, tzLegrand.identify, tzLegrand.led_mode, tzLegrand.calibration_mode(true)],
exposes: (device, options) => {
return [
_067776.getCover(options),
_067776.getCover(device),
e.action(['moving', 'identify']),
eLegrand.identify(),
eLegrand.ledInDark(),
Expand Down
24 changes: 11 additions & 13 deletions src/lib/legrand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Zcl} from 'zigbee-herdsman';
import {Fz, Tz, OnEvent, KeyValue, KeyValueString, KeyValueAny} from '../lib/types';
import {Fz, Tz, Zh, OnEvent, KeyValueString, KeyValueAny} from '../lib/types';
import * as exposes from './exposes';
import * as utils from '../lib/utils';
import {logger} from './logger';
Expand All @@ -8,12 +8,12 @@ const NS = 'zhc:legrand';
const e = exposes.presets;
const ea = exposes.access;

const shutterCalibrationModes: {[k: number]: {description: string, onlyNLLV: boolean}} = {
0: {description: 'classic_nllv', onlyNLLV: true},
1: {description: 'specific_nllv', onlyNLLV: true},
2: {description: 'up_down_stop', onlyNLLV: false},
3: {description: 'temporal', onlyNLLV: false},
4: {description: 'venetian_bso', onlyNLLV: false},
const shutterCalibrationModes: {[k: number]: {description: string, onlyNLLV: boolean, supportsTilt: boolean}} = {
0: {description: 'classic_nllv', onlyNLLV: true, supportsTilt: false},
1: {description: 'specific_nllv', onlyNLLV: true, supportsTilt: false},
2: {description: 'up_down_stop', onlyNLLV: false, supportsTilt: false},
3: {description: 'temporal', onlyNLLV: false, supportsTilt: false},
4: {description: 'venetian_bso', onlyNLLV: false, supportsTilt: true},
};

const ledModes:{[k: number]: string} = {
Expand Down Expand Up @@ -46,9 +46,6 @@ const optsLegrand = {
.withFeature(e.enum('effect', ea.SET, Object.values(ledEffects)).withLabel('Effect'))
.withFeature(e.enum('color', ea.SET, Object.values(ledColors)).withLabel('Color'));
},
tiltControl: () => {
return new exposes.Binary('tilt_control', ea.SET, 'Show', 'Hide').withDescription('Defines if this cover shall display a tilt control.');
},
};

const getApplicableCalibrationModes = (isNLLVSwitch: boolean): KeyValueString => {
Expand All @@ -60,10 +57,12 @@ const getApplicableCalibrationModes = (isNLLVSwitch: boolean): KeyValueString =>
export const legrandOptions = {manufacturerCode: Zcl.ManufacturerCode.LEGRAND_GROUP, disableDefaultResponse: true};

export const _067776 = {
getCover: (options: KeyValue) => {
getCover: (device: Zh.Device) => {
const c = e.cover_position();

const showTilt = (options?.tilt_control ?? 'Show') === 'Show' ? true : false;
const calMode = Number(device?.getEndpoint(1)?.clusters?.closuresWindowCovering?.attributes?.calibrationMode);
const showTilt = calMode ? (shutterCalibrationModes[calMode]?.supportsTilt === true): false;

if (showTilt) {
c.addFeature(new exposes.Numeric('tilt', ea.ALL)
.withValueMin(0).withValueMax(100)
Expand Down Expand Up @@ -124,7 +123,6 @@ export const tzLegrand = {
calibration_mode: (isNLLVSwitch: boolean) => {
return {
key: ['calibration_mode'],
options: [optsLegrand.tiltControl()],
convertSet: async (entity, key, value, meta) => {
const applicableModes = getApplicableCalibrationModes(isNLLVSwitch);
utils.validateValue(value, Object.values(applicableModes));
Expand Down
Loading