-
-
Save Koenkk/1c7811ba5296543905aaf0482b54484e 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 legacy = require('zigbee-herdsman-converters/lib/legacy'); | |
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 fzLocal = { | |
TS0726_action: { | |
cluster: 'genOnOff', | |
type: ['raw'], | |
convert: (model, msg, publish, options, meta) => { | |
return {action: `scene_${msg.endpoint.ID}`}; | |
}, | |
}, | |
}; | |
const tzLocal = { | |
switch_mode: { | |
key: ['switch_mode'], | |
convertSet: async (entity, key, value, meta) => { | |
await entity.write(0xe001, {0xd020: {value: {switch: 0, scene: 1}[value], type: 0x30}}); | |
return {state: {switch_mode: value}}; | |
}, | |
}, | |
}; | |
const definition = { | |
zigbeeModel: ['TS0726'], | |
model: 'TS0726', | |
vendor: 'TuYa', | |
description: '4 gang switch with neutral wire', | |
fromZigbee: [fz.on_off, tuya.fz.power_on_behavior_2, fz.ignore_basic_report, fzLocal.TS0726_action], | |
toZigbee: [tz.on_off, tuya.tz.power_on_behavior_2, tzLocal.switch_mode], | |
exposes: [e.switch().withEndpoint('l1'), e.power_on_behavior().withEndpoint('l1'), e.switch().withEndpoint('l2'), | |
e.power_on_behavior().withEndpoint('l2'), e.switch().withEndpoint('l3'), e.power_on_behavior().withEndpoint('l3'), | |
e.switch().withEndpoint('l4'), e.power_on_behavior().withEndpoint('l4'), | |
e.enum('switch_mode', ea.STATE_SET, ['switch', 'scene']).withEndpoint('l1'), | |
e.enum('switch_mode', ea.STATE_SET, ['switch', 'scene']).withEndpoint('l2'), | |
e.enum('switch_mode', ea.STATE_SET, ['switch', 'scene']).withEndpoint('l3'), | |
e.enum('switch_mode', ea.STATE_SET, ['switch', 'scene']).withEndpoint('l4'), | |
e.action(['scene_1', 'scene_2', 'scene_3', 'scene_4']), | |
], | |
endpoint: (device) => { | |
return {'l1': 1, 'l2': 2, 'l3': 3, 'l4': 4}; | |
}, | |
meta: {multiEndpoint: true}, | |
configure: async (device, coordinatorEndpoint, logger) => { | |
await tuya.configureMagicPacket(device, coordinatorEndpoint, logger); | |
await reporting.bind(device.getEndpoint(1), coordinatorEndpoint, ['genOnOff']); | |
await reporting.bind(device.getEndpoint(2), coordinatorEndpoint, ['genOnOff']); | |
await reporting.bind(device.getEndpoint(3), coordinatorEndpoint, ['genOnOff']); | |
await reporting.bind(device.getEndpoint(4), coordinatorEndpoint, ['genOnOff']); | |
}, | |
}; | |
module.exports = definition; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment