Update zigbee-shepherd-converters to 8.0.11.

This commit is contained in:
Koen Kanters 2019-03-22 23:37:07 +01:00
parent 0277591085
commit e537784d34
4 changed files with 51 additions and 6 deletions

View File

@ -115,8 +115,9 @@ class DevicePublish {
msg['brightness'] = 0;
}
} else if (converted.cid === 'genLevelCtrl' && converted.cmd === 'moveToLevelWithOnOff') {
msg[_key] = 'ON';
msg['brightness'] = Number(converted.zclData.level);
const brightness = Number(converted.zclData.level);
msg[_key] = brightness === 0 ? 'OFF' : 'ON';
msg['brightness'] = brightness;
} else if (converted.cid === 'genLevelCtrl' && converted.cmd === 'moveToLevel') {
msg['brightness'] = Number(converted.zclData.level);
}

6
npm-shrinkwrap.json generated
View File

@ -6447,9 +6447,9 @@
}
},
"zigbee-shepherd-converters": {
"version": "8.0.10",
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-8.0.10.tgz",
"integrity": "sha512-d45yVA4MIIvNTyw3K3BTUd61GOEP163ePYfKN4tfr+bwBVVhWrtWazQWuaxjxpte23feLc9ft24200KCz0rKhA==",
"version": "8.0.11",
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-8.0.11.tgz",
"integrity": "sha512-w3EmkKhiiNiH8d3K3s8vPm125OfT+vrWVV6rIhPbpMcODzhclL2trSB7IWFlsjxaAVIroHz8DkAUIbscbd3MDw==",
"requires": {
"chai": "*",
"debounce": "*",

View File

@ -46,7 +46,7 @@
"zcl-id": "git+https://github.com/Koenkk/zcl-id.git#4fa75c92424cd070a3bf6e1f4640b1e3ad8f802d",
"ziee": "*",
"zigbee-shepherd": "git+https://github.com/Koenkk/zigbee-shepherd.git#a8b5828200140adf4de83457508576f6879f7ec1",
"zigbee-shepherd-converters": "8.0.10",
"zigbee-shepherd-converters": "8.0.11",
"zive": "*"
},
"devDependencies": {

View File

@ -855,4 +855,48 @@ describe('DevicePublish', () => {
'functional', {}, cfg.default, null, expect.any(Function)
);
});
it('Should turn device off when brightness 0 is send with light_brightness converter', async () => {
zigbee.publish.mockClear();
publishEntityState.mockClear();
zigbee.getDevice = () => ({modelId: 'TRADFRI bulb E27 CWS opal 600lm'});
devicePublish.onMQTTMessage('zigbee2mqtt/0x00000001/set', JSON.stringify({state: 'ON', transition: 1}));
expect(zigbee.publish).toHaveBeenCalledTimes(1);
expect(zigbee.publish).toHaveBeenNthCalledWith(1,
'0x00000001',
'device',
'genLevelCtrl',
'moveToLevelWithOnOff',
'functional',
{level: 255, transtime: 10},
cfg.default,
null,
expect.any(Function));
expect(publishEntityState).toHaveBeenCalledTimes(1);
expect(publishEntityState).toHaveBeenNthCalledWith(1,
'0x00000001',
{state: 'ON', brightness: 255});
});
it('Should turn device off when brightness 0 is send with light_brightness converter', async () => {
zigbee.publish.mockClear();
publishEntityState.mockClear();
zigbee.getDevice = () => ({modelId: 'TRADFRI bulb E27 CWS opal 600lm'});
devicePublish.onMQTTMessage('zigbee2mqtt/0x00000001/set', JSON.stringify({state: 'OFF', transition: 2}));
expect(zigbee.publish).toHaveBeenCalledTimes(1);
expect(zigbee.publish).toHaveBeenNthCalledWith(1,
'0x00000001',
'device',
'genLevelCtrl',
'moveToLevelWithOnOff',
'functional',
{level: 0, transtime: 20},
cfg.default,
null,
expect.any(Function));
expect(publishEntityState).toHaveBeenCalledTimes(1);
expect(publishEntityState).toHaveBeenNthCalledWith(1,
'0x00000001',
{state: 'OFF', brightness: 0});
});
});