Skip to content

Conversation

@Gatsby-2024
Copy link

Proposed change

Additional information

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

Comment on lines 71 to 88
async def _read_attributes(
self,
attribute_ids: list[t.uint16_t],
*args,
manufacturer: int | t.uint16_t | None = None,
**kwargs,
):
"""Read attributes ZCL foundation command."""
return await super()._read_attributes(
attribute_ids,
*args,
manufacturer=foundation.ZCLHeader.NO_MANUFACTURER_ID,
**kwargs,
)

@property
def _is_manuf_specific(self):
return False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have manufacturer_id_override = foundation.ZCLHeader.NO_MANUFACTURER_ID at the top.
Are you sure this is needed too?

Copy link
Author

@Gatsby-2024 Gatsby-2024 May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that I should delete lines 82 and 75

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 71 to 88. So, does the quirk still work fine if you delete the _read_attributes method and _is_manuf_specific property?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it still works after deletion.I have deleted the code you mentioned

@TheJulianJES
Copy link
Collaborator

Also, keeping the old PR would have been fine. No need to create a new one after making changes.

@codecov
Copy link

codecov bot commented May 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.18%. Comparing base (81108c4) to head (e0daa7d).
⚠️ Report is 76 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4075      +/-   ##
==========================================
+ Coverage   91.20%   92.18%   +0.98%     
==========================================
  Files         335      362      +27     
  Lines       10889    12009    +1120     
==========================================
+ Hits         9931    11071    +1140     
+ Misses        958      938      -20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fgsch
Copy link
Contributor

fgsch commented May 22, 2025

I got some of these myself and will test them against this PR.

)
.number(
SonoffCluster.AttributeDefs.ac_current_max_overload.name,
0xFC11,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this and all instances of 0xFC11 use SonoffCluster.cluster_id?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines 71 to 73
@property
def _is_manuf_specific(self):
return False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed now that manufacturer_id_override: t.uint16_t = .. is used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll revise it together after you reply to me

Comment on lines 71 to 73
@property
def _is_manuf_specific(self):
return False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll revise it together after you reply to me

Comment on lines 111 to 124
.number(
SonoffCluster.AttributeDefs.ac_current_max_overload.name,
0xFC11,
ClusterType.Server,
1,
0.1,
14.0,
0.1,
unit=UnitOfElectricCurrent.AMPERE,
multiplier=0.001,
translation_key="ac_current_max_overload",
device_class=NumberDeviceClass.CURRENT,
fallback_name="AC current max overload",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something, but from a quick look, the values in https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/sonoff.ts#L1866 seem to be shared between the two variants of this device.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, some are the same, but some are different, such as overloadProtection

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right. The wattage/amp is different for the F and G variants.

Comment on lines 107 to 120
.number(
SonoffCluster.AttributeDefs.ac_current_max_overload.name,
SonoffCluster.cluster_id,
ClusterType.Server,
1,
0.1,
17.0,
0.1,
unit=UnitOfElectricCurrent.AMPERE,
multiplier=0.001,
translation_key="ac_current_max_overload",
device_class=NumberDeviceClass.CURRENT,
fallback_name="AC current max overload",
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's explicitly specify what parameter we provide by using keyword arguments, so:

Suggested change
.number(
SonoffCluster.AttributeDefs.ac_current_max_overload.name,
SonoffCluster.cluster_id,
ClusterType.Server,
1,
0.1,
17.0,
0.1,
unit=UnitOfElectricCurrent.AMPERE,
multiplier=0.001,
translation_key="ac_current_max_overload",
device_class=NumberDeviceClass.CURRENT,
fallback_name="AC current max overload",
)
.number(
SonoffCluster.AttributeDefs.ac_current_max_overload.name,
SonoffCluster.cluster_id,
cluster_type=ClusterType.Server,
endpoint_id=1,
min_value=0.1,
max_value=17.0,
step=0.1,
unit=UnitOfElectricCurrent.AMPERE,
multiplier=0.001,
translation_key="ac_current_max_overload",
device_class=NumberDeviceClass.CURRENT,
fallback_name="AC current max overload",
)

Please also apply that to all other quirks v2 methods.

Omitting the parameter name for attribute_name and cluster_id is fine (first two parameters), as that's a common pattern across all our v2 quirks. We should explicitly provide all other names though.
In the future, we'll hopefully enforce this in the zigpy quirks v2 API.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,I have added it

"""Attribute definitions."""

outlet_control_protect_setting = ZCLAttributeDef(
name="outlet_control_protect_setting",
Copy link
Collaborator

@TheJulianJES TheJulianJES May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name doesn't need to be provided here, since we're already using the new-style AttributeDefs.
We'll just use the actual attribute ("value") name.

Please remove it for all ZCLAttributeDef.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,I have removed

@TheJulianJES TheJulianJES added the needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state). label May 26, 2025
@Gatsby-2024
Copy link
Author

@TheJulianJES @fgsch Is there anything else that needs to be modified

@fgsch
Copy link
Contributor

fgsch commented May 28, 2025

@TheJulianJES @fgsch Is there anything else that needs to be modified

You may want to remove cluster_type=ClusterType.Server and endpoint_id=1, as these are the default values. That said, I’d defer to @TheJulianJES for confirmation.

@Gatsby-2024
Copy link
Author

Gatsby-2024 commented Jun 3, 2025

@fgsch You mean that I'm going to delete cluster_type=ClusterType.Server and endpoint_id=1

@fgsch
Copy link
Contributor

fgsch commented Jun 6, 2025

@fgsch You mean that I'm going to delete cluster_type=ClusterType.Server and endpoint_id=1

Yes, those are the default values, so no need to specify them.

@Gatsby-2024
Copy link
Author

@fgsch I have deleted the default value

@fgsch
Copy link
Contributor

fgsch commented Jun 10, 2025

LGTM. Thank you!

@Gatsby-2024
Copy link
Author

@TheJulianJES @fgsch Hi,When can you help me merge

@TheJulianJES TheJulianJES added the needs review This PR should be reviewed soon, as it generally looks good. label Jun 24, 2025
@fgsch
Copy link
Contributor

fgsch commented Sep 6, 2025

@Gatsby-2024 I'm afraid I don't have permissions to merge, so we'll need to wait for @TheJulianJES or someone else to do so.

@Gatsby-2024
Copy link
Author

@TheJulianJES May I ask if there are any other questions? If not, could you help me merge?

@fgsch
Copy link
Contributor

fgsch commented Oct 12, 2025

@Gatsby-2024 please don't add more changes, and in particular other files. Those should go in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review This PR should be reviewed soon, as it generally looks good. needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants