Skip to content

Commit

Permalink
Separately identify GL-C-007-1ID and GL-C-007-2ID. Koenkk/zigbee2mqtt…
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed May 9, 2020
1 parent 7b903a8 commit 8ea2d74
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 74 deletions.
52 changes: 1 addition & 51 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -1320,15 +1320,6 @@ const converters = {
meta.message.transition = meta.message.transition * 3.3;
}

if (meta.mapped.model === 'GL-C-007' && utils.hasEndpoints(meta.device, [11, 13, 15])) {
// GL-C-007 RGBW
if (key === 'state' && value.toUpperCase() === 'OFF' && !meta.options.separate_control) {
await converters.light_onoff_brightness.convertSet(meta.device.getEndpoint(15), key, value, meta);
}

entity = meta.state.white_value === -1 ? meta.device.getEndpoint(11) : meta.device.getEndpoint(15);
}

if (meta.mapped.model === 'GL-C-007/GL-C-008' && utils.hasEndpoints(meta.device, [10, 11, 13])) {
// GL-C-007/GL-C-008 RGBW
if (key === 'state' && value.toUpperCase() === 'OFF') {
Expand Down Expand Up @@ -1361,55 +1352,14 @@ const converters = {
meta.message.transition = meta.message.transition * 3.3;
}

if (key === 'color' && !meta.message.transition) {
if (meta.mapped.model === 'GL-C-007-1ID' && key === 'color' && !meta.message.transition) {
// Always provide a transition when setting color, otherwise CCT to RGB
// doesn't work properly (CCT leds stay on).
meta.message.transition = 0.4;
}

const state = {};

if (meta.mapped.model === 'GL-C-007') {
// GL-C-007 RGBW
if (utils.hasEndpoints(meta.device, [11, 13, 15])) {
if (key === 'white_value') {
// Switch from RGB to white
if (!meta.options.separate_control) {
await meta.device.getEndpoint(15).command('genOnOff', 'on', {});
await meta.device.getEndpoint(11).command('genOnOff', 'off', {});
state.color = xyWhite;
}

const result = await converters.light_brightness.convertSet(
meta.device.getEndpoint(15), key, value, meta,
);
return {
state: {white_value: value, ...result.state, ...state},
readAfterWriteTime: 0,
};
} else {
if (meta.state.white_value !== -1 && !meta.options.separate_control) {
// Switch from white to RGB
await meta.device.getEndpoint(11).command('genOnOff', 'on', {});
await meta.device.getEndpoint(15).command('genOnOff', 'off', {});
state.white_value = -1;
}
}
} else if (utils.hasEndpoints(meta.device, [11, 13])) {
if (key === 'white_value') {
// Switch to white channel
const payload = {colortemp: 500, transtime: getTransition(entity, key, meta).time};
await entity.command('lightingColorCtrl', 'moveToColorTemp', payload, getOptions(meta.mapped));

const result = await converters.light_brightness.convertSet(entity, key, value, meta);
return {
state: {white_value: value, ...result.state, color: xyWhite},
readAfterWriteTime: 0,
};
}
}
}

// GL-C-007/GL-C-008 RGBW
if (meta.mapped.model === 'GL-C-007/GL-C-008' && utils.hasEndpoints(meta.device, [10, 11, 13])) {
if (key === 'white_value') {
Expand Down
30 changes: 26 additions & 4 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -4258,12 +4258,34 @@ const devices = [
supports: 'on/off, brightness, color temperature',
},
{
zigbeeModel: ['GL-C-007'],
model: 'GL-C-007',
fingerprint: [
{type: 'Router', manufacturerName: 'GLEDOPTO', modelID: 'GL-C-007', endpoints: [
{ID: 11, profileID: 49246, deviceID: 528, inputClusters: [0, 3, 4, 5, 6, 8, 768], outputClusters: []},
{ID: 13, profileID: 49246, deviceID: 528, inputClusters: [4096], outputClusters: [4096]},
]},
],
model: 'GL-C-007-1ID', // 1 ID controls white and color together
vendor: 'Gledopto',
description: 'Zigbee LED controller RGBW',
description: 'Zigbee LED controller RGBW (1 ID)',
extend: gledopto.light,
supports: 'on/off, brightness, color, white',
supports: 'on/off, brightness, color temperature, color',
},
{
fingerprint: [
{type: 'Router', manufacturerName: 'GLEDOPTO', modelID: 'GL-C-007', endpoints: [
{ID: 11, profileID: 49246, deviceID: 528, inputClusters: [0, 3, 4, 5, 6, 8, 768], outputClusters: []},
{ID: 13, profileID: 49246, deviceID: 57694, inputClusters: [4096], outputClusters: [4096]},
{ID: 15, profileID: 49246, deviceID: 256, inputClusters: [0, 3, 4, 5, 6, 8, 768], outputClusters: []},
]},
],
model: 'GL-C-007-2ID', // 2 ID controls white and color separate
vendor: 'Gledopto',
description: 'Zigbee LED controller RGBW (2 ID)',
extend: gledopto.light,
supports: 'on/off, brightness, color temperature, color',
endpoint: (device) => {
return {rgb: 11, white: 15};
},
},
{
zigbeeModel: ['GL-S-004ZS'],
Expand Down
40 changes: 21 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,30 @@ function findByDevice(device) {

function fingerprintMatch(fingerprint, device) {
let match =
device.applicationVersion === fingerprint.applicationVersion &&
device.manufacturerID === fingerprint.manufacturerID &&
device.type === fingerprint.type &&
device.dateCode === fingerprint.dateCode &&
device.hardwareVersion === fingerprint.hardwareVersion &&
device.manufacturerName === fingerprint.manufacturerName &&
device.modelID === fingerprint.modelID &&
device.powerSource === fingerprint.powerSource &&
device.softwareBuildID === fingerprint.softwareBuildID &&
device.stackVersion === fingerprint.stackVersion &&
device.stackVersion === fingerprint.stackVersion &&
device.zclVersion === fingerprint.zclVersion &&
arrayEquals(device.endpoints.map((e) => e.ID), fingerprint.endpoints.map((e) => e.ID));

if (match) {
(!fingerprint.applicationVersion || device.applicationVersion === fingerprint.applicationVersion) &&
(!fingerprint.manufacturerID || device.manufacturerID === fingerprint.manufacturerID) &&
(!fingerprint.type || device.type === fingerprint.type) &&
(!fingerprint.dateCode || device.dateCode === fingerprint.dateCode) &&
(!fingerprint.hardwareVersion || device.hardwareVersion === fingerprint.hardwareVersion) &&
(!fingerprint.manufacturerName || device.manufacturerName === fingerprint.manufacturerName) &&
(!fingerprint.modelID || device.modelID === fingerprint.modelID) &&
(!fingerprint.powerSource || device.powerSource === fingerprint.powerSource) &&
(!fingerprint.softwareBuildID || device.softwareBuildID === fingerprint.softwareBuildID) &&
(!fingerprint.stackVersion || device.stackVersion === fingerprint.stackVersion) &&
(!fingerprint.zclVersion || device.zclVersion === fingerprint.zclVersion) &&
(!fingerprint.endpoints ||
arrayEquals(device.endpoints.map((e) => e.ID), fingerprint.endpoints.map((e) => e.ID)));

if (match && fingerprint.endpoints) {
for (const fingerprintEndpoint of fingerprint.endpoints) {
const deviceEndpoint = device.getEndpoint(fingerprintEndpoint.ID);
match = match &&
deviceEndpoint.deviceID === fingerprintEndpoint.deviceID &&
deviceEndpoint.profileID === fingerprintEndpoint.profileID &&
arrayEquals(deviceEndpoint.inputClusters, fingerprintEndpoint.inputClusters) &&
arrayEquals(deviceEndpoint.outputClusters, fingerprintEndpoint.outputClusters);
(!fingerprintEndpoint.deviceID || deviceEndpoint.deviceID === fingerprintEndpoint.deviceID) &&
(!fingerprintEndpoint.profileID || deviceEndpoint.profileID === fingerprintEndpoint.profileID) &&
(!fingerprintEndpoint.inputClusters ||
arrayEquals(deviceEndpoint.inputClusters, fingerprintEndpoint.inputClusters)) &&
(!fingerprintEndpoint.outputClusters ||
arrayEquals(deviceEndpoint.outputClusters, fingerprintEndpoint.outputClusters));
}
}

Expand Down

0 comments on commit 8ea2d74

Please sign in to comment.