Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 211 additions & 8 deletions src/devices/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1481,22 +1481,32 @@ export const definitions: DefinitionWithExtend[] = [
fingerprint: tuya.fingerprint("TS0601", ["_TZE284_zpvusbtv"]),
model: "ZN2S-RS02E",
vendor: "Tuya",
description: "Two gang switch with colored backlight modes",
description: "Two gang switch with colored backlight modes (ZN2S-RS02E)",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "Two gang switch with colored backlight modes (ZN2S-RS02E)",
description: "Two gang switch with colored backlight modes",

extend: [tuya.modernExtend.tuyaBase({dp: true})],
exposes: [
e.switch().withDescription("All switches"),
e.switch().withEndpoint("l1"),
e.switch().withEndpoint("l2"),
e.binary("backlight_mode", ea.STATE_SET, "ON", "OFF").withDescription("Backlight mode"),
e.binary("indicator_mode", ea.STATE_SET, "ON", "OFF").withDescription("Indicator mode"),
tuya.exposes.switch().withDescription("All switches"),
tuya.exposes.switch().withEndpoint("l1"),
tuya.exposes.switch().withEndpoint("l2"),

// --- Mejoras añadidas ---
e
.binary("backlight_switch", ea.STATE_SET, "ON", "OFF")
.withDescription("Backlight master switch"),
e.numeric("backlight", ea.STATE_SET).withValueMin(0).withValueMax(100).withUnit("%").withDescription("Backlight brightness percentage"),

e.enum("indicator_mode", ea.STATE_SET, ["off", "on_off_status", "switch_position"]).withDescription("LED indicator mode"),

e.power_on_behavior().withAccess(ea.STATE_SET),
e.binary("child_lock", ea.STATE_SET, "ON", "OFF").withDescription("Child lock"),

e
.enum("on_color", ea.STATE_SET, ["red", "blue", "green", "white", "yellow", "magenta", "cyan", "warm_white", "warm_yellow"])
.withDescription("ON color"),

e
.enum("off_color", ea.STATE_SET, ["red", "blue", "green", "white", "yellow", "magenta", "cyan", "warm_white", "warm_yellow"])
.withDescription("OFF color"),

e.numeric("countdown_l1", ea.STATE_SET).withUnit("s").withDescription("Countdown for l1").withValueMin(0).withValueMax(86400),
e.numeric("countdown_l2", ea.STATE_SET).withUnit("s").withDescription("Countdown for l2").withValueMin(0).withValueMax(86400),
],
Expand All @@ -1509,9 +1519,202 @@ export const definitions: DefinitionWithExtend[] = [
[7, "countdown_l1", tuya.valueConverter.countdown],
[8, "countdown_l2", tuya.valueConverter.countdown],
[14, "power_on_behavior", tuya.valueConverter.powerOnBehaviorEnum],
[15, "indicator_mode", tuya.valueConverter.onOff],
[16, "backlight_mode", tuya.valueConverter.onOff],

// ✅ Corregido: ENUM
[
15,
"indicator_mode",
tuya.valueConverterBasic.lookup({
off: tuya.enum(0),
on_off_status: tuya.enum(1),
switch_position: tuya.enum(2),
}),
],

[16, "backlight_switch", tuya.valueConverter.onOff],
[101, "child_lock", tuya.valueConverter.onOff],

// ✅ Nuevo: backlight %
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all non English text

[102, "backlight", tuya.valueConverter.raw],

[
103,
"on_color",
tuya.valueConverterBasic.lookup({
red: tuya.enum(0),
blue: tuya.enum(1),
green: tuya.enum(2),
white: tuya.enum(3),
yellow: tuya.enum(4),
magenta: tuya.enum(5),
cyan: tuya.enum(6),
warm_white: tuya.enum(7),
warm_yellow: tuya.enum(8),
}),
],
[
104,
"off_color",
tuya.valueConverterBasic.lookup({
red: tuya.enum(0),
blue: tuya.enum(1),
green: tuya.enum(2),
white: tuya.enum(3),
yellow: tuya.enum(4),
magenta: tuya.enum(5),
cyan: tuya.enum(6),
warm_white: tuya.enum(7),
warm_yellow: tuya.enum(8),
}),
],
],
},
},
{
fingerprint: tuya.fingerprint("TS0601", ["_TZE204_rkbxtclc"]),
model: "TS0601_3gang_rkbxtclc",
vendor: "Tuya",
description: "Three gang smart switch with backlight (_TZE204_rkbxtclc)",
extend: [tuya.modernExtend.tuyaBase({dp: true})],
exposes: [
tuya.exposes.switch().withDescription("All switches"),
tuya.exposes.switch().withEndpoint("l1"),
tuya.exposes.switch().withEndpoint("l2"),
tuya.exposes.switch().withEndpoint("l3"),

e.binary("backlight_switch", ea.STATE_SET, "ON", "OFF").withDescription("Backlight master switch"),
e.numeric("backlight", ea.STATE_SET).withValueMin(0).withValueMax(100).withUnit("%").withDescription("Backlight brightness percentage"),
e.enum("indicator_mode", ea.STATE_SET, ["off", "on_off_status", "switch_position"]).withDescription("LED indicator mode"),

e.power_on_behavior().withAccess(ea.STATE_SET),
e.binary("child_lock", ea.STATE_SET, "ON", "OFF").withDescription("Child lock"),

e
.enum("on_color", ea.STATE_SET, ["red", "blue", "green", "white", "yellow", "magenta", "cyan", "warm_white", "warm_yellow"])
.withDescription("ON color"),

e
.enum("off_color", ea.STATE_SET, ["red", "blue", "green", "white", "yellow", "magenta", "cyan", "warm_white", "warm_yellow"])
.withDescription("OFF color"),

e.numeric("countdown_l1", ea.STATE_SET).withUnit("s").withDescription("Countdown for l1").withValueMin(0).withValueMax(86400),
e.numeric("countdown_l2", ea.STATE_SET).withUnit("s").withDescription("Countdown for l2").withValueMin(0).withValueMax(86400),
e.numeric("countdown_l3", ea.STATE_SET).withUnit("s").withDescription("Countdown for l3").withValueMin(0).withValueMax(86400),
],
meta: {
multiEndpoint: true,
tuyaDatapoints: [
[13, "state", tuya.valueConverter.onOff],
[1, "state_l1", tuya.valueConverter.onOff],
[2, "state_l2", tuya.valueConverter.onOff],
[3, "state_l3", tuya.valueConverter.onOff],
[7, "countdown_l1", tuya.valueConverter.countdown],
[8, "countdown_l2", tuya.valueConverter.countdown],
[9, "countdown_l3", tuya.valueConverter.countdown],
[14, "power_on_behavior", tuya.valueConverter.powerOnBehaviorEnum],
[
15,
"indicator_mode",
tuya.valueConverterBasic.lookup({
off: tuya.enum(0),
on_off_status: tuya.enum(1),
switch_position: tuya.enum(2),
}),
],
[16, "backlight_switch", tuya.valueConverter.onOff],
[101, "child_lock", tuya.valueConverter.onOff],
[102, "backlight", tuya.valueConverter.raw],
[
103,
"on_color",
tuya.valueConverterBasic.lookup({
red: tuya.enum(0),
blue: tuya.enum(1),
green: tuya.enum(2),
white: tuya.enum(3),
yellow: tuya.enum(4),
magenta: tuya.enum(5),
cyan: tuya.enum(6),
warm_white: tuya.enum(7),
warm_yellow: tuya.enum(8),
}),
],
[
104,
"off_color",
tuya.valueConverterBasic.lookup({
red: tuya.enum(0),
blue: tuya.enum(1),
green: tuya.enum(2),
white: tuya.enum(3),
yellow: tuya.enum(4),
magenta: tuya.enum(5),
cyan: tuya.enum(6),
warm_white: tuya.enum(7),
warm_yellow: tuya.enum(8),
}),
],
],
},
},
{
fingerprint: tuya.fingerprint("TS0601", ["_TZE204_7ytnacie"]),
model: "TS0601_4gang_7ytnacie",
vendor: "Tuya",
description: "Four gang smart switch with backlight (_TZE204_7ytnacie)",
extend: [tuya.modernExtend.tuyaBase({dp: true})],
exposes: [
tuya.exposes.switch().withDescription("All switches"),
tuya.exposes.switch().withEndpoint("l1"),
tuya.exposes.switch().withEndpoint("l2"),
tuya.exposes.switch().withEndpoint("l3"),
tuya.exposes.switch().withEndpoint("l4"),

e.binary("backlight_switch", ea.STATE_SET, "ON", "OFF").withDescription("Backlight master switch"),
e.numeric("backlight", ea.STATE_SET).withValueMin(0).withValueMax(100).withUnit("%").withDescription("Backlight brightness percentage"),
e.enum("indicator_mode", ea.STATE_SET, ["off", "on_off_status", "switch_position"]).withDescription("LED indicator mode"),

e.power_on_behavior().withAccess(ea.STATE_SET),
e.binary("child_lock", ea.STATE_SET, "ON", "OFF").withDescription("Child lock"),

e
.enum("on_color", ea.STATE_SET, ["red", "blue", "green", "white", "yellow", "magenta", "cyan", "warm_white", "warm_yellow"])
.withDescription("ON color"),

e
.enum("off_color", ea.STATE_SET, ["red", "blue", "green", "white", "yellow", "magenta", "cyan", "warm_white", "warm_yellow"])
.withDescription("OFF color"),

e.numeric("countdown_l1", ea.STATE_SET).withUnit("s").withDescription("Countdown for l1").withValueMin(0).withValueMax(86400),
e.numeric("countdown_l2", ea.STATE_SET).withUnit("s").withDescription("Countdown for l2").withValueMin(0).withValueMax(86400),
e.numeric("countdown_l3", ea.STATE_SET).withUnit("s").withDescription("Countdown for l3").withValueMin(0).withValueMax(86400),
e.numeric("countdown_l4", ea.STATE_SET).withUnit("s").withDescription("Countdown for l4").withValueMin(0).withValueMax(86400),
],
meta: {
multiEndpoint: true,
tuyaDatapoints: [
[13, "state", tuya.valueConverter.onOff],
[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.countdown],
[8, "countdown_l2", tuya.valueConverter.countdown],
[9, "countdown_l3", tuya.valueConverter.countdown],
[10, "countdown_l4", tuya.valueConverter.countdown],
[14, "power_on_behavior", tuya.valueConverter.powerOnBehaviorEnum],
[
15,
"indicator_mode",
tuya.valueConverterBasic.lookup({
off: tuya.enum(0),
on_off_status: tuya.enum(1),
switch_position: tuya.enum(2),
}),
],
[16, "backlight_switch", tuya.valueConverter.onOff],
[101, "child_lock", tuya.valueConverter.onOff],
[102, "backlight", tuya.valueConverter.raw],
[
103,
"on_color",
Expand Down