-
-
Save Koenkk/4e1c3f21186739038b42632e6eefddda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 tuya = require('zigbee-herdsman-converters/lib/tuya'); | |
const e = exposes.presets; | |
const ea = exposes.access; | |
const legacy = require('zigbee-herdsman-converters/lib/legacy'); | |
const lumi = require('zigbee-herdsman-converters/lib/lumi'); | |
const utils = require('zigbee-herdsman-converters/lib/utils'); | |
const {develcoModernExtend} = require('../lib/develco'); | |
const {battery} = require('../lib/modernExtend'); | |
const fzLocal = { | |
on_off_action: { | |
cluster: 'genOnOff', | |
type: 'commandTuyaAction', | |
convert: (model, msg, publish, options, meta) => { | |
if (utils.hasAlreadyProcessedMessage(msg, model, msg.data[0])) return; | |
const clickMapping = {0: 'single', 1: 'double', 2: 'hold'}; | |
const buttonMapping = {1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8'}; | |
// TS004F has single endpoint, TS0041A/TS0041 can have multiple but have just one button | |
const button = | |
msg.device.endpoints.length == 1 || ['TS0041A', 'TS0041'].includes(msg.device.modelID) ? '' : `${buttonMapping[msg.endpoint.ID]}_`; | |
return {action: `${button}${clickMapping[msg.data.value]}`}; | |
}, | |
} | |
} | |
const definition = { | |
zigbeeModel: ['TS0044'], | |
model: 'TS0044', | |
vendor: 'Tuya', | |
description: 'Wireless switch with 4 buttons', | |
whiteLabel: [ | |
{vendor: 'Lonsonho', model: 'TS0044'}, | |
{vendor: 'Haozee', model: 'ESW-OZAA-EU'}, | |
{vendor: 'LoraTap', model: 'SS6400ZB'}, | |
{vendor: 'Moes', model: 'ZT-SY-EU-G-4S-WH-MS'}, | |
tuya.whitelabel('Moes', 'ZT-SR-EU4', 'Star Ring 4 Gang Scene Switch', ['_TZ3000_a4xycprs']), | |
tuya.whitelabel('Tuya', 'TS0044_1', 'Zigbee 4 button remote - 12 scene', ['_TZ3000_dziaict4', '_TZ3000_mh9px7cq', '_TZ3000_j61x9rxn']), | |
tuya.whitelabel('Tuya', 'TM-YKQ004', 'Zigbee 4 button remote - 12 scene', ['_TZ3000_u3nv1jwk']), | |
], | |
fromZigbee: [fzLocal.on_off_action, fz.battery], | |
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', | |
]), | |
], | |
toZigbee: [], | |
configure: tuya.configureMagicPacket, | |
/* | |
* reporting.batteryPercentageRemaining removed as it was causing devices to fall of the network | |
* every 1 hour, with light flashing when it happened, extremely short battery life, 2 presses for | |
* action to register: https://github.com/Koenkk/zigbee2mqtt/issues/8072 | |
* Initially wrapped in a try catch: https://github.com/Koenkk/zigbee2mqtt/issues/6313 | |
*/ | |
}; | |
module.exports = definition; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment