Skip to content

Commit

Permalink
feat: Expose power_on_behavior and backlight_mode for TuYa TS0601…
Browse files Browse the repository at this point in the history
…_dimmer_1, TS0601_dimmer_2 and TS0601_dimmer_3 (#6172)

* power_on_behavior and backlight_mode for wall dimmer

* lint

* add inverted backlight_mode

* Update tuya.ts

* Update tuya.ts

---------

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
kirovilya and Koenkk authored Sep 18, 2023
1 parent c78fad1 commit 3d27893
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/devices/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1236,8 +1236,9 @@ const definitions: Definition[] = [
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
configure: tuya.configureMagicPacket,
exposes: [tuya.exposes.lightBrightnessWithMinMax(), e.power_on_behavior(),
tuya.exposes.countdown(), tuya.exposes.lightType()],
exposes: [tuya.exposes.lightBrightnessWithMinMax(), tuya.exposes.countdown(), tuya.exposes.lightType(),
e.power_on_behavior().withAccess(ea.STATE_SET),
tuya.exposes.backlightModeOffNormalInverted().withAccess(ea.STATE_SET)],
meta: {
tuyaDatapoints: [
[1, 'state', tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
Expand All @@ -1247,6 +1248,7 @@ const definitions: Definition[] = [
[5, 'max_brightness', tuya.valueConverter.scale0_254to0_1000],
[6, 'countdown', tuya.valueConverter.countdown],
[14, 'power_on_behavior', tuya.valueConverter.powerOnBehavior],
[21, 'backlight_mode', tuya.valueConverter.backlightMode],
],
},
whiteLabel: [
Expand All @@ -1269,6 +1271,8 @@ const definitions: Definition[] = [
tuya.exposes.lightBrightnessWithMinMax().withEndpoint('l2'),
tuya.exposes.countdown().withEndpoint('l1'),
tuya.exposes.countdown().withEndpoint('l2'),
e.power_on_behavior().withAccess(ea.STATE_SET),
tuya.exposes.backlightModeOffNormalInverted().withAccess(ea.STATE_SET),
],
meta: {
multiEndpoint: true,
Expand All @@ -1283,6 +1287,8 @@ const definitions: Definition[] = [
[9, 'min_brightness_l2', tuya.valueConverter.scale0_254to0_1000],
[11, 'max_brightness_l2', tuya.valueConverter.scale0_254to0_1000],
[12, 'countdown_l2', tuya.valueConverter.countdown],
[14, 'power_on_behavior', tuya.valueConverter.powerOnBehaviorEnum],
[21, 'backlight_mode', tuya.valueConverter.backlightMode],
],
},
endpoint: (device) => {
Expand All @@ -1303,7 +1309,8 @@ const definitions: Definition[] = [
toZigbee: [tuya.tz.datapoints],
configure: tuya.configureMagicPacket,
exposes: [tuya.exposes.lightBrightness().withEndpoint('l1'), tuya.exposes.lightBrightness().withEndpoint('l2'),
tuya.exposes.lightBrightness().withEndpoint('l3')],
tuya.exposes.lightBrightness().withEndpoint('l3'), e.power_on_behavior().withAccess(ea.STATE_SET),
tuya.exposes.backlightModeOffNormalInverted().withAccess(ea.STATE_SET)],
meta: {
multiEndpoint: true,
tuyaDatapoints: [
Expand All @@ -1313,6 +1320,8 @@ const definitions: Definition[] = [
[8, 'brightness_l2', tuya.valueConverter.scale0_254to0_1000],
[15, 'state_l3', tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}],
[16, 'brightness_l3', tuya.valueConverter.scale0_254to0_1000],
[14, 'power_on_behavior', tuya.valueConverter.powerOnBehaviorEnum],
[21, 'backlight_mode', tuya.valueConverter.backlightMode],
],
},
endpoint: (device) => {
Expand Down
1 change: 1 addition & 0 deletions src/lib/tuya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ export const valueConverter = {
onOff: valueConverterBasic.lookup({'ON': true, 'OFF': false}),
powerOnBehavior: valueConverterBasic.lookup({'off': 0, 'on': 1, 'previous': 2}),
powerOnBehaviorEnum: valueConverterBasic.lookup({'off': new Enum(0), 'on': new Enum(1), 'previous': new Enum(2)}),
backlightMode: valueConverterBasic.lookup({'off': new Enum(0), 'normal': new Enum(1), 'inverted': new Enum(2)}),
lightType: valueConverterBasic.lookup({'led': 0, 'incandescent': 1, 'halogen': 2}),
countdown: valueConverterBasic.raw(),
scale0_254to0_1000: valueConverterBasic.scale(0, 254, 0, 1000),
Expand Down

0 comments on commit 3d27893

Please sign in to comment.