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

[Bug]: Extra attributes being added to devices that don't support them #473

Open
2 tasks done
sparkym3 opened this issue Jan 25, 2025 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@sparkym3
Copy link
Contributor

sparkym3 commented Jan 25, 2025

Version

3.0.0-63

Matter Controller

NA

Steps to reproduce

I noticed this with a basic fan I have, but it seems like it could be more widespread as a similar code signature exists in window covering and possibly others. I can make the code change or leave it up to you, just let me know your thoughts (maybe there was a reason to do some of this and I dont have it set up to test my changes, so I can only make them blind).

Fan example to illustrate problem:
In FanControlServer the FeaturedBase defines all available options to start with

const FeaturedBase = Base.with(
  "Step",
  "MultiSpeed",
  "AirflowDirection",
  "Auto",
);

https://github.com/t0bst4r/home-assistant-matter-hub/blob/v3.0.0-alpha.63/packages/backend/src/matter/behaviors/fan-control-server.ts#L13

but then within FanDevice it does FanControlServer.with(...FanControlFeatures(supportedFeatures)) to check home assistant for the supported features, but then only appends them on (i.e. the ...) rather than replacing everything that was defaulted in previously.
https://github.com/t0bst4r/home-assistant-matter-hub/blob/v3.0.0-alpha.63/packages/backend/src/matter/devices/fan-device.ts#L47

This leads to all of the features being included regardless of whether they are supported on HA. Possible fixes would be to not start with the default in FanControlServer, or alternatively to remove the ... from FanDevice.

State and attributes

HA fan:
supported_features: 48

Bridge state:

  "attributeList": [
    0,
    1,
    2,
    3,
    65533,
    65532,
    65531,
    65529,
    65528
  ],

Relevant log output

Documentation & Issues

  • I have reviewed the documentation and the linked troubleshooting guide.
  • I have searched the issues for a similar problem.
@sparkym3 sparkym3 added the bug Something isn't working label Jan 25, 2025
@t0bst4r
Copy link
Owner

t0bst4r commented Jan 25, 2025

Hello,
thank you for reaching out. I think you got something wrong.

The underlying matter.js library has implemented a specific pattern which I adopted to my needs:

  1. FeaturedBase is just defining which features I want to support in general
  2. FanControlServerBase is my specific implementation extending the FeaturedBase. I need to put all the code into it to handle all features. If not extending the fully featured base, i wouldn't be able to access all the state props or handle all commands.
  3. At the bottom of this file, you'll find the actual FanControlServer which extends my fully featured FanControlServerBase. BUT by using .for(ClusterType(FanControl.Base)), all the features are removed from the class. The implementation stays, but the features are not activated anymore.

So maybe you could describe a bit more in detail, what is actually wrong / not working.

@t0bst4r t0bst4r added waiting for feedback invalid This doesn't seem right labels Jan 25, 2025
@sparkym3
Copy link
Contributor Author

Ok, without being set up to test out code flows I must have missed how that is working. I can give it some more look, but you may be able to spot the issue more quickly.
The true issue you can see from the state and attribute logs above. This specific fan should only have the on and off attributes since the HA features is 48 (16 & 32), but what shows in the bridge and in Google home are the additional attributes that you can see in the bridge state log.
Functionally this means showing the fan speed slider even though it is not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants