mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 23:00:55 +00:00
Improve MQTT switch support.
This commit is contained in:
+8
-1
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user