Skip to content

Commit

Permalink
Change TuYa Led Controller TS0503A (Koenkk#1446)
Browse files Browse the repository at this point in the history
* Add Aqara D1 1 gang smart switch (with neutral line)

* model: 'QBKG23LM',
  vendor: 'Xiaomi'

* Add Tuya TYZS1L Led Strip Controller

* zigbeeModel: ['TS0503A']
   model: 'TYZS1L'
  vendor: '_TZ3000_c5drg1wn' #unknown

* Update devices.js

* Update .gitignore

* Update devices.js

+ Adjust Aqara 1 Gang Smart Switch (with Neutral wire), model: lumi.switch.b1nacn02

* Add converter for TS0503A

+ Described at: Koenkk/zigbee2mqtt#4020

* Update fromZigbee.js

* Update toZigbee.js

* Update devices.js

* Update toZigbee.js

* Update devices.js

* Update toZigbee.js

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
wolverinevn and Koenkk authored Aug 1, 2020
1 parent 251ea70 commit 9584954
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
.vs/slnx.sqlite
.vs/ProjectSettings.json
.idea
.DS_Store
23 changes: 23 additions & 0 deletions converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -5068,6 +5068,29 @@ const converters = {
return payload;
},
},
tuya_led_controller: {
cluster: 'lightingColorCtrl',
type: ['attributeReport'],
convert: (model, msg, publish, options, meta) => {
const result = {};

if (msg.data['61441']) {
result.brightness = msg.data['61441'];
}

result.color = {};

if (msg.data.hasOwnProperty('currentHue')) {
result.color.hue = precisionRound((msg.data['currentHue'] * 360) / 254, 0);
}

if (msg.data['currentSaturation']) {
result.color.saturation = precisionRound(msg.data['currentSaturation'] / 2.54, 0);
}

return result;
},
},
tuya_dimmer: {
cluster: 'manuSpecificTuyaDimmer',
type: 'commandGetData',
Expand Down
35 changes: 35 additions & 0 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,41 @@ const converters = {
await entity.read('haElectricalMeasurement', [0xf000, 0xf001, 0xf002]);
},
},
tuya_led_controller: {
key: ['state', 'color'],
convertSet: async (entity, key, value, meta) => {
if (key === 'state') {
if (value.toLowerCase() === 'off') {
await entity.command(
'genOnOff', 'offWithEffect', {effectid: 0x01, effectvariant: 0x01}, getOptions(meta.mapped, entity),
);
} else {
const payload = {level: 255, transtime: 0};
await entity.command('genLevelCtrl', 'moveToLevelWithOnOff', payload, getOptions(meta.mapped, entity));
}
return {state: {state: value.toUpperCase()}};
} else if (key === 'color') {
const hue = {};
const saturation = {};

hue.hue = Math.round((value.hue * 254) / 360);
saturation.saturation = Math.round(value.saturation * 2.54);

hue.transtime = saturation.transtime = 0;
hue.direction = 0;

await entity.command('lightingColorCtrl', 'moveToHue', hue, {}, getOptions(meta.mapped, entity));
await entity.command('lightingColorCtrl', 'moveToSaturation', saturation, {}, getOptions(meta.mapped, entity));
}
},
convertGet: async (entity, key, meta) => {
if (key === 'state') {
await entity.read('genOnOff', ['onOff']);
} else if (key === 'color') {
await entity.read('lightingColorCtrl', ['currenthHue', 'currentSaturation']);
}
},
},
tuya_dimmer_state: {
key: ['state'],
convertSet: async (entity, key, value, meta) => {
Expand Down
6 changes: 4 additions & 2 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,10 @@ const devices = [
zigbeeModel: ['TS0503A'],
model: 'TYZS1L',
vendor: 'TuYa',
description: 'Zigbee LED Strip controller RGB + CCT or RGBW',
extend: generic.light_onoff_brightness_colortemp_colorxy,
description: 'Led strip controller HSB',
supports: 'on/off, color (hue/saturation)',
fromZigbee: [fz.on_off, fz.tuya_led_controller],
toZigbee: [tz.tuya_led_controller, tz.ignore_transition, tz.ignore_rate],
},
{
zigbeeModel: ['TS0001'],
Expand Down

0 comments on commit 9584954

Please sign in to comment.