Skip to content

Add Sonoff smart plug S60ZBTPF quirk #4031

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

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

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

Copy link

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 93.75000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 91.21%. Comparing base (5556090) to head (59978c8).

Files with missing lines Patch % Lines
zhaquirks/sonoff/s60zbtpf.py 93.75% 2 Missing ⚠️
zhaquirks/sonoff/s60zbtpg.py 93.75% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4031      +/-   ##
==========================================
+ Coverage   91.19%   91.21%   +0.01%     
==========================================
  Files         335      337       +2     
  Lines       10886    10950      +64     
==========================================
+ Hits         9928     9988      +60     
- Misses        958      962       +4     

☔ 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.

@TheJulianJES TheJulianJES changed the title add s60zb Add Sonoff smart plug S60ZBTPF quirk Apr 29, 2025
Copy link
Collaborator

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

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

The quirks look very similar to me. If they are indeed basically the same, we should combine them in one file, e.g. sonoff/plug.py and add the different variants for models in one quirk using applies_to.

Comment on lines +76 to +93
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 should be able to set manufacturer_id_override for the cluster instead.
See as an example:

manufacturer_id_override: t.uint16_t = foundation.ZCLHeader.NO_MANUFACTURER_ID

Comment on lines +76 to +93
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.

Same comment as above here:

We should be able to set manufacturer_id_override for the cluster instead. See as an example:

manufacturer_id_override: t.uint16_t = foundation.ZCLHeader.NO_MANUFACTURER_ID

Comment on lines 28 to 32
# network_led = ZCLAttributeDef(
# name="network_led",
# id=0x0001,
# type=t.Bool,
# )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this attribute not work? If so, it can be removed. We shouldn't add commented code.
If the attribute does work, we can define it here (so just uncomment). We don't have to necessarily add a config entity for all attributes (although it might make sense for this attribute).

Comment on lines 106 to 112
# .enum(
# SonoffCluster.AttributeDefs.network_led.name,
# SonoffNetworkLedSetType,
# 0xFC11,
# translation_key = "network_led",
# fallback_name = "Network led",
# )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Related to the comment above regarding the network_led attribute:
Does this not work? Should this be a switch instead?

.add_to_registry()
)

# class SonoffS60zb(CustomDevice):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this commented line.

@TheJulianJES TheJulianJES added waiting for changes Waiting for changes to the PR v2 quirk Quirks using v2 API. Might add custom entities that need translation keys in HA. labels Apr 29, 2025
@Gatsby-2024 Gatsby-2024 closed this May 9, 2025
@Gatsby-2024 Gatsby-2024 reopened this May 9, 2025
@Gatsby-2024
Copy link
Author

@TheJulianJES I have already made the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 quirk Quirks using v2 API. Might add custom entities that need translation keys in HA. waiting for changes Waiting for changes to the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants