Improve MQTT switch support.

This commit is contained in:
Koen Kanters
2018-04-24 19:03:09 +02:00
parent 8673fa27e2
commit e0feacea0b
3 changed files with 11 additions and 4 deletions
+8 -1
View File
@@ -156,7 +156,14 @@ class Controller {
}
// Convert the MQTT message to a Zigbee message.
const json = JSON.parse(message);
let json = null;
try {
json = JSON.parse(message);
} catch (e) {
// Cannot be parsed to JSON, assume state message.
json = {state: message.toString()};
}
Object.keys(json).forEach((key) => {
// Find converter for this key.
const converter = mqtt2zigbee[key];