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

Legrand 067776(A): Added support for showing / hiding the tilt control #7412

Merged
merged 2 commits 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
38 changes: 22 additions & 16 deletions src/devices/legrand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ const definitions: Definition[] = [
fromZigbee: [fz.ignore_basic_report, fz.cover_position_tilt, fz.legrand_binary_input_moving, fz.identify,
fzLegrand.cluster_fc01, fzLegrand.calibration_mode(false)],
toZigbee: [tz.cover_state, tz.cover_position_tilt, tzLegrand.identify, tzLegrand.led_mode, tzLegrand.calibration_mode(false)],
exposes: [
_067776.getCover(),
e.action(['moving', 'identify']),
eLegrand.identify(),
eLegrand.ledInDark(),
eLegrand.ledIfOn(),
_067776.getCalibrationModes(false),
],
exposes: (device, options) => {
return [
_067776.getCover(options),
e.action(['moving', 'identify']),
eLegrand.identify(),
eLegrand.ledInDark(),
eLegrand.ledIfOn(),
_067776.getCalibrationModes(false),
e.linkquality(),
];
},
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genBinaryInput', 'closuresWindowCovering', 'genIdentify']);
Expand Down Expand Up @@ -182,14 +185,17 @@ const definitions: Definition[] = [
fromZigbee: [fz.ignore_basic_report, fz.cover_position_tilt, fz.legrand_binary_input_moving, fz.identify,
fzLegrand.cluster_fc01, fzLegrand.calibration_mode(true)],
toZigbee: [tz.cover_state, tz.cover_position_tilt, tzLegrand.identify, tzLegrand.led_mode, tzLegrand.calibration_mode(true)],
exposes: [
_067776.getCover(),
e.action(['moving', 'identify']),
eLegrand.identify(),
eLegrand.ledInDark(),
eLegrand.ledIfOn(),
_067776.getCalibrationModes(true),
],
exposes: (device, options) => {
return [
_067776.getCover(options),
e.action(['moving', 'identify']),
eLegrand.identify(),
eLegrand.ledInDark(),
eLegrand.ledIfOn(),
_067776.getCalibrationModes(true),
e.linkquality(),
];
},
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genBinaryInput', 'closuresWindowCovering', 'genIdentify']);
Expand Down
16 changes: 11 additions & 5 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, KeyValueString, KeyValueAny} from '../lib/types';
import {Fz, Tz, OnEvent, KeyValue, KeyValueString, KeyValueAny} from '../lib/types';
import * as exposes from './exposes';
import * as utils from '../lib/utils';
import {logger} from './logger';
Expand Down Expand Up @@ -42,10 +42,13 @@ const ledColors:{[k: number]: string} = {
const optsLegrand = {
identityEffect: () => {
return e.composite('Identity effect', 'identity_effect', ea.SET)
.withDescription('Defines the identification effect to simplify the device identification')
.withDescription('Defines the identification effect to simplify the device identification.')
.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 @@ -57,10 +60,12 @@ const getApplicableCalibrationModes = (isNLLVSwitch: boolean): KeyValueString =>
export const legrandOptions = {manufacturerCode: Zcl.ManufacturerCode.LEGRAND_GROUP, disableDefaultResponse: true};

export const _067776 = {
getCover: () => {
getCover: (options: KeyValue) => {
const c = e.cover_position();
if (c.hasOwnProperty('features')) {
c.features.push(new exposes.Numeric('tilt', ea.ALL)

const showTilt = (options?.tilt_control ?? 'Show') === 'Show' ? true : false;
if (showTilt) {
c.addFeature(new exposes.Numeric('tilt', ea.ALL)
.withValueMin(0).withValueMax(100)
.withValueStep(25)
.withPreset('Closed', 0, 'Vertical')
Expand Down Expand Up @@ -119,6 +124,7 @@ 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