Update zigbee-shepherd-converters to 1.0.0.

This commit is contained in:
Koenkk 2018-06-04 20:03:53 +02:00
parent bb9b6dd550
commit eae8a80588
4 changed files with 18 additions and 17 deletions

View File

@ -2,7 +2,7 @@ const MQTT = require('./mqtt');
const Zigbee = require('./zigbee');
const logger = require('./util/logger');
const settings = require('./util/settings');
const deviceMapping = require('zigbee-shepherd-converters').devices;
const zigbeeShepherdConverters = require('zigbee-shepherd-converters');
const homeassistant = require('./homeassistant');
const objectAssignDeep = require(`object-assign-deep`);
const debug = require('debug')('zigbee2mqtt:controller');
@ -66,8 +66,9 @@ class Controller {
if (settings.get().homeassistant) {
// MQTT discovery of all paired devices on startup.
this.zigbee.getAllClients().forEach((device) => {
if (deviceMapping[device.modelId]) {
homeassistant.discover(device.ieeeAddr, deviceMapping[device.modelId].model, this.mqtt);
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
if (mappedModel) {
homeassistant.discover(device.ieeeAddr, mappedModel.model, this.mqtt);
}
});
}
@ -142,7 +143,7 @@ class Controller {
// Configure reporting for this device.
const ieeeAddr = device.ieeeAddr;
if (ieeeAddr && device.modelId && !this.configuredReport.includes(ieeeAddr)) {
const mappedModel = deviceMapping[device.modelId];
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
if (mappedModel && mappedModel.report) {
this.zigbee.configureReport(ieeeAddr, mappedModel.report);
@ -156,9 +157,9 @@ class Controller {
let friendlyName = 'unknown';
let type = 'unknown';
let friendlyDevice = {model: 'unkown', description: 'unknown'};
if (deviceMapping[device.modelId]) {
friendlyDevice = deviceMapping[device.modelId];
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
if (mappedModel) {
friendlyDevice = mappedModel;
}
if (settings.getDevice(device.ieeeAddr)) {
@ -213,7 +214,7 @@ class Controller {
// Map Zigbee modelID to vendor modelID.
const modelID = message.endpoints[0].device.modelId;
const mappedModel = deviceMapping[modelID];
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(modelID);
if (!mappedModel) {
logger.warn(`Device with modelID '${modelID}' is not supported.`);
@ -290,7 +291,7 @@ class Controller {
this.zigbee.permitJoin(message.toString().toLowerCase() === 'true');
} else if (option === 'devices') {
const devices = this.zigbee.getAllClients().map((device) => {
const mappedModel = deviceMapping[device.modelId];
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
const friendlyDevice = settings.getDevice(device.ieeeAddr);
return {
@ -331,7 +332,7 @@ class Controller {
}
// Find ep for this device
const mappedModel = deviceMapping[this.zigbee.getDevice(deviceID).modelId];
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(this.zigbee.getDevice(deviceID).modelId);
const ep = mappedModel.ep && mappedModel.ep[topicPrefix] ? mappedModel.ep[topicPrefix] : null;
const published = [];

6
npm-shrinkwrap.json generated
View File

@ -2810,9 +2810,9 @@
}
},
"zigbee-shepherd-converters": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-0.2.0.tgz",
"integrity": "sha512-YgbxoR9I+dY+bj6qcbPvp927M50cYS/NsM9e3IVuPDdwkVS7RtNHrP1LlSt6kq3pJNd3vZ8nlTXsAxCi98N1vQ==",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-1.0.0.tgz",
"integrity": "sha512-+n2XO7l/4AEQbmHsipqY+Epu7B3UdneMxcYBN1lb5mzFtnIBUMBKr5ANw+HOEEBLFIXz82/6L5KU5RGorSZatg==",
"dependencies": {
"acorn": {
"version": "5.5.3",

View File

@ -33,11 +33,11 @@ const logDevices = (devices) => {
return result;
}
const vendors = Array.from(new Set(Object.values(deviceMapping).map((d) => d.vendor)));
const vendors = Array.from(new Set(deviceMapping.map((d) => d.vendor)));
vendors.sort();
vendors.forEach((vendor) => {
text += `### ${vendor}\n`;
text += logDevices(Object.values(deviceMapping).filter((d) => d.vendor === vendor));
text += logDevices(deviceMapping.filter((d) => d.vendor === vendor));
text += '\n';
})
@ -93,7 +93,7 @@ const homeassistantConfig = (device) => {
return yml;
}
Object.values(deviceMapping).forEach((device) => {
deviceMapping.forEach((device) => {
text += `### ${device.model}\n`;
text += '```yaml\n'

View File

@ -3,7 +3,7 @@ const devices = require('zigbee-shepherd-converters').devices;
const homeassistant = require('../lib/homeassistant');
let failed = false;
Object.values(devices).forEach((d) => {
devices.forEach((d) => {
if (!homeassistant.mapping[d.model]) {
console.error(`Missing homeassistant mapping for '${d.model}'`);
failed = true;