Skip to content

Instantly share code, notes, and snippets.

@Koenkk
Last active December 25, 2022 15:58
Show Gist options
  • Save Koenkk/3d982aef1f138ebae6021d517621e482 to your computer and use it in GitHub Desktop.
Save Koenkk/3d982aef1f138ebae6021d517621e482 to your computer and use it in GitHub Desktop.
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 extend = require('zigbee-herdsman-converters/lib/extend');
const ota = require('zigbee-herdsman-converters/lib/ota');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const utils = require('zigbee-herdsman-converters/lib/utils');
const globalStore = require('zigbee-herdsman-converters/lib/store');
const e = exposes.presets;
const ea = exposes.access;
const definition = {
fingerprint: tuya.fingerprint('TS004F', ['_TZ3000_xabckq1v', '_TZ3000_czuyt8lz', '_TZ3000_ja5osu5g']),
model: 'TS004F',
vendor: 'TuYa',
description: 'Wireless switch with 4 buttons',
exposes: [e.battery(), e.action(['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, fz.tuya_on_off_action],
toZigbee: [tz.tuya_operation_mode],
configure: async (device, coordinatorEndpoint, logger) => {
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']);
await reporting.bind(device.getEndpoint(1), coordinatorEndpoint, ['genOnOff']);
},
};
module.exports = definition;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment