zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[External Converter]: TS0601 from _TZE284_xvywzhmi

Open Rod-Persky opened this issue 11 months ago • 10 comments

Link

https://www.zemismart.com/products/zms-208us

Database entry

{"id":33,"type":"Router","ieeeAddr":"0xa4c1383c6ae03baa","nwkAddr":30427,"manufId":4417,"manufName":"_TZE284_xvywzhmi","powerSource":"Mains (single phase)","modelId":"TS0601","epList":[1,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[4,5,61184,0,60672],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"�\u0000\u0000\u0000i�\u0000\u0000\u0000i�\u0000\u0000\u0000i�\u0000\u0000\u0000i�\u0000\u0000\u0000i�\u0000\u0000\u0000i�\u0000\u0000\u0000i�\u0000\u0000\u0000i","65506":56,"65508":0,"65534":0,"modelId":"TS0601","manufacturerName":"_TZE284_xvywzhmi","powerSource":1,"zclVersion":3,"appVersion":78,"stackVersion":0,"hwVersion":1,"dateCode":""}}},"binds":[],"configuredReportings":[],"meta":{}},"242":{"profId":41440,"epId":242,"devId":97,"inClusterList":[],"outClusterList":[33],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":78,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"interviewState":"SUCCESSFUL","meta":{"configured":332242049},"lastSeen":1765111526000}

Zigbee2MQTT version

2.6.3 (6e001b48ec278c6c141579c9eacc045f190fc289 )

External converter

const exposes = require("zigbee-herdsman-converters/lib/exposes");
const tuya = require("zigbee-herdsman-converters/lib/tuya");

const e = exposes.presets;

const ea = exposes.access;

const valueConverterLocal = {
    indiciatorStatus: tuya.valueConverterBasic.lookup({
        off: tuya.enum(0),
        on_off_status: tuya.enum(1),
        switch_position: tuya.enum(2),
    }),
};

// Derived from ZMS-206EU-3 in https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/zemismart.ts
const definition = {
    fingerprint: tuya.fingerprint("TS0601", ["_TZE284_xvywzhmi"]),
    model: "ZMS-208US-3",
    vendor: "Zemismart",
    description: "Smart screen switch 3 gang",
    extend: [tuya.modernExtend.tuyaBase({dp: true})],
    exposes: [
        e.switch(),
        e.switch().withEndpoint("l1"),
        e.switch().withEndpoint("l2"),
        e.switch().withEndpoint("l3"),
        e.child_lock(),
        e.text("name", ea.STATE_SET).withEndpoint("l1").withDescription("Name for Switch 1"),
        e.text("name", ea.STATE_SET).withEndpoint("l2").withDescription("Name for Switch 2"),
        e.text("name", ea.STATE_SET).withEndpoint("l3").withDescription("Name for Switch 3"),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l1")
            .withDescription("Countdown for Switch 1")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l2")
            .withDescription("Countdown for Switch 2")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l3")
            .withDescription("Countdown for Switch 3")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
    ],
    endpoint: (device) => {
        return {l1: 1, l2: 1, l3: 1};
    },
    meta: {
        multiEndpoint: true,
        tuyaDatapoints: [
            [1, "state_l1", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [2, "state_l2", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [3, "state_l3", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [7, "countdown_l1", tuya.valueConverter.raw],
            [8, "countdown_l2", tuya.valueConverter.raw],
            [9, "countdown_l3", tuya.valueConverter.raw],
            [13, "state", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [24, "test_bit", tuya.valueConverter.raw], // Unclear what this does
            [101, "child_lock", tuya.valueConverter.lockUnlock],
            [105, "name_l1", valueConverterLocal.name],
            [106, "name_l2", valueConverterLocal.name],
            [107, "name_l3", valueConverterLocal.name],
        ],
    },
};

module.exports = definition;

What does/doesn't work with the external definition?

Currently all tested features work.

Notes

software_build_id: undefined date_code: `` endpoints:

{"1":{"clusters":{"input":["genGroups","genScenes","manuSpecificTuya","genBasic","zosungIRTransmit"],"output":["genOta","genTime"]},"name":"l1"},"242":{"clusters":{"input":[],"output":["greenPower"]}}}

Rod-Persky avatar Dec 07 '25 12:12 Rod-Persky

🙏 Thank you for creating this issue and sharing your external converter!

In case all features work, please submit a pull request on this repository so the device can be supported out-of-the-box with the next release. For instructions on how to create a pull request see the docs.

If NOT all features work, please follow the How To Support new devices. Since this is a Tuya also consider How To Support new Tuya devices.

If you need help with the process, feel free to ask here and we'll be happy to assist.

github-actions[bot] avatar Dec 07 '25 12:12 github-actions[bot]

PR: https://github.com/Koenkk/zigbee-herdsman-converters/pull/10961

Rod-Persky avatar Dec 07 '25 13:12 Rod-Persky

Device image Image

Rod-Persky avatar Dec 07 '25 13:12 Rod-Persky

@Koenkk this is ready to go

  • Herdsman: https://github.com/Koenkk/zigbee-herdsman-converters/pull/10961
  • Docs PR: https://github.com/Koenkk/zigbee2mqtt.io/pull/4527

Rod-Persky avatar Dec 07 '25 13:12 Rod-Persky

Thanks @Rod-Persky !

Changes will be available in the dev branch in a few hours from now and in the next release which is every 1st of the month.

Koenkk avatar Dec 07 '25 19:12 Koenkk

Hi! I have the 4-way version (ZMS-208US-4). I've added the lines for l4 to the converter and I can control all four channels fine, but I can't change the names. When I do, I get this error:

[11/12/2025, 11:09:14 am] frontend:api: Sending {"topic":"0xa4c138c3706abe1f/set","payload":{"name_l1":"Lights"}} [11/12/2025, 11:09:14 am] z2m: Publish 'set' 'name' to '0xa4c138c3706abe1f' failed: 'TypeError: Cannot read properties of undefined (reading 'to')'

What am I missing?

const exposes = require("zigbee-herdsman-converters/lib/exposes");
const tuya = require("zigbee-herdsman-converters/lib/tuya");

const e = exposes.presets;

const ea = exposes.access;

const valueConverterLocal = {
    indiciatorStatus: tuya.valueConverterBasic.lookup({
        off: tuya.enum(0),
        on_off_status: tuya.enum(1),
        switch_position: tuya.enum(2),
    }),
};

// Derived from ZMS-206EU-3 in https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/zemismart.ts
const definition = {
    fingerprint: tuya.fingerprint("TS0601", ["_TZE284_xibaabmu"]),
    model: "ZMS-208US-4",
    vendor: "Zemismart",
    description: "Smart screen switch 4 gang",
    extend: [tuya.modernExtend.tuyaBase({dp: true})],
    exposes: [
        e.switch(),
        e.switch().withEndpoint("l1"),
        e.switch().withEndpoint("l2"),
        e.switch().withEndpoint("l3"),
        e.switch().withEndpoint("l4"),
        e.child_lock(),
        e.text("name", ea.STATE_SET).withEndpoint("l1").withDescription("Name for Switch 1"),
        e.text("name", ea.STATE_SET).withEndpoint("l2").withDescription("Name for Switch 2"),
        e.text("name", ea.STATE_SET).withEndpoint("l3").withDescription("Name for Switch 3"),
        e.text("name", ea.STATE_SET).withEndpoint("l4").withDescription("Name for Switch 4"),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l1")
            .withDescription("Countdown for Switch 1")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l2")
            .withDescription("Countdown for Switch 2")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l3")
            .withDescription("Countdown for Switch 3")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l4")
            .withDescription("Countdown for Switch 4")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),

    ],
    endpoint: (device) => {
        return {l1: 1, l2: 1, l3: 1, l4: 1};
    },
    meta: {
        multiEndpoint: true,
        tuyaDatapoints: [
            [1, "state_l1", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [2, "state_l2", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [3, "state_l3", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [4, "state_l4", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],            
            [7, "countdown_l1", tuya.valueConverter.raw],
            [8, "countdown_l2", tuya.valueConverter.raw],
            [9, "countdown_l3", tuya.valueConverter.raw],
            [10, "countdown_l4", tuya.valueConverter.raw],            
            [13, "state", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [24, "test_bit", tuya.valueConverter.raw], // Unclear what this does
            [101, "child_lock", tuya.valueConverter.lockUnlock],
            [105, "name_l1", valueConverterLocal.name],
            [106, "name_l2", valueConverterLocal.name],
            [107, "name_l3", valueConverterLocal.name],
            [108, "name_l4", valueConverterLocal.name],            
        ],
    },
};

module.exports = definition;

veryboringname avatar Dec 11 '25 01:12 veryboringname

@veryboringname I just got lucky since someone else wrote most of this and it worked. I haven't got a way to work out what it should be on the device. I think it's same as the other smart screen 4 button switch just with less functionality (no backlight)

Rod-Persky avatar Dec 12 '25 02:12 Rod-Persky

Your custom converter code looks just fine, the DPID's I'm guessing are as below and that matches up with what you've done. I could change the name from the UI without a special message

I'd just edit here in the main dashboard:

Image

                [1, "state_l1", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
                [2, "state_l2", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
                [3, "state_l3", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
                [4, "state_l4", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
                [7, "countdown_l1", tuya.valueConverter.raw],
                [8, "countdown_l2", tuya.valueConverter.raw],
                [9, "countdown_l3", tuya.valueConverter.raw],
                [10, "countdown_l4", tuya.valueConverter.raw],
                [13, "state", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
                [24, "test_bit", tuya.valueConverter.raw],
                [101, "child_lock", tuya.valueConverter.lockUnlock],
                [105, "name_l1", valueConverterLocal.name],
                [106, "name_l2", valueConverterLocal.name],
                [107, "name_l3", valueConverterLocal.name],
                [108, "name_l4", valueConverterLocal.name],

Rod-Persky avatar Dec 12 '25 03:12 Rod-Persky

ChatGPT and Gemini gave lots of suggestions but nothing worked. I then tried Grok and it fixed it. I can rename the switches now!

The reasoning it gave was:

The error you're seeing occurs because valueConverterLocal.name is referenced in your meta.tuyaDatapoints array (for DPs 105–108), but this converter isn't actually defined in your valueConverterLocal object. When Zigbee2MQTT tries to publish the "set" command for a name (e.g., name_l1), it invokes the missing converter's .to() method during payload conversion, which fails with the "Cannot read properties of undefined (reading 'to')" TypeError.

This is based on the official converter for the similar ZMS-208US-3 model, which handles names as strings encoded as arrays of ASCII character codes (Tuya's format for string DPs). The converter limits names to 12 characters to match the device's constraint.

Here's your corrected converter code. Add the name entry to valueConverterLocal, and I've included minor tweaks for consistency (e.g., ensuring all endpoints use the same skip logic, and confirming the 4-gang structure aligns with the 3-gang's pattern). Drop this into your external converter file and restart Zigbee2MQTT.

This is the corrected converter:

const exposes = require("zigbee-herdsman-converters/lib/exposes");
const tuya = require("zigbee-herdsman-converters/lib/tuya");
const fz = require("zigbee-herdsman-converters/converters/fromZigbee");
const tz = require("zigbee-herdsman-converters/converters/toZigbee");

const e = exposes.presets;
const ea = exposes.access;

const valueConverterLocal = {
    name: {
        to: (v, meta) => {
            const stringValue = String(v ?? "");
            const limitedString = stringValue.slice(0, 12);
            return limitedString.split("").map((char) => char.charCodeAt(0));
        },
        from: (v, meta) => {
            return Object.values(v)
                .map((code) => String.fromCharCode(code))
                .join("");
        },
    },
    indicatorStatus: tuya.valueConverterBasic.lookup({
        off: tuya.enum(0),
        on_off_status: tuya.enum(1),
        switch_position: tuya.enum(2),
    }),
};

// Derived from ZMS-208US-3 in https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/zemismart.ts
const definition = {
    fingerprint: tuya.fingerprint("TS0601", ["_TZE284_xibaabmu"]),
    model: "ZMS-208US-4",
    vendor: "Zemismart",
    description: "Smart screen switch 4 gang",
    extend: [tuya.modernExtend.tuyaBase({dp: true})],
    exposes: [
        e.switch(),
        e.switch().withEndpoint("l1"),
        e.switch().withEndpoint("l2"),
        e.switch().withEndpoint("l3"),
        e.switch().withEndpoint("l4"),
        e.child_lock(),
        e.text("name", ea.STATE_SET).withEndpoint("l1").withDescription("Name for Switch 1"),
        e.text("name", ea.STATE_SET).withEndpoint("l2").withDescription("Name for Switch 2"),
        e.text("name", ea.STATE_SET).withEndpoint("l3").withDescription("Name for Switch 3"),
        e.text("name", ea.STATE_SET).withEndpoint("l4").withDescription("Name for Switch 4"),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l1")
            .withDescription("Countdown for Switch 1")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l2")
            .withDescription("Countdown for Switch 2")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l3")
            .withDescription("Countdown for Switch 3")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
        e
            .numeric("countdown", ea.STATE_SET)
            .withEndpoint("l4")
            .withDescription("Countdown for Switch 4")
            .withUnit("s")
            .withValueMin(0)
            .withValueMax(43200)
            .withValueStep(1),
    ],
    endpoint: (device) => {
        return {l1: 1, l2: 1, l3: 1, l4: 1};
    },
    meta: {
        multiEndpoint: true,
        tuyaDatapoints: [
            [1, "state_l1", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [2, "state_l2", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [3, "state_l3", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [4, "state_l4", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [7, "countdown_l1", tuya.valueConverter.raw],
            [8, "countdown_l2", tuya.valueConverter.raw],
            [9, "countdown_l3", tuya.valueConverter.raw],
            [10, "countdown_l4", tuya.valueConverter.raw],
            [13, "state", tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
            [24, "test_bit", tuya.valueConverter.raw], // Unclear what this does
            [101, "child_lock", tuya.valueConverter.lockUnlock],
            [105, "name_l1", valueConverterLocal.name],
            [106, "name_l2", valueConverterLocal.name],
            [107, "name_l3", valueConverterLocal.name],
            [108, "name_l4", valueConverterLocal.name],
        ],
    },
};

module.exports = definition;

Thanks for the original converter!

veryboringname avatar Dec 12 '25 07:12 veryboringname

Here is the code with Picture added to z2m:

const exposes = require("zigbee-herdsman-converters/lib/exposes"); const tuya = require("zigbee-herdsman-converters/lib/tuya"); const fz = require("zigbee-herdsman-converters/converters/fromZigbee"); const tz = require("zigbee-herdsman-converters/converters/toZigbee");

const e = exposes.presets; const ea = exposes.access;

const valueConverterLocal = { name: { to: (v) => { const stringValue = String(v ?? ""); const limitedString = stringValue.slice(0, 12); return limitedString.split("").map((char) => char.charCodeAt(0)); }, from: (v) => { return Object.values(v) .map((code) => String.fromCharCode(code)) .join(""); }, }, indicatorStatus: tuya.valueConverterBasic.lookup({ off: tuya.enum(0), on_off_status: tuya.enum(1), switch_position: tuya.enum(2), }), };

// Derived from ZMS-208US-3 const definition = { fingerprint: tuya.fingerprint("TS0601", ["_TZE284_xibaabmu"]),

// 🔧 ONLY CHANGE FOR DEVICE IMAGE
model: "ZMS-206US-4",

vendor: "Zemismart",
description: "Smart screen switch 4 gang",

extend: [tuya.modernExtend.tuyaBase({dp: true})],

exposes: [
    e.switch(),
    e.switch().withEndpoint("l1"),
    e.switch().withEndpoint("l2"),
    e.switch().withEndpoint("l3"),
    e.switch().withEndpoint("l4"),

    e.child_lock(),

    e.text("name", ea.STATE_SET).withEndpoint("l1").withDescription("Name for Switch 1"),
    e.text("name", ea.STATE_SET).withEndpoint("l2").withDescription("Name for Switch 2"),
    e.text("name", ea.STATE_SET).withEndpoint("l3").withDescription("Name for Switch 3"),
    e.text("name", ea.STATE_SET).withEndpoint("l4").withDescription("Name for Switch 4"),

    e.numeric("countdown", ea.STATE_SET).withEndpoint("l1").withUnit("s").withValueMin(0).withValueMax(43200),
    e.numeric("countdown", ea.STATE_SET).withEndpoint("l2").withUnit("s").withValueMin(0).withValueMax(43200),
    e.numeric("countdown", ea.STATE_SET).withEndpoint("l3").withUnit("s").withValueMin(0).withValueMax(43200),
    e.numeric("countdown", ea.STATE_SET).withEndpoint("l4").withUnit("s").withValueMin(0).withValueMax(43200),
],

endpoint: () => ({
    l1: 1,
    l2: 1,
    l3: 1,
    l4: 1,
}),

meta: {
    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],

        [7, "countdown_l1", tuya.valueConverter.raw],
        [8, "countdown_l2", tuya.valueConverter.raw],
        [9, "countdown_l3", tuya.valueConverter.raw],
        [10, "countdown_l4", tuya.valueConverter.raw],

        [13, "state", tuya.valueConverter.onOff],
        [24, "test_bit", tuya.valueConverter.raw],

        [101, "child_lock", tuya.valueConverter.lockUnlock],

        [105, "name_l1", valueConverterLocal.name],
        [106, "name_l2", valueConverterLocal.name],
        [107, "name_l3", valueConverterLocal.name],
        [108, "name_l4", valueConverterLocal.name],
    ],
},

};

module.exports = definition;

stas1000 avatar Dec 15 '25 04:12 stas1000