mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 05:24:29 +00:00
Ensure filtered_attributes and filtered_optimistic are also regex
Bring filtered_attributes and filtered_optimistic in line with the newer filtered_cache. All three of them are now regex matches instead of absolute matches.
This commit is contained in:
+5
-1
@@ -267,7 +267,11 @@ class Controller {
|
||||
|
||||
// Filter mqtt message attributes
|
||||
if (entity.options.filtered_attributes) {
|
||||
entity.options.filtered_attributes.forEach((a) => delete message[a]);
|
||||
for (const property of Object.keys(message)) {
|
||||
if (entity.options.filtered_attributes.find((p) => property.match(p))) {
|
||||
delete message[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.entries(message).length) {
|
||||
|
||||
@@ -256,7 +256,14 @@ export default class Publish extends Extension {
|
||||
}
|
||||
|
||||
// filter out attribute listed in filtered_optimistic
|
||||
entitySettings.filtered_optimistic?.forEach((a) => delete msg[a]);
|
||||
if (entitySettings.filtered_optimistic) {
|
||||
for (const property of Object.keys(msg)) {
|
||||
if (entitySettings.filtered_optimistic.find((p) => property.match(p))) {
|
||||
delete msg[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addToToPublish(re, msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -817,27 +817,27 @@
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"examples": ["temperature", "battery", "action"],
|
||||
"examples": ["^temperature$", "^battery$", "^action$"],
|
||||
"title": "Filtered publish attributes",
|
||||
"description": "Filter attributes from publish payload."
|
||||
"description": "Filter attributes with regex from published payload."
|
||||
},
|
||||
"filtered_cache": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"examples": ["action", "input_actions"],
|
||||
"examples": ["^input_actions$"],
|
||||
"title": "Filtered attributes from cache",
|
||||
"description": "Filter attributes from being added to the cache, this prevents the attribute from being in the published payload when the value didn't change."
|
||||
"description": "Filter attributes with regex from being added to the cache, this prevents the attribute from being in the published payload when the value didn't change."
|
||||
},
|
||||
"filtered_optimistic": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"examples": ["color_mode", "color_temp", "color"],
|
||||
"examples": ["^color_(mode|temp)$", "color"],
|
||||
"title": "Filtered optimistic attributes",
|
||||
"description": "Filter attributes from optimistic publish payload when calling /set. (This has no effect if optimistic is set to false)."
|
||||
"description": "Filter attributes with regex from optimistic publish payload when calling /set. (This has no effect if optimistic is set to false)."
|
||||
},
|
||||
"icon": {
|
||||
"type": "string",
|
||||
|
||||
Reference in New Issue
Block a user