Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
- const tz = require('zigbee-herdsman-converters/converters/toZigbee');
- const exposes = require('zigbee-herdsman-converters/lib/exposes');
- const reporting = require('zigbee-herdsman-converters/lib/reporting');
- const modernExtend = require('zigbee-herdsman-converters/lib/modernExtend');
- const e = exposes.presets;
- const ea = exposes.access;
- const tuya = require('zigbee-herdsman-converters/lib/tuya');
- const definition = {
- fingerprint: tuya.fingerprint('TS004F', ['_TZ3000_11pg3ima']),
- model: 'TS004F',
- vendor: 'Tuya',
- description: 'Wireless switch with 4 buttons',
- exposes: [
- e.battery(),
- e
- .enum('operation_mode', ea.ALL, ['command', 'event'])
- .withDescription('Operation mode: "command" - for group control, "event" - for clicks'),
- e.action([
- 'on',
- 'off',
- 'brightness_step_up',
- 'brightness_step_down',
- 'brightness_move_up',
- 'brightness_move_down',
- '1_single',
- '1_double',
- '1_hold',
- '2_single',
- '2_double',
- '2_hold',
- '3_single',
- '3_double',
- '3_hold',
- '4_single',
- '4_double',
- '4_hold',
- ]),
- ],
- fromZigbee: [fz.battery, tuya.fz.on_off_action, fz.tuya_operation_mode, fz.command_on, fz.command_off, fz.command_step, fz.command_move],
- toZigbee: [tz.tuya_operation_mode],
- configure: async (device, coordinatorEndpoint) => {
- const endpoint = device.getEndpoint(1);
- await endpoint.read('genBasic', [0x0004, 0x000, 0x0001, 0x0005, 0x0007, 0xfffe]);
- await endpoint.write('genOnOff', { tuyaOperationMode: 1 });
- await endpoint.read('genOnOff', ['tuyaOperationMode']);
- try {
- await endpoint.read(0xe001, [0xd011]);
- } catch (err) {
- /* do nothing */
- }
- await endpoint.read('genPowerCfg', ['batteryVoltage', 'batteryPercentageRemaining']);
- await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg']);
- for (const ep of [1, 2, 3, 4]) {
- // Not all variants have all endpoints
- // https://github.com/Koenkk/zigbee2mqtt/issues/15730#issuecomment-1364498358
- if (device.getEndpoint(ep)) {
- await reporting.bind(device.getEndpoint(ep), coordinatorEndpoint, ['genOnOff']);
- }
- }
- await reporting.batteryPercentageRemaining(endpoint);
- }
- };
- module.exports = definition;
Advertisement
Add Comment
Please, Sign In to add comment