mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-23 22:32:40 +00:00
Add eslint & fixes. #8
This commit is contained in:
1 parent
3872d58561
commit
dec470fb51
6 files changed
+1004
-10
No files matched your search
+7
-6
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user