mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-24 06:42:26 +00:00
* Expand attribute output. #493 If attribute is actually an Object, expand it in the format `topic/key-subkey` in order to keep the same amount of topic levels for predictable parsing. This only expands the first level of contained object. If more expansion are needed a more robust method should be implemented rather than just nesting `if`s. * Fixing whitespace fixing https://travis-ci.org/Koenkk/zigbee2mqtt/builds/507616980 * first time splitting line... obviously Not sure what the proper approach is, but I guess we can put all params on new line. * identation... really... How is that `eslint`? any other requests?
This commit is contained in:
1 parent
bee722c9c4
commit
6d24a49062
1 file changed
+8
-1
+8
-1
@@ -245,7 +245,14 @@ class Controller {
|
||||
this.mqtt.publish(entity.friendlyName, JSON.stringify(messagePayload), options);
|
||||
} else if (settings.get().experimental.output === 'attribute') {
|
||||
Object.keys(messagePayload).forEach((key) => {
|
||||
this.mqtt.publish(`${entity.friendlyName}/${key}`, JSON.stringify(messagePayload[key]), options);
|
||||
if (typeof messagePayload[key] == 'object') {
|
||||
Object.keys(messagePayload[key]).forEach((subKey) => {
|
||||
this.mqtt.publish(`${entity.friendlyName}/${key}-${subKey}`,
|
||||
JSON.stringify(messagePayload[key][subKey]), options);
|
||||
});
|
||||
} else {
|
||||
this.mqtt.publish(`${entity.friendlyName}/${key}`, JSON.stringify(messagePayload[key]), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user