Add eslint & fixes. #8

This commit is contained in:
Koen Kanters authored and Koenkk committed 2018-04-18 19:10:33 +02:00
1 parent 3872d58561
commit dec470fb51
6 files changed
+1004 -10

No files matched your search

+7 -6
View File
@@ -1,6 +1,7 @@
const MQTT = require('./mqtt');
const Zigbee = require('./zigbee');
const logger = require('./util/logger');
const settings = require('./util/settings');
const deviceMapping = require('./devices');
const zigbee2mqtt = require('./converters/zigbee2mqtt');
const mqtt2zigbee = require('./converters/mqtt2zigbee');
@@ -57,7 +58,7 @@ class Controller {
}
// Map Zigbee modelID to vendor modelID.
const modelID = msg.endpoints[0].device.modelId;
const modelID = message.endpoints[0].device.modelId;
const mappedModel = deviceMapping[modelID];
if (!mappedModel) {
@@ -67,11 +68,11 @@ class Controller {
}
// Find a conveter for this message.
const cid = msg.data.cid;
const converters = zigbee2mqtt.filter((c) => c.devices.includes(mappedModel.model) && c.cid === cid && c.type === msg.type);
const cid = message.data.cid;
const converters = zigbee2mqtt.filter((c) => c.devices.includes(mappedModel.model) && c.cid === cid && c.type === message.type);
if (!converters.length) {
logger.error(`No converter available for '${mappedModel.model}' with cid '${cid}' and type '${msg.type}'`);
logger.error(`No converter available for '${mappedModel.model}' with cid '${cid}' and type '${message.type}'`);
logger.error('Please create an issue on https://github.com/Koenkk/zigbee2mqtt/issues with this message.');
return;
}
@@ -94,7 +95,7 @@ class Controller {
// - If NO payload is returned do nothing. This is for non-standard behaviour
// for e.g. click switches where we need to count number of clicks and detect long presses.
converters.forEach((converter) => {
const payload = converter.convert(msg, publish);
const payload = converter.convert(message, publish);
if (payload) {
this.stateCache[device.ieeeAddr] = {...this.stateCache[device.ieeeAddr], ...payload};
@@ -126,7 +127,7 @@ class Controller {
}
const message = converter(json[key]);
const callback = (error, response) => {
const callback = (error) => {
// Devices do not report when they go off, this ensures state (on/off) is always in sync.
if (!error && key === 'state') {
this.mqtt.publish(friendlyName, JSON.stringify({state: json[key]}), true);