Skip to content

Commit c21add6

Browse files
authored
Apply suggestions from code review
Co-authored-by: Jack <5182053+phyzical@users.noreply.github.com>
1 parent dfee13c commit c21add6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/lib/tuya.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3315,13 +3315,13 @@ const tuyaTz = {
33153315
return await tz.on_off.convertSet(entity, key, value, meta);
33163316
}
33173317
if (message.brightness != null) {
3318+
// If state includes state_l1 assume we need to use a custom lookup
3319+
const stateKey = Object.keys(state).find((k) => k.startsWith("state_l1")) ? `state_l${entity.ID}` : "state";
33183320
// turn on
33193321
if (state[stateKey] === "OFF") {
33203322
await entity.command("genOnOff", "on", {}, utils.getOptions(meta.mapped, entity));
33213323
}
33223324

3323-
// If state includes state_l1 assume we need to use a custom lookup
3324-
const stateKey = Object.keys(state).find((k) => k.startsWith("state_l1")) ? `state_l${entity.ID}` : "state";
33253325
const brightness = utils.toNumber(message.brightness, "brightness");
33263326

33273327
const level = utils.mapNumberRange(brightness, 0, 254, 0, 1000);

0 commit comments

Comments
 (0)