『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 304|回复: 5

[基础教程] zigbee2mqtt接anthouse配置文件

[复制链接]

2

主题

24

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
98
HASS币
0
发表于 2024-12-13 00:21:25 | 显示全部楼层 |阅读模式
本帖最后由 fenny96 于 2024-12-13 00:24 编辑

入坑不久,但是入坑很深,是我日日夜夜(只有夜,白天要上班)翻源码,试方法一个一个试出来,可能不完美但是应该能满足日常使用。不管怎么样,如果帮到你了,请对我说声谢谢,本人小区是武汉的,本小区的可以联系我一起交流

先来一个单路通断器的js文件
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const e = exposes.presets;
const reporting = require('zigbee-herdsman-converters/lib/reporting');

const definition = {
    fingerprint: [
        {modelID: 'LightPanel1_ZM211-TLW', manufacturerName: 'anthouse'},
    ],
    model: 'LightPanel1_ZM211-TLW',
    vendor: 'anthouse',
    description: '1 gang switch',
    whiteLabel: [{vendor: 'Larkkey', model: 'PS580'}],
    extend: [tuya.modernExtend.tuyaOnOff()],
    meta: {disableDefaultResponse: true},
    configure: async (device, coordinatorEndpoint) => {
        await tuya.configureMagicPacket(device, coordinatorEndpoint);
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint);
    },
    
};

module.exports = definition;
同时感谢https://bbs.hassbian.com/thread-26642-1-1.html这篇文章的作者,偶然看到他帖子说用涂鸦网关接入过这个品牌的电机,一下子思路就打开了。一头扎到tuya的js文件中,然后就解决了

其他东西我成功接入后都会发上来

评分

参与人数 1金钱 +12 收起 理由
隔壁的王叔叔 + 12 高手,这是高手!

查看全部评分

回复

使用道具 举报

4

主题

337

帖子

2500

积分

金牌会员

Rank: 6Rank: 6

积分
2500
金钱
2163
HASS币
0
发表于 2024-12-13 17:24:15 | 显示全部楼层
写代码的都是高手,我也有一个zigbee,不会接
回复

使用道具 举报

2

主题

24

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
98
HASS币
0
 楼主| 发表于 2024-12-15 23:18:12 | 显示全部楼层
双路通断器
onst tuya = require('zigbee-herdsman-converters/lib/tuya');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const e = exposes.presets;
const reporting = require('zigbee-herdsman-converters/lib/reporting');

const definition = {
    fingerprint: [
        {modelID: 'LightPanel2_ZM221-TLW', manufacturerName: 'anthouse'},
    ],
    model: 'LightPanel2_ZM221-TLW',
    vendor: 'anthouse',
    description: '2 gang switch',
    whiteLabel: [{vendor: 'Larkkey', model: 'PS580'}],
    extend: [tuya.modernExtend.tuyaOnOff()],
    exposes: [e.switch().withEndpoint('l1'), e.switch().withEndpoint('l2')],
    endpoint: (device) => {
        return {l1: 1, l2: 2};
    },
    meta: {multiEndpoint: true, disableDefaultResponse: true},
    configure: async (device, coordinatorEndpoint) => {
        await tuya.configureMagicPacket(device, coordinatorEndpoint);
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint);
        const endpoint2 = device.getEndpoint(2);
        await reporting.bind(endpoint2, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint2);
    },

};

module.exports = definition;
回复

使用道具 举报

2

主题

24

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
98
HASS币
0
 楼主| 发表于 2024-12-15 23:25:56 | 显示全部楼层
三路通断器
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const e = exposes.presets;
const reporting = require('zigbee-herdsman-converters/lib/reporting');

const definition = {
    fingerprint: [
        {modelID: 'LightPanel3_ZM231-TLW', manufacturerName: 'anthouse'},
    ],
    model: 'LightPanel3_ZM231-TLW',
    vendor: 'anthouse',
    description: '3 gang switch',
    whiteLabel: [{vendor: 'Larkkey', model: 'PS580'}],
    extend: [tuya.modernExtend.tuyaOnOff()],
    exposes: [e.switch().withEndpoint('l1'), e.switch().withEndpoint('l2'), e.switch().withEndpoint('l3')],
    endpoint: (device) => {
        return {l1: 1, l2: 2, l3: 3};
    },
    meta: {multiEndpoint: true, disableDefaultResponse: true},
    configure: async (device, coordinatorEndpoint) => {
        await tuya.configureMagicPacket(device, coordinatorEndpoint);
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint);
        const endpoint2 = device.getEndpoint(2);
        await reporting.bind(endpoint2, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint2);
        const endpoint3 = device.getEndpoint(3);
        await reporting.bind(endpoint3, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint3);
    },

};

module.exports = definition;
回复

使用道具 举报

2

主题

24

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
98
HASS币
0
 楼主| 发表于 2024-12-15 23:27:30 | 显示全部楼层
窗帘电机,有点小瑕疵,使用完全没问题
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 definition = {
    fingerprint: [{modelID: 'Curtain_ZC004_TLW', manufacturerName: 'anthouse'}],
    model: 'MS-108ZR',
    vendor: 'Moes',
    description: 'Zigbee + RF curtain switch module',
    meta: {coverInverted: true},
    whiteLabel: [tuya.whitelabel('QA', 'QACZ1', 'Curtain switch', ['_TZ3210_xbpt8ewc'])],
    fromZigbee: [fz.tuya_cover_options, fz.cover_position_tilt],
    toZigbee: [tz.cover_state, tz.moes_cover_calibration, tz.cover_position_tilt, tz.tuya_cover_reversal],
    exposes: [
        e.cover_position(),
        e.numeric('calibration_time', ea.ALL).withValueMin(0).withValueMax(100),
        e.enum('moving', ea.STATE, ['UP', 'STOP', 'DOWN']),
        e.binary('motor_reversal', ea.ALL, 'ON', 'OFF'),
    ],
};

module.exports = definition; 
回复

使用道具 举报

2

主题

24

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
98
HASS币
0
 楼主| 发表于 2024-12-16 00:24:50 | 显示全部楼层
wbdownn 发表于 2024-12-13 17:24
写代码的都是高手,我也有一个zigbee,不会接

找类似设备直接抄,基本能搞定
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-26 19:22 , Processed in 0.207294 second(s), 29 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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