Update zigbee-shepherd-converters to 7.1.11

This commit is contained in:
Koen Kanters
2019-02-23 16:02:45 +01:00
parent 1fda02ae7c
commit 147a130628
4 changed files with 95 additions and 20 deletions
+41 -1
View File
@@ -255,6 +255,18 @@ const configurations = {
optimistic: true,
},
},
'cover_positon': {
type: 'cover',
object_id: 'cover',
discovery_payload: {
command_topic: true,
position_topic: true,
set_position_topic: true,
set_position_template: '{ "position": {{ position }} }',
value_template: '{{ value_json.position }}',
state_topic: false,
},
},
// Lock
'lock': {
@@ -509,6 +521,20 @@ const mapping = {
'E1743': [configurations.sensor_click, configurations.sensor_battery],
'LED1732G11': [configurations.light_brightness_colortemp],
'RB 265': [configurations.light_brightness],
'9290019758': [
configurations.binary_sensor_occupancy, configurations.sensor_temperature,
configurations.sensor_illuminance, configurations.sensor_battery,
],
'HGZB-042': [switchWithPostfix('left'), switchWithPostfix('right')],
'GL-FL-004TZ': [configurations.light_brightness_colortemp_colorxy],
'IM6001-OTP05': [configurations.switch],
'SV01': [
configurations.cover_positon, configurations.sensor_temperature, configurations.sensor_pressure,
configurations.sensor_battery,
],
'316GLEDRF': [configurations.light_brightness],
'LVS-ZB500D': [configurations.light_brightness],
'ST218': [],
};
Object.keys(mapping).forEach((key) => {
@@ -563,7 +589,17 @@ class HomeAssistant {
mapping[mappedModel.model].forEach((config) => {
const topic = `${config.type}/${entityID}/${config.object_id}/config`;
const payload = {...config.discovery_payload};
payload.state_topic = `${settings.get().mqtt.base_topic}/${entity.friendlyName}`;
const stateTopic = `${settings.get().mqtt.base_topic}/${entity.friendlyName}`;
if (!payload.hasOwnProperty('state_topic') || payload.state_topic) {
payload.state_topic = stateTopic;
} else if (payload.hasOwnProperty('state_topic')) {
delete payload.state_topic;
}
if (payload.position_topic) {
payload.position_topic = stateTopic;
}
// Set json_attributes_topic for types which support this
// https://github.com/Koenkk/zigbee2mqtt/issues/840
@@ -616,6 +652,10 @@ class HomeAssistant {
payload.command_topic += 'set';
}
if (payload.set_position_topic && payload.command_topic) {
payload.set_position_topic = payload.command_topic;
}
// Override configuration with user settings.
if (device.hasOwnProperty('homeassistant')) {
const add = (obj) => {
+17 -17
View File
@@ -282,9 +282,9 @@
"dev": true
},
"ajv": {
"version": "6.9.1",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.9.1.tgz",
"integrity": "sha512-XDN92U311aINL77ieWHmqCcNlwjoP5cHXDxIxbf2MaPYuCXOHS7gHH8jktxeK5omgd52XbSTX6a4Piwd1pQmzA==",
"version": "6.9.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.9.2.tgz",
"integrity": "sha512-4UFy0/LgDo7Oa/+wOAlj44tp9K78u38E5/359eSrqEp1Z5PdVfimCcs7SluXMP755RUQu6d2b4AvF0R1C9RZjg==",
"dev": true,
"requires": {
"fast-deep-equal": "^2.0.1",
@@ -1918,9 +1918,9 @@
}
},
"es5-ext": {
"version": "0.10.47",
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.47.tgz",
"integrity": "sha512-/1TItLfj+TTfWoeRcDn/0FbGV6SNo4R+On2GGVucPU/j3BWnXE2Co8h8CTo4Tu34gFJtnmwS9xiScKs4EjZhdw==",
"version": "0.10.48",
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.48.tgz",
"integrity": "sha512-CdRvPlX/24Mj5L4NVxTs4804sxiS2CjVprgCmrgoDkdmjdY4D+ySHa7K3jJf8R40dFg0tIm3z/dk326LrnuSGw==",
"requires": {
"es6-iterator": "~2.0.3",
"es6-symbol": "~3.1.1",
@@ -2693,9 +2693,9 @@
}
},
"homedir-polyfill": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz",
"integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz",
"integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==",
"dev": true,
"requires": {
"parse-passwd": "^1.0.0"
@@ -3324,9 +3324,9 @@
}
},
"mocha": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-6.0.0.tgz",
"integrity": "sha512-A7g9k3yr8oJaXn2IItFnfgjyxFc/LTe6Wwv7FczP+e8G74o9xYNSbMYmCf1ouldRojLrFcOb+z75P6Ak0GX6ug==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-6.0.1.tgz",
"integrity": "sha512-tQzCxWqxSD6Oyg5r7Ptbev0yAMD8p+Vfh4snPFuiUsWqYj0eVYTDT2DkEY307FTj0WRlIWN9rWMMAUzRmijgVQ==",
"dev": true,
"requires": {
"ansi-colors": "3.2.3",
@@ -6108,8 +6108,8 @@
}
},
"zigbee-shepherd": {
"version": "git+https://github.com/Koenkk/zigbee-shepherd.git#620882844089fe47fcb143cbe6eb5cc5a6218e8d",
"from": "git+https://github.com/Koenkk/zigbee-shepherd.git#620882844089fe47fcb143cbe6eb5cc5a6218e8d",
"version": "git+https://github.com/Koenkk/zigbee-shepherd.git#3c5d7b4a3048eed19f71f618b7cc70bb866a2818",
"from": "git+https://github.com/Koenkk/zigbee-shepherd.git#3c5d7b4a3048eed19f71f618b7cc70bb866a2818",
"requires": {
"areq": "^0.2.0",
"busyman": "^0.3.0",
@@ -6135,9 +6135,9 @@
}
},
"zigbee-shepherd-converters": {
"version": "7.1.10",
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-7.1.10.tgz",
"integrity": "sha512-qSfCNZuzB+0znqKLYhs47MWFamTxXa5XSBsLFcJ1ULxAUhHk9iV923I4v3TUIvwfpALo617UtlDfyP9Fy9y/tw==",
"version": "7.1.11",
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-7.1.11.tgz",
"integrity": "sha512-oG8QFj6p+3stiUI1iMV9Orhm7FzUlT/BH+B2kNCXTov1uFZ/esxSUF8U+EwUy+PbmgyGE5N4vJyz3oyKGWaEVA==",
"requires": {
"chai": "*",
"debounce": "*",
+2 -2
View File
@@ -44,8 +44,8 @@
"semver": "*",
"winston": "2.4.2",
"ziee": "*",
"zigbee-shepherd": "git+https://github.com/Koenkk/zigbee-shepherd.git#620882844089fe47fcb143cbe6eb5cc5a6218e8d",
"zigbee-shepherd-converters": "7.1.10",
"zigbee-shepherd": "git+https://github.com/Koenkk/zigbee-shepherd.git#3c5d7b4a3048eed19f71f618b7cc70bb866a2818",
"zigbee-shepherd-converters": "7.1.11",
"zive": "*"
},
"devDependencies": {
+35
View File
@@ -6,6 +6,7 @@ const sandbox = sinon.createSandbox();
const settings = require('../lib/util/settings');
const WSDCGQ11LM = devices.find((d) => d.model === 'WSDCGQ11LM');
const SV01 = devices.find((d) => d.model === 'SV01');
describe('HomeAssistant extension', () => {
let homeassistant = null;
@@ -446,4 +447,38 @@ describe('HomeAssistant extension', () => {
chai.assert.equal(mqtt.publish.getCall(4).args[3], null);
chai.assert.equal(mqtt.publish.getCall(4).args[4], 'homeassistant');
});
it('Should discover devices with cover_position', () => {
let payload = null;
sandbox.stub(settings, 'getDevice').callsFake(() => {
return {friendly_name: 'my_device'};
});
homeassistant.discover('0x12345678', SV01, false);
chai.assert.equal(mqtt.publish.callCount, 5);
// 1
payload = {
name: 'my_device_cover',
command_topic: 'zigbee2mqtt/my_device/set',
position_topic: 'zigbee2mqtt/my_device',
set_position_topic: 'zigbee2mqtt/my_device/set',
set_position_template: '{ "position": {{ position }} }',
value_template: '{{ value_json.position }}',
unique_id: '0x12345678_cover_zigbee2mqtt',
device: {
'identifiers': 'zigbee2mqtt_0x12345678',
'name': 'my_device',
'sw_version': 'Zigbee2mqtt test',
'model': 'Smart vent (SV01)',
'manufacturer': 'Keen Home',
},
availability_topic: 'zigbee2mqtt/bridge/state',
};
chai.assert.deepEqual(JSON.parse(mqtt.publish.getCall(0).args[1]), payload);
chai.assert.deepEqual(mqtt.publish.getCall(0).args[2], {retain: true, qos: 0});
chai.assert.equal(mqtt.publish.getCall(0).args[3], null);
chai.assert.equal(mqtt.publish.getCall(0).args[4], 'homeassistant');
});
});