Skip to content

Commit dfee13c

Browse files
authored
Apply suggestions from code review
will review again but i think the state key being returned is a mistake and there is translation occuring down the line and the only issue was the state check to turn on Co-authored-by: Jack <5182053+phyzical@users.noreply.github.com>
1 parent 3c8e8eb commit dfee13c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/lib/tuya.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,6 +3315,11 @@ const tuyaTz = {
33153315
return await tz.on_off.convertSet(entity, key, value, meta);
33163316
}
33173317
if (message.brightness != null) {
3318+
// turn on
3319+
if (state[stateKey] === "OFF") {
3320+
await entity.command("genOnOff", "on", {}, utils.getOptions(meta.mapped, entity));
3321+
}
3322+
33183323
// If state includes state_l1 assume we need to use a custom lookup
33193324
const stateKey = Object.keys(state).find((k) => k.startsWith("state_l1")) ? `state_l${entity.ID}` : "state";
33203325
const brightness = utils.toNumber(message.brightness, "brightness");
@@ -3329,11 +3334,7 @@ const tuyaTz = {
33293334
utils.getOptions(meta.mapped, entity),
33303335
);
33313336

3332-
if (state[stateKey] === "OFF") {
3333-
await entity.command("genOnOff", "on", {}, utils.getOptions(meta.mapped, entity));
3334-
}
3335-
3336-
return {state: {[stateKey]: "ON", brightness}};
3337+
return {state: {state: "ON", brightness}};
33373338
}
33383339
},
33393340
convertGet: async (entity, key, meta) => {

0 commit comments

Comments
 (0)