找回密码
 立即注册

微信扫码登录

搜索
查看: 57|回复: 0

[求助] 麦驰双开开关接入z2m

[复制链接]

2

主题

2

回帖

45

积分

新手上路

积分
45
金钱
41
HASS币
0
发表于 6 小时前 | 显示全部楼层 |阅读模式
可以识别型号TS0726但是显示不支持,z2m版本是2.6,zigbee hederman是24.11,我下载的24.1的涂鸦,里面写的转换器一直无法加载,大佬能帮看看错误吗?

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 modernExtend = require('zigbee-herdsman-converters/lib/modernExtend');
const e = exposes.presets;
const ea = exposes.access;
const tuya = require('zigbee-herdsman-converters/lib/tuya');

// 自定义转换器
const fzLocal = {
    TS0726_action: {
        cluster: "genOnOff",
        type: ["commandTuyaAction"],
        convert: (model, msg, publish, options, meta) => {
            return {action: `scene_${msg.endpoint.ID}`};
        }
    }
};

const tzLocal = {
    TS0726_switch_mode: {
        key: ["switch_mode"],
        convertSet: async (entity, key, value, meta) => {
            await entity.write(0xe001, {
                53280: {
                    value: value === "scene" ? 1 : 0,
                    type: 0x30
                }
            });
            return {state: {switch_mode: value}};
        }
    }
};

// 设备定义
const definition = {
    fingerprint: [
        {
            // The model ID from: Device with modelID 'TS0601' is not supported
            // You may need to add \u0000 at the end of the name in some cases
            modelID: 'TS0726',
            // The manufacturer name from: Device with modelID 'TS0601' is not supported.
            manufacturerName: '_TZ3002_ovsw7u2p',
        },
    ],
    model: "TS0726_2_switch",
    vendor: "Tuya",
    description: "2 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.TS0726_switch_mode],
    exposes: [
        ...[1, 2].map((ep) => e.switch().withEndpoint(`l${ep}`)),
        ...[1, 2].map((ep) => e.power_on_behavior().withEndpoint(`l${ep}`)),
        ...[1, 2].map((ep) => e.enum("switch_mode", access.STATE_SET, ["switch", "scene"]).withEndpoint(`l${ep}`)),
        e.action(["scene_1", "scene_2"])
    ],
    endpoint: (device) => {
        return {l1: 1, l2: 2};
    },
    meta: {multiEndpoint: true},
    configure: async (device, coordinatorEndpoint) => {
        await tuya.configureMagicPacket(device, coordinatorEndpoint);
        for (const ep of [1, 2]) {
            await reporting.bind(device.getEndpoint(ep), coordinatorEndpoint, ["genOnOff"]);
        }
    }
};

// 使用 CommonJS 导出方式
module.exports = definition;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-8-20 14:46 , Processed in 0.098640 second(s), 6 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表