Koenkk / zigbee-herdsman-converters

Collection of device converters to be used with zigbee-herdsman
MIT License
919 stars 3.04k forks source link

Add light switch - TS0601 - vendor '_TZE204_aagrxlbd' #7133

Closed rbernardo89 closed 8 months ago

rbernardo89 commented 8 months ago

I bought a light switch ( 4 gang) of brazilian brand NovaDigital. This device shows unsupported in z2m. The model looks like a zemismart TB26-4: https://www.zigbee2mqtt.io/devices/TB26-4.html

I was able to add the device creating a converter. I copied the exposes in this case and it works: https://github.com/Koenkk/zigbee2mqtt/issues/20944

Below is the code created:

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 {} = 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 = {
    zigbeeModel: ['TS0601'],
    model: 'TS0601',
    vendor: '_TZE204_aagrxlbd',
    description: 'Light Switch',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    //onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime'
    configure: tuya.configureMagicPacket,
    exposes: [
        // Here you should put all functionality that your device exposes
        tuya.exposes.switch().withEndpoint('l1'),
        tuya.exposes.switch().withEndpoint('l2'),
        tuya.exposes.switch().withEndpoint('l3'),
        tuya.exposes.switch().withEndpoint('l4'),
    ],
    endpoint: (device) => {
            return {'l1': 1, 'l2': 1, 'l3': 1, 'l4': 1};
        },
    meta: {
        // All datapoints go in here
        multiEndpoint: true,
        tuyaDatapoints: [
            [1, 'state_l1', tuya.valueConverter.onOff],
            [2, 'state_l2', tuya.valueConverter.onOff],
            [3, 'state_l3', tuya.valueConverter.onOff],
            [4, 'state_l4', tuya.valueConverter.onOff],
        ],
    },
};

module.exports = definition;

Sorry, I'm a noob to this code issue. With this information, is it possible to add the code to z2m for the next updates?

I tried create a pull request, but i received validation error

Thanks!

Koenkk commented 8 months ago

Added, thanks!

Changes will be available in the dev branch in a few hours from now.