Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filtered_attributes publishes attributes with 'null' values #10099

Closed
silvanverschuur opened this issue Dec 8, 2021 · 5 comments
Closed

filtered_attributes publishes attributes with 'null' values #10099

silvanverschuur opened this issue Dec 8, 2021 · 5 comments
Labels
problem Something isn't working stale Stale issues

Comments

@silvanverschuur
Copy link

What happened

I'm trying to use the filtered_attributes option to remove attributes from the MQTT payload. The filtered attributes are not removed from the payload as described in the documentation but the values are replaced with null.

What did you expect to happen

I would like to have the attributes removed from the JSON payload instead of null values.

How to reproduce it (minimal and precise)

This is the configuration of one of my devices (devices.yaml):

'0x60a423fffe61d0f3':
  friendly_name: blitzwolf_bw_shp13_1
  filtered_attributes: ["power_outage_memory", "current", "voltage"]
  debounce: 1

MQTT log

zigbee2mqtt/blitzwolf_bw_shp13_1
{"current":null,"energy":1.91,"linkquality":69,"power":34,"power_outage_memory":null,"state":"ON","voltage":null}

zigbee2mqtt/z2m_router_1 {"led":null,"linkquality":72}

Debug info

Zigbee2MQTT version: 1.22.1

@silvanverschuur silvanverschuur added the problem Something isn't working label Dec 8, 2021
@sjorge
Copy link
Sponsor Contributor

sjorge commented Dec 9, 2021

@Koenkk not really sure how this can happen, as we unconditionally delete the attributes listed from the message?

if (entity.settings.filtered_attributes) {
entity.settings.filtered_attributes.forEach((a) => delete message[a]);
}

I've never seen attributes with null value myself, they are either present and set or absent.

@Koenkk
Copy link
Owner

Koenkk commented Dec 9, 2021

Should be fixed now.
Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

@sjorge the filtered attributes were put back in:

override adjustMessageBeforePublish(entity: Device | Group, message: KeyValue): void {
, fixed the ordering now.

@sjorge
Copy link
Sponsor Contributor

sjorge commented Dec 9, 2021

Aah that makes sense, as I don’t run the homeassistent extension I never ran into that.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2022

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale issues label Jan 9, 2022
@silvanverschuur
Copy link
Author

I can confirm it works fine in stable version v1.22.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working stale Stale issues
Projects
None yet
Development

No branches or pull requests

3 participants