Skip to content

Commit 19a9847

Browse files
apages2Aurelien PAGESKoenkk
authored
fix: Add status shutter for Legrand 067776 (#7992)
* add status shutter * Update legrand.ts * lint --------- Co-authored-by: Aurelien PAGES <[email protected]> Co-authored-by: Koen Kanters <[email protected]>
1 parent 427c644 commit 19a9847

File tree

2 files changed

+64
-28
lines changed

2 files changed

+64
-28
lines changed

src/devices/legrand.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fz from '../converters/fromZigbee';
22
import tz from '../converters/toZigbee';
33
import * as exposes from '../lib/exposes';
44
import * as legacy from '../lib/legacy';
5-
import {_067776, eLegrand, fzLegrand, legrandOptions, readInitialBatteryState, tzLegrand} from '../lib/legrand';
5+
import {eLegrand, fzLegrand, legrandOptions, readInitialBatteryState, tzLegrand} from '../lib/legrand';
66
import {deviceEndpoints, electricityMeter, light, onOff} from '../lib/modernExtend';
77
import * as ota from '../lib/ota';
88
import * as reporting from '../lib/reporting';
@@ -145,20 +145,20 @@ const definitions: DefinitionWithExtend[] = [
145145
fromZigbee: [
146146
fz.ignore_basic_report,
147147
fz.cover_position_tilt,
148-
fz.legrand_binary_input_moving,
149148
fz.identify,
150149
fzLegrand.cluster_fc01,
151150
fzLegrand.calibration_mode(false),
151+
fzLegrand.command_cover,
152152
],
153153
toZigbee: [tz.cover_state, tz.cover_position_tilt, tzLegrand.identify, tzLegrand.led_mode, tzLegrand.calibration_mode(false)],
154154
exposes: (device, options) => {
155155
return [
156-
_067776.getCover(device),
157-
e.action(['moving', 'identify']),
156+
eLegrand.getCover(device),
157+
e.action(['identify', 'open', 'close', 'stop', 'moving', 'stopped']),
158158
eLegrand.identify(),
159159
eLegrand.ledInDark(),
160160
eLegrand.ledIfOn(),
161-
_067776.getCalibrationModes(false),
161+
eLegrand.getCalibrationModes(false),
162162
e.linkquality(),
163163
];
164164
},
@@ -217,20 +217,20 @@ const definitions: DefinitionWithExtend[] = [
217217
fromZigbee: [
218218
fz.ignore_basic_report,
219219
fz.cover_position_tilt,
220-
fz.legrand_binary_input_moving,
221220
fz.identify,
222221
fzLegrand.cluster_fc01,
223222
fzLegrand.calibration_mode(true),
223+
fzLegrand.command_cover,
224224
],
225225
toZigbee: [tz.cover_state, tz.cover_position_tilt, tzLegrand.identify, tzLegrand.led_mode, tzLegrand.calibration_mode(true)],
226226
exposes: (device, options) => {
227227
return [
228-
_067776.getCover(device),
229-
e.action(['moving', 'identify']),
228+
eLegrand.getCover(device),
229+
e.action(['identify', 'open', 'close', 'stop', 'moving', 'stopped']),
230230
eLegrand.identify(),
231231
eLegrand.ledInDark(),
232232
eLegrand.ledIfOn(),
233-
_067776.getCalibrationModes(true),
233+
eLegrand.getCalibrationModes(true),
234234
e.linkquality(),
235235
];
236236
},

src/lib/legrand.ts

+55-19
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,22 @@ const getApplicableCalibrationModes = (isNLLVSwitch: boolean): KeyValueString =>
6060

6161
export const legrandOptions = {manufacturerCode: Zcl.ManufacturerCode.LEGRAND_GROUP, disableDefaultResponse: true};
6262

63-
export const _067776 = {
63+
export const eLegrand = {
64+
identify: () => {
65+
return e
66+
.enum('identify', ea.SET, ['identify'])
67+
.withDescription('Blinks the built-in LED to make it easier to identify the device')
68+
.withCategory('config');
69+
},
70+
ledInDark: () => {
71+
return e
72+
.binary('led_in_dark', ea.ALL, 'ON', 'OFF')
73+
.withDescription('Enables the built-in LED allowing to see the switch in the dark')
74+
.withCategory('config');
75+
},
76+
ledIfOn: () => {
77+
return e.binary('led_if_on', ea.ALL, 'ON', 'OFF').withDescription('Enables the LED on activity').withCategory('config');
78+
},
6479
getCover: (device: Zh.Device) => {
6580
const c = e.cover_position();
6681

@@ -93,24 +108,6 @@ export const _067776 = {
93108
},
94109
};
95110

96-
export const eLegrand = {
97-
identify: () => {
98-
return e
99-
.enum('identify', ea.SET, ['identify'])
100-
.withDescription('Blinks the built-in LED to make it easier to identify the device')
101-
.withCategory('config');
102-
},
103-
ledInDark: () => {
104-
return e
105-
.binary('led_in_dark', ea.ALL, 'ON', 'OFF')
106-
.withDescription('Enables the built-in LED allowing to see the switch in the dark')
107-
.withCategory('config');
108-
},
109-
ledIfOn: () => {
110-
return e.binary('led_if_on', ea.ALL, 'ON', 'OFF').withDescription('Enables the LED on activity').withCategory('config');
111-
},
112-
};
113-
114111
export const readInitialBatteryState: OnEvent = async (type, data, device, options) => {
115112
if (['deviceAnnounce'].includes(type)) {
116113
const endpoint = device.getEndpoint(1);
@@ -220,4 +217,43 @@ export const fzLegrand = {
220217
return payload;
221218
},
222219
} satisfies Fz.Converter,
220+
command_cover: {
221+
cluster: 'closuresWindowCovering',
222+
type: ['attributeReport', 'readResponse'],
223+
convert: (model, msg, publish, options, meta) => {
224+
const payload: KeyValueAny = {};
225+
if (msg.data.tuyaMovingState !== undefined) {
226+
if ((0, utils.hasAlreadyProcessedMessage)(msg, model)) return;
227+
if (msg.data['tuyaMovingState'] === 0) {
228+
// return {
229+
// action: 'open',
230+
// };
231+
payload['action'] = (0, utils.postfixWithEndpointName)('OPEN', msg, model, meta);
232+
(0, utils.addActionGroup)(payload, msg, model);
233+
}
234+
if (msg.data['tuyaMovingState'] === 100) {
235+
// return {
236+
// action: 'closed',
237+
// };
238+
payload['action'] = (0, utils.postfixWithEndpointName)('CLOSE', msg, model, meta);
239+
(0, utils.addActionGroup)(payload, msg, model);
240+
}
241+
if (msg.data['tuyaMovingState'] >= 1 && msg.data['tuyaMovingState'] < 100) {
242+
// return {
243+
// action: 'stop',
244+
// };
245+
payload['action'] = (0, utils.postfixWithEndpointName)('STOP', msg, model, meta);
246+
(0, utils.addActionGroup)(payload, msg, model);
247+
}
248+
}
249+
return payload;
250+
},
251+
} satisfies Fz.Converter,
252+
identify: {
253+
cluster: 'genIdentify',
254+
type: ['attributeReport', 'readResponse'],
255+
convert: (model, msg, publish, options, meta) => {
256+
return {};
257+
},
258+
} satisfies Fz.Converter,
223259
};

0 commit comments

Comments
 (0)