Update zigbee-shepherd-converters.

This commit is contained in:
Koen Kanters committed 2019-08-11 14:13:44 +02:00
1 parent f67eeffed6
commit 36e52ba4fb
5 files changed
+83 -20

No files matched your search

+5 -1
View File
@@ -3,6 +3,7 @@ const settings = require('../util/settings');
const zigbeeShepherdConverters = require('zigbee-shepherd-converters');
const logger = require('../util/logger');
const utils = require('../util/utils');
const objectAssignDeep = require(`object-assign-deep`);
const postfixes = utils.getPostfixes();
const topicRegex = new RegExp(`^(.+?)(?:/(${postfixes.join('|')}))?/(get|set)(?:/(.+))?`);
@@ -120,9 +121,12 @@ class DevicePublish {
}
converters = model.toZigbee;
options = model.options || {};
const deviceSettings = settings.getDevice(entity.ID);
options = objectAssignDeep.noMutate({}, model.options, deviceSettings);
} else if (entity.type === 'group') {
converters = groupConverters;
options = objectAssignDeep.noMutate({}, settings.getGroup(entity.ID));
}
// Convert the MQTT message to a Zigbee message.
+2
View File
@@ -848,6 +848,8 @@ const mapping = {
],
'HS1CG-M': [configurations.binary_sensor_gas],
'LVS-SN10ZW_SN11': [configurations.sensor_battery, configurations.binary_sensor_occupancy],
'B00TN589ZG': [configurations.light_brightness],
'PSB19-SW27': [configurations.light_brightness],
};
Object.keys(mapping).forEach((key) => {
+36 -18
View File
@@ -2782,10 +2782,13 @@
}
},
"hosted-git-info": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz",
"integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==",
"dev": true
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.2.tgz",
"integrity": "sha512-CyjlXII6LMsPMyUzxpTt8fzh5QwzGqPmQXgY/Jyf4Zfp27t/FvfhwoE/8laaMUcMy816CkWF20I7NeQhwwY88w==",
"dev": true,
"requires": {
"lru-cache": "^5.1.1"
}
},
"html-encoding-sniffer": {
"version": "1.0.2",
@@ -3868,6 +3871,15 @@
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
"dev": true,
"requires": {
"yallist": "^3.0.2"
}
},
"make-dir": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
@@ -4162,9 +4174,9 @@
"dev": true
},
"node-notifier": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.0.tgz",
"integrity": "sha512-SUDEb+o71XR5lXSTyivXd9J7fCloE3SyP4lSgt3lU2oSANiox+SxlNRGPjDKrwU1YN3ix2KN/VGGCg0t01rttQ==",
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.4.1.tgz",
"integrity": "sha512-p52B+onAEHKW1OF9MGO/S7k/ahGEHfhP5/tvwYzog/5XLYOd8ZuD6vdNZdUuWMONRnKPneXV43v3s6Snx1wsCQ==",
"dev": true,
"requires": {
"growly": "^1.3.0",
@@ -4598,13 +4610,13 @@
"dev": true
},
"prompts": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.1.0.tgz",
"integrity": "sha512-+x5TozgqYdOwWsQFZizE/Tra3fKvAoy037kOyU6cgz84n8f6zxngLOV4O32kTwt9FcLCxAqw0P/c8rOr9y+Gfg==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.2.1.tgz",
"integrity": "sha512-VObPvJiWPhpZI6C5m60XOzTfnYg/xc/an+r9VYymj9WJW3B/DIH+REzjpAACPf8brwPeP+7vz3bIim3S+AaMjw==",
"dev": true,
"requires": {
"kleur": "^3.0.2",
"sisteransi": "^1.0.0"
"kleur": "^3.0.3",
"sisteransi": "^1.0.3"
}
},
"psl": {
@@ -5020,9 +5032,9 @@
"dev": true
},
"sisteransi": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.2.tgz",
"integrity": "sha512-ZcYcZcT69nSLAR2oLN2JwNmLkJEKGooFMCdvOkFrToUt/WfcRWqhIg4P4KwY4dmLbuyXIx4o4YmPsvMRJYJd/w==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.3.tgz",
"integrity": "sha512-SbEG75TzH8G7eVXFSN5f9EExILKfly7SUvVY5DhhYLvfhKqhDFY0OzevWa/zwak0RLRfWS5AvfMWpd9gJvr5Yg==",
"dev": true
},
"slash": {
@@ -5771,9 +5783,9 @@
"dev": true
},
"v8-compile-cache": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz",
"integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
"integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==",
"dev": true
},
"validate-npm-package-license": {
@@ -5993,6 +6005,12 @@
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==",
"dev": true
},
"yallist": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
"integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==",
"dev": true
},
"yargs": {
"version": "12.0.5",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz",
+1 -1
View File
@@ -44,7 +44,7 @@
"semver": "*",
"winston": "2.4.2",
"zigbee-herdsman": "0.5.1",
"zigbee-shepherd-converters": "10.1.9",
"zigbee-shepherd-converters": "10.2.0",
"deep-diff": "*"
},
"devDependencies": {
+39
View File
@@ -947,6 +947,45 @@ describe('DevicePublish', () => {
{color: {x: 0.701, y: 0.299}});
});
it('Should use transition when enabled', async () => {
zigbee.publish.mockClear();
publishEntityState.mockClear();
zigbee.getDevice = () => ({modelId: 'LCT001'});
jest.spyOn(settings, 'getDevice').mockReturnValue({transition: 20});
const msg = {'brightness': 200};
devicePublish.onMQTTMessage('zigbee2mqtt/0x00000020/set', JSON.stringify(msg));
expect(zigbee.publish).toHaveBeenCalledTimes(1);
expect(zigbee.publish.mock.calls[0][2]).toBe('genLevelCtrl');
expect(zigbee.publish.mock.calls[0][3]).toBe('moveToLevelWithOnOff');
expect(zigbee.publish.mock.calls[0][5]).toStrictEqual({level: 200, transtime: 200});
});
it('Should use transition when color temp', async () => {
zigbee.publish.mockClear();
publishEntityState.mockClear();
zigbee.getDevice = () => ({modelId: 'LCT001'});
jest.spyOn(settings, 'getDevice').mockReturnValue({transition: 20});
const msg = {'color_temp': 200};
devicePublish.onMQTTMessage('zigbee2mqtt/0x00000020/set', JSON.stringify(msg));
expect(zigbee.publish).toHaveBeenCalledTimes(1);
expect(zigbee.publish.mock.calls[0][2]).toBe('lightingColorCtrl');
expect(zigbee.publish.mock.calls[0][3]).toBe('moveToColorTemp');
expect(zigbee.publish.mock.calls[0][5]).toStrictEqual({colortemp: 200, transtime: 200});
});
it('Message transition should overrule options transition', async () => {
zigbee.publish.mockClear();
publishEntityState.mockClear();
zigbee.getDevice = () => ({modelId: 'LCT001'});
jest.spyOn(settings, 'getDevice').mockReturnValue({transition: 20});
const msg = {'brightness': 200, 'transition': 10};
devicePublish.onMQTTMessage('zigbee2mqtt/0x00000020/set', JSON.stringify(msg));
expect(zigbee.publish).toHaveBeenCalledTimes(1);
expect(zigbee.publish.mock.calls[0][2]).toBe('genLevelCtrl');
expect(zigbee.publish.mock.calls[0][3]).toBe('moveToLevelWithOnOff');
expect(zigbee.publish.mock.calls[0][5]).toStrictEqual({level: 200, transtime: 100});
});
it('Should set state with brightness before color', async () => {
zigbee.publish.mockClear();
publishEntityState.mockClear();