77 binary,
88 windowCovering,
99 deviceAddCustomCluster,
10+ setupConfigureForBinding,
1011} = require("zigbee-herdsman-converters/lib/modernExtend");
12+ const {presets: e, access: ea} = require("zigbee-herdsman-converters/lib/exposes");
1113const {assertString} = require("zigbee-herdsman-converters/lib/utils");
1214const reporting = require("zigbee-herdsman-converters/lib/reporting");
1315const constants = require("zigbee-herdsman-converters/lib/constants");
@@ -27,6 +29,11 @@ const ota = require("zigbee-herdsman-converters/lib/ota");
2729 Generate with: `make tools/update_converters`
2830********************************************************************/
2931
32+ const genEncoderPayload = (endpoint, action, stepSize) => ({
33+ [`${endpoint}_action`]: action,
34+ [`${endpoint}_step_size`]: stepSize,
35+ })
36+
3037const romasku = {
3138 switchAction: (name, endpointName) =>
3239 enumLookup({
@@ -241,8 +248,10 @@ const romasku = {
241248 ;
242249 } else if(part[0] == 'i') {
243250 ; // TODO: write validation
251+ } else if(part[0] == 'E') {
252+ ; // TODO: write validation
244253 } else {
245- throw new Error(`Invalid entry ${part}. Should start with one of B, BT, C, D, I, L, M, R, S, SLP, X, i`);
254+ throw new Error(`Invalid entry ${part}. Should start with one of B, BT, C, D, I, L, M, R, S, SLP, X, i, E `);
246255 }
247256 }
248257 },
@@ -358,6 +367,73 @@ const romasku = {
358367 description: "Reverse motor direction (swap OPEN/CLOSE relays)",
359368 entityCategory: "config",
360369 }),
370+ encoderAction: (endpointName) =>{
371+ const exposes = [];
372+ exposes.push(e.enum(`${endpointName}_action`, ea.STATE, [])
373+ .withDescription("Last triggered action")
374+ .withCategory("diagnostic"))
375+ exposes.push(e.numeric(`${endpointName}_step_size`, ea.STATE, [])
376+ .withValueMin(0)
377+ .withValueMax(5000)
378+ .withDescription("Step size for last triggered action")
379+ .withCategory("diagnostic"))
380+
381+ const fromZigbee = [
382+ {
383+ cluster: "genLevelCtrl",
384+ type: ["commandStep"],
385+ convert:
386+ ((model, msg, publish, options, meta) => {
387+ publish(genEncoderPayload(endpointName, `brightness_${msg.data.stepmode === 0 ? 'up' : 'down'}`, msg.data.stepsize));
388+
389+ setTimeout(() => {
390+ publish(genEncoderPayload(endpointName, '', 0));
391+ }, 20);
392+
393+ return;
394+ }),
395+ // biome-ignore lint/suspicious/noExplicitAny: generic
396+ },
397+ {
398+ cluster: "lightingColorCtrl",
399+ type: ["commandStepColorTemp"],
400+ convert:
401+ ((model, msg, publish, options, meta) => {
402+ publish(genEncoderPayload(endpointName, `color_temp_${msg.data.stepmode === 1 ? 'up' : 'down'}`, msg.data.stepsize));
403+
404+ setTimeout(() => {
405+ publish(genEncoderPayload(endpointName, '', 0));
406+ }, 20);
407+
408+ return;
409+ }),
410+ // biome-ignore lint/suspicious/noExplicitAny: generic
411+ },
412+ {
413+ cluster: "genOnOff",
414+ type: ["commandToggle"],
415+ convert:
416+ ((model, msg, publish, options, meta) => {
417+ publish(genEncoderPayload(endpointName, 'toggle_on_off', 0));
418+
419+ setTimeout(() => {
420+ publish(genEncoderPayload(endpointName, '', 0));
421+ }, 20);
422+
423+ return;
424+ }),
425+ // biome-ignore lint/suspicious/noExplicitAny: generic
426+ }
427+ ];
428+
429+ const configure = [
430+ setupConfigureForBinding("genLevelCtrl", "output", [endpointName]),
431+ setupConfigureForBinding("lightingColorCtrl", "output", [endpointName]),
432+ setupConfigureForBinding("genOnOff", "output", [endpointName]),
433+ ]
434+
435+ return {exposes, fromZigbee, configure, isModernExtend: true};
436+ },
361437};
362438
363439const definitions = [
@@ -414,6 +490,9 @@ const definitions = [
414490 {% - for coverName in device .coverNames -%}
415491 "{{coverName}}": {{loop.index + (device.switchNames | length) + (device.relayNames | length) + (device.coverSwitchNames | length)}},{{" "}}
416492 {% - endfor -%}
493+ {% - for encoder in device .encoders -%}
494+ "{{encoder}}": {{loop.index + (device.switchNames | length) + (device.relayNames | length) + (device.coverSwitchNames | length) + (device.coverNames | length)}},{{" "}}
495+ {% - endfor -%}
417496 } }),
418497 {% set first_endpoint = device .switchNames [0] if device .switchNames else (device .relayNames [0] if device .relayNames else (device .coverSwitchNames [0] if device .coverSwitchNames else device .coverNames [0])) %}
419498 romasku.deviceConfig("device_config", "{{first_endpoint}}"),
@@ -461,6 +540,9 @@ const definitions = [
461540 romasku.coverSwitchBindedMode("{{coverSwitchName}}_binded_mode", "{{coverSwitchName}}"),
462541 romasku.coverSwitchLongPressDuration("{{coverSwitchName}}_long_press_duration", "{{coverSwitchName}}"),
463542 {% endfor %}
543+ {% for encoder in device .encoders %}
544+ romasku.encoderAction("{{encoder}}"),
545+ {% endfor %}
464546 ],
465547 meta: { multiEndpoint: true },
466548 configure: async (device, coordinatorEndpoint, logger) => {
0 commit comments