Skip to content

Instantly share code, notes, and snippets.

@viperet
Last active November 7, 2020 15:49
Show Gist options
  • Save viperet/048720a0c526a23de9dad59c3a99e77e to your computer and use it in GitHub Desktop.
Save viperet/048720a0c526a23de9dad59c3a99e77e to your computer and use it in GitHub Desktop.

В файле zigbee2mqtt/node_modules/zigbee-herdsman-converters/converters/toZigbee.js добавить перед строкой RM01_light_onoff_brightness: {:

    edm_dimmer_control: {
        key: ['brightness_min', 'brightness', 'brightness_percent', 'level'],
        convertSet: async (entity, key, value, meta) => {
            value = Number(value);
            if (isNaN(value)) {
                throw new Error(`${key} value of message: '${JSON.stringify(meta.message)}' invalid`);
            }
            let Val;
            let dp = 514;
            if (key === 'brightness') {
                if (value >= 0 && value <= 254) {
                    Val = Math.round(value * 1000 / 254);
                } else {
                    throw new Error('Dimmer brightness is out of range 0..254');
                }
            } else if (key === 'brightness_percent') {
                if (value >= 0 && value <= 100) {
                    Val = value * 10;
                } else {
                    throw new Error('Dimmer brightness_percent is out of range 0..100');
                }
            } else if (key === 'level') {
                if (value >= 0 && value <= 1000) {
                    Val = value;
                } else {
                    throw new Error('Dimmer level is out of range 0..1000');
                }
            } else if (key === 'brightness_min') {
                if (value >= 0 && value <= 100) {
                    Val = value * 10;
                    dp = 515;
                } else {
                    throw new Error('Dimmer brightness_min is out of range 0..100');
                }
            }
            const val1 = Val >> 8;
            const val2 = Val & 0xFF;
            sendTuyaCommand(entity, dp, 0, [4, 0, 0, val1, val2]);
        },
    },

В файле zigbee2mqtt/node_modules/zigbee-herdsman-converters/devices.js перед строками

    {
        fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_sbordckq'}],
        model: 'TS0601_curtain_switch',

добавить:

    {
        fingerprint: [
            {modelID: 'TS0601', manufacturerName: '_TZE200_9i9dt8is'},
        ],
        model: 'EDM_1ZAA',
        vendor: 'TuYa',
        description: 'Smarty dimmer switch',
        extend: generic.light_onoff_brightness,
        fromZigbee: [fz.tuya_dimmer, fz.ignore_basic_report],
        toZigbee: [tz.tuya_dimmer_state, tz.edm_dimmer_control],
        meta: {configureKey: 1},
        configure: async (device, coordinatorEndpoint) => {
            const endpoint = device.getEndpoint(1);
            await bind(endpoint, coordinatorEndpoint, ['genOnOff', 'genLevelCtrl']);
        },
        whiteLabel: [
            {vendor: 'Earda', model: 'EDM-1ZAA-EU'},
        ],
    },

Конфиг диммера для homebridge/mqtthing:

        {
           "accessory": "mqttthing",
           "type": "lightbulb",
           "name": "Dimmer",
           "url": "http://.....:1883",
           "username": ".....",
           "password": ".....",
           "topics": {
               "getOn": {
                   "topic": "zigbee/xxxxxxx",
                   "apply": "return JSON.parse(message).state"
               },
               "setOn": {
                   "topic": "zigbee/xxxxxxx/set",
                   "apply": "return JSON.stringify({state: message})"
               },
               "setBrightness": {
                   "topic": "zigbee/xxxxxxx/set",
                   "apply": "return JSON.stringify({brightness: Math.round(message*254/100)})"
               },
               "getBrightness": {
                   "topic": "zigbee/xxxxxxx",
                   "apply": "return JSON.parse(message).level/10"
               }
           },
           "onValue": "ON",
           "offValue": "OFF"
       },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment