mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-25 12:09:53 +00:00
Update zigbee-shepherd-converters 6.0.0. https://github.com/Koenkk/zigbee2mqtt/issues/608
This commit is contained in:
@@ -101,8 +101,11 @@ class DevicePublish {
|
||||
}
|
||||
|
||||
// Determine endpoint to publish to.
|
||||
const endpoint = model.hasOwnProperty('ep') && model.ep.hasOwnProperty(topic.postfix) ?
|
||||
model.ep[topic.postfix] : null;
|
||||
let endpoint = null;
|
||||
if (model.hasOwnProperty('ep')) {
|
||||
const eps = model.ep(device);
|
||||
endpoint = eps.hasOwnProperty(topic.postfix) ? eps[topic.postfix] : null;
|
||||
}
|
||||
|
||||
// For each key in the JSON message find the matching converter.
|
||||
Object.keys(json).forEach((key) => {
|
||||
|
||||
Generated
+3
-3
@@ -4805,9 +4805,9 @@
|
||||
}
|
||||
},
|
||||
"zigbee-shepherd-converters": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-5.0.3.tgz",
|
||||
"integrity": "sha512-dBEAAWniNWWiP5T7anG6uQR19x9dyFIXuoxTT9cMTjPb1fswqGg+Ie8NJhBKcFDVwJyP8gz3hOFuHWJlc/22mw==",
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-6.0.0.tgz",
|
||||
"integrity": "sha512-Azdhl76Zg0TvcBCnR4cyuUr6YkecHOZuJQAZVCLCgBVVJvWNcnkp1gdw/Ms+7UFHGZRVCec2qvTUDang0C0Aag==",
|
||||
"requires": {
|
||||
"debounce": "*",
|
||||
"zcl-id": "*"
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@
|
||||
"rimraf": "*",
|
||||
"winston": "2.4.2",
|
||||
"zigbee-shepherd": "git+https://github.com/Koenkk/zigbee-shepherd.git#ce52ac4131e2a505af6197b4a26d2b5360e4eb80",
|
||||
"zigbee-shepherd-converters": "5.0.3"
|
||||
"zigbee-shepherd-converters": "6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "*",
|
||||
|
||||
@@ -116,6 +116,36 @@ describe('DevicePublish', () => {
|
||||
chai.assert.deepEqual(zigbee.publish.getCall(0).args[5], cfg.default);
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[6], 3);
|
||||
});
|
||||
|
||||
it('Should publish messages to zigbee gledopto with [11,13]', () => {
|
||||
zigbee.publish.resetHistory();
|
||||
zigbee.getDevice = sinon.fake.returns({modelId: 'GLEDOPTO', epList: [11, 13]});
|
||||
devicePublish = new DevicePublish(zigbee, mqtt, null, null);
|
||||
devicePublish.onMQTTMessage('zigbee2mqtt/0x12345678/set', JSON.stringify({state: 'OFF'}));
|
||||
chai.assert.isTrue(zigbee.publish.calledOnce);
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[0], '0x12345678');
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[1], 'genOnOff');
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[2], 'off');
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[3], 'functional');
|
||||
chai.assert.deepEqual(zigbee.publish.getCall(0).args[4], {});
|
||||
chai.assert.deepEqual(zigbee.publish.getCall(0).args[5], cfg.default);
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[6], null);
|
||||
});
|
||||
|
||||
it('Should publish messages to zigbee gledopto with [11,12,13]', () => {
|
||||
zigbee.publish.resetHistory();
|
||||
zigbee.getDevice = sinon.fake.returns({modelId: 'GLEDOPTO', epList: [11, 12, 13]});
|
||||
devicePublish = new DevicePublish(zigbee, mqtt, null, null);
|
||||
devicePublish.onMQTTMessage('zigbee2mqtt/0x12345678/set', JSON.stringify({state: 'OFF'}));
|
||||
chai.assert.isTrue(zigbee.publish.calledOnce);
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[0], '0x12345678');
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[1], 'genOnOff');
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[2], 'off');
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[3], 'functional');
|
||||
chai.assert.deepEqual(zigbee.publish.getCall(0).args[4], {});
|
||||
chai.assert.deepEqual(zigbee.publish.getCall(0).args[5], cfg.default);
|
||||
chai.assert.strictEqual(zigbee.publish.getCall(0).args[6], 12);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Parse topic', () => {
|
||||
|
||||
@@ -7,6 +7,7 @@ const devices = require('zigbee-shepherd-converters').devices;
|
||||
|
||||
// Devices
|
||||
const WXKG11LM = devices.find((d) => d.model === 'WXKG11LM');
|
||||
const WXKG02LM = devices.find((d) => d.model === 'WXKG02LM');
|
||||
|
||||
const mqtt = {
|
||||
log: () => {},
|
||||
@@ -20,14 +21,17 @@ describe('DeviceReceive', () => {
|
||||
let deviceReceive;
|
||||
let publishDeviceState;
|
||||
|
||||
beforeEach(() => {
|
||||
publishDeviceState = sinon.spy();
|
||||
deviceReceive = new DeviceReceive(null, mqtt, null, publishDeviceState);
|
||||
before(() => {
|
||||
sinon.stub(settings, 'addDevice').callsFake(() => {});
|
||||
sinon.stub(logger, 'info').callsFake(() => {});
|
||||
sinon.stub(logger, 'warn').callsFake(() => {});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
publishDeviceState = sinon.spy();
|
||||
deviceReceive = new DeviceReceive(null, mqtt, null, publishDeviceState);
|
||||
});
|
||||
|
||||
describe('Handling zigbee messages', () => {
|
||||
it('Should handle a zigbee message', () => {
|
||||
const device = {ieeeAddr: '0x12345678'};
|
||||
@@ -36,5 +40,21 @@ describe('DeviceReceive', () => {
|
||||
chai.assert.isTrue(publishDeviceState.calledOnce);
|
||||
chai.assert.deepEqual(publishDeviceState.getCall(0).args[1], {click: 'single'});
|
||||
});
|
||||
|
||||
it('Should handle a zigbee message which uses ep (left)', () => {
|
||||
const device = {ieeeAddr: '0x12345678', epId: 1};
|
||||
const message = msg(device, 'genOnOff', 'attReport', {onOff: 1});
|
||||
deviceReceive.onZigbeeMessage(message, device, WXKG02LM);
|
||||
chai.assert.isTrue(publishDeviceState.calledOnce);
|
||||
chai.assert.deepEqual(publishDeviceState.getCall(0).args[1], {click: 'left'});
|
||||
});
|
||||
|
||||
it('Should handle a zigbee message which uses ep (right)', () => {
|
||||
const device = {ieeeAddr: '0x12345678', epId: 2};
|
||||
const message = msg(device, 'genOnOff', 'attReport', {onOff: 1});
|
||||
deviceReceive.onZigbeeMessage(message, device, WXKG02LM);
|
||||
chai.assert.isTrue(publishDeviceState.calledOnce);
|
||||
chai.assert.deepEqual(publishDeviceState.getCall(0).args[1], {click: 'right'});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user