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

 找回密码
 立即注册
查看: 312|回复: 0

[技术探讨] 询问Z2M 外部转换器写法 TS0726 一路二路四路(带情景)开关

[复制链接]

8

主题

111

帖子

528

积分

高级会员

Rank: 4

积分
528
金钱
417
HASS币
0
发表于 2024-10-16 03:20:39 | 显示全部楼层 |阅读模式
本帖最后由 下載王下載王 于 2024-10-16 03:22 编辑

询问Z2M 外部转换器写法 TS0726 一路二路四路(带情景)开关
以下為Tuya云平台查到的資料
{
  "result": {
    "category": "cjkg",
    "functions": [
      {
        "code": "scene_1",
        "dp_id": 1,
        "type": "Enum",
        "values": "{"range":["scene"]}"
      },
      {
        "code": "scene_2",
        "dp_id": 2,
        "type": "Enum",
        "values": "{"range":["scene"]}"
      },
      {
        "code": "scene_id_group_id",
        "dp_id": 17,
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "mode_1",
        "dp_id": 18,
        "type": "Enum",
        "values": "{"range":["switch_1","scene_1"]}"
      },
      {
        "code": "mode_2",
        "dp_id": 19,
        "type": "Enum",
        "values": "{"range":["switch_2","scene_2"]}"
      },
      {
        "code": "switch_1",
        "dp_id": 24,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_2",
        "dp_id": 25,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "countdown_1",
        "dp_id": 30,
        "type": "Integer",
        "values": "{"unit":"s","min":0,"max":43200,"scale":0,"step":1}"
      },
      {
        "code": "countdown_2",
        "dp_id": 31,
        "type": "Integer",
        "values": "{"unit":"s","min":0,"max":43200,"scale":0,"step":1}"
      },
      {
        "code": "switch_backlight",
        "dp_id": 36,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "relay_status",
        "dp_id": 38,
        "type": "Enum",
        "values": "{"range":["power_off","power_on","last"]}"
      },
      {
        "code": "relay_status_1",
        "dp_id": 39,
        "type": "Enum",
        "values": "{"range":["power_off","power_on","last"]}"
      },
      {
        "code": "relay_status_2",
        "dp_id": 40,
        "type": "Enum",
        "values": "{"range":["power_off","power_on","last"]}"
      }
    ],
    "lang_config": {},
    "status": [
      {
        "code": "scene_1",
        "dp_id": 1,
        "type": "Enum",
        "values": "{"range":["scene"]}"
      },
      {
        "code": "scene_2",
        "dp_id": 2,
        "type": "Enum",
        "values": "{"range":["scene"]}"
      },
      {
        "code": "scene_id_group_id",
        "dp_id": 17,
        "type": "Raw",
        "values": "{}"
      },
      {
        "code": "mode_1",
        "dp_id": 18,
        "type": "Enum",
        "values": "{"range":["switch_1","scene_1"]}"
      },
      {
        "code": "mode_2",
        "dp_id": 19,
        "type": "Enum",
        "values": "{"range":["switch_2","scene_2"]}"
      },
      {
        "code": "switch_1",
        "dp_id": 24,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "switch_2",
        "dp_id": 25,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "countdown_1",
        "dp_id": 30,
        "type": "Integer",
        "values": "{"unit":"s","min":0,"max":43200,"scale":0,"step":1}"
      },
      {
        "code": "countdown_2",
        "dp_id": 31,
        "type": "Integer",
        "values": "{"unit":"s","min":0,"max":43200,"scale":0,"step":1}"
      },
      {
        "code": "switch_backlight",
        "dp_id": 36,
        "type": "Boolean",
        "values": "{}"
      },
      {
        "code": "relay_status",
        "dp_id": 38,
        "type": "Enum",
        "values": "{"range":["power_off","power_on","last"]}"
      },
      {
        "code": "relay_status_1",
        "dp_id": 39,
        "type": "Enum",
        "values": "{"range":["power_off","power_on","last"]}"
      },
      {
        "code": "relay_status_2",
        "dp_id": 40,
        "type": "Enum",
        "values": "{"range":["power_off","power_on","last"]}"
      }
    ]
  },
  "success": true,
  "t": 1728902472733,
  "tid": "d4d1e1f78a1811ef8a7de283003eef7e"
}


功能描述  Code  類型  取值範圍
場景1 scene_1 Enum  
{
  "range": [
    "scene"
  ]
}
場景2 scene_2 Enum  
{
  "range": [
    "scene"
  ]
}
場景ID組ID scene_id_group_id Raw 
{}
模式1 mode_1  Enum  
{
  "range": [
    "switch_1",
    "scene_1"
  ]
}
模式2 mode_2  Enum  
{
  "range": [
    "switch_2",
    "scene_2"
  ]
}
開關1 switch_1  Boolean 
"{true,false}"
開關2 switch_2  Boolean 
"{true,false}"
開關1倒計時  countdown_1 Integer 
{
  "unit": "s",
  "min": 0,
  "max": 43200,
  "scale": 0,
  "step": 1
}
開關2倒計時  countdown_2 Integer 
{
  "unit": "s",
  "min": 0,
  "max": 43200,
  "scale": 0,
  "step": 1
}
背光開關  switch_backlight  Boolean 
"{true,false}"
上電狀態設置  relay_status  Enum  
{
  "range": [
    "power_off",
    "power_on",
    "last"
  ]
}
開關1上電狀態設置 relay_status_1  Enum  
{
  "range": [
    "power_off",
    "power_on",
    "last"
  ]
}
開關2上電狀態設置 relay_status_2  Enum  
{
  "range": [
    "power_off",
    "power_on",
    "last"
  ]
}





以下為我用ChatGPT寫的
----
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 e = exposes.presets;
const ea = exposes.access;
const tuya = require('zigbee-herdsman-converters/lib/tuya');

const definition = {
    fingerprint: [
        {
            modelID: "TS0726",
            manufacturerName: "_TZ3002_xw7xz6ys",
        }
    ],
    model: 'TS0726',
    vendor: 'TuYa',
    description: 'TuYa Two Gang Switch (with scene control and backlight)',
    powerSource: 'Mains (single phase)',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [
        tz.on_off,
        tuya.tz.datapoints
    ],
    configure: tuya.configureMagicPacket,
    exposes: [
        e.action(['scene_1', 'scene_2']),  // 场景控制
        e.linkquality(),
        tuya.exposes.switch().withEndpoint('switch_1'),  // 开关1
        tuya.exposes.switch().withEndpoint('switch_2'),  // 开关2
        tuya.exposes.countdown().withEndpoint('countdown_1'),  // 倒计时1
        tuya.exposes.countdown().withEndpoint('countdown_2'),  // 倒计时2
        e.binary('switch_backlight', ea.STATE_SET, 'ON', 'OFF').withDescription('背光开关'),  // 背光开关
        e.enum('relay_status', ea.STATE_SET, ['power_off', 'power_on', 'last']).withDescription('上电状态设置'),  // 全局上电状态设置
        e.enum('relay_status_1', ea.STATE_SET, ['power_off', 'power_on', 'last']).withDescription('开关1上电状态设置'),  // 开关1的上电状态设置
        e.enum('relay_status_2', ea.STATE_SET, ['power_off', 'power_on', 'last']).withDescription('开关2的上电状态设置'),  // 开关2的上电状态设置
        e.enum('mode_1', ea.STATE_SET, ['switch_1', 'scene_1']).withDescription('开关1模式'),  // 开关1模式
        e.enum('mode_2', ea.STATE_SET, ['switch_2', 'scene_2']).withDescription('开关2模式'),  // 开关2模式
    ],
    endpoint: (device) => {
        return {
            'switch_1': 1,
            'switch_2': 2
        };
    },
    meta: {
        multiEndpoint: true,
        disableDefaultResponse: true,
        timeout: 5000,
        tuyaDatapoints: [
            [1, 'scene_1', tuya.valueConverter.static('scene')],
            [2, 'scene_2', tuya.valueConverter.static('scene')],
            [17, 'scene_id_group_id', tuya.valueConverter.raw],
            [18, 'mode_1', tuya.valueConverterBasic.lookup({'switch_1': 0, 'scene_1': 1})],
            [19, 'mode_2', tuya.valueConverterBasic.lookup({'switch_2': 0, 'scene_2': 1})],
            [24, 'switch_1', tuya.valueConverter.onOff],
            [25, 'switch_2', tuya.valueConverter.onOff],
            [30, 'countdown_1', tuya.valueConverter.countdown],  // 倒计时1
            [31, 'countdown_2', tuya.valueConverter.countdown],  // 倒计时2
            [36, 'switch_backlight', tuya.valueConverter.onOff],  // 背光开关
            [38, 'relay_status', tuya.valueConverterBasic.lookup({'power_off': 0, 'power_on': 1, 'last': 2})],  // 上电状态
            [39, 'relay_status_1', tuya.valueConverterBasic.lookup({'power_off': 0, 'power_on': 1, 'last': 2})],  // 开关1的上电状态
            [40, 'relay_status_2', tuya.valueConverterBasic.lookup({'power_off': 0, 'power_on': 1, 'last': 2})],  // 开关2的上电状态
        ],
    },
};

module.exports = definition;



回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-4 01:16 , Processed in 0.045184 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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