#3009 allow filtering of mqtt topics and payloads (#3037)

* Allow filtering of attributes in mqtt json payload or published attributes

* Add test for mqtt_attribute_filter

Just doing attribute_and_json should be fine as the code changes are run before this. Doing this tests lets us varify both json or seperate topic get properly filtered.

* Add test for mqtt_attribute_filter on group

* Rename mqtt_attribute_filter to filtered_attributes
This commit is contained in:
Jorge Schrauwen authored and GitHub committed 2020-03-02 20:08:51 +01:00
1 parent 68750fade0
commit 658cc21b4d
4 files changed
+38

No files matched your search

+5
View File
@@ -285,6 +285,11 @@ class Controller {
attributes.forEach((a) => messagePayload.device[a] = device[a]);
}
// filter mqtt message attributes
if (entity.settings.filtered_attributes) {
entity.settings.filtered_attributes.forEach((a) => delete messagePayload[a]);
}
this.eventBus.emit('publishEntityState', {payload: messagePayload, entity});
if (Object.entries(messagePayload).length) {