Skip to content

Commit

Permalink
Fix MQTT command with prefix, introduced in #c22f8b3. #387
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Sep 20, 2018
1 parent 7d49e13 commit ade84dc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const objectAssignDeep = require(`object-assign-deep`);

const mqttConfigRegex = new RegExp(`${settings.get().mqtt.base_topic}/bridge/config/\\w+`, 'g');
const mqttDeviceRegex = new RegExp(`${settings.get().mqtt.base_topic}/[\\w\\s\\d.-]+/set`, 'g');
const mqttDevicePrefixRegex = new RegExp(`${settings.get().mqtt.base_topic}/[\\w\\s\\d.-]
+/[\\w\\s\\d.-]+/set`, 'g');
const mqttDevicePrefixRegex = new RegExp(`${settings.get().mqtt.base_topic}/[\\w\\s\\d.-]+/[\\w\\s\\d.-]+/set`, 'g');

const pollInterval = 60 * 1000; // seconds * 1000.
const softResetTimeout = 3600 * 1000; // seconds * 1000.
Expand Down Expand Up @@ -479,7 +478,7 @@ class Controller {
}

handleMQTTMessageDevice(topic, message, withPrefix) {
const friendlyName = topic.split('/').slice(-2)[0];
const friendlyName = topic.split('/').slice(withPrefix ? -3 : -2)[0];
const topicPrefix = withPrefix ? topic.split('/').slice(-3)[0] : '';

// Map friendlyName to deviceID.
Expand Down

0 comments on commit ade84dc

Please sign in to comment.