Skip to content

Conversation

uvNikita
Copy link
Contributor

Proposed change

Add support for Schneider Electric Smoke Alarms.

Reference to the original issue #1705

Specs: ZB Spec - Smoke Alarm -110422.pdf

image

Additional information

There are two issues from the logs:

  • Home Assistant complains when "y" is set as a duration unit ("Entity is using native unit of measurement 'y' which is not a valid unit for the device class ('duration') it is using; expected one of ['min', 'd', 'h', 's', 'ms'];"
  • "Test mode" switch should probably be under "Diagnostics", but then it fails with "does not have an entity class mapping" error similar to Quirks v2 unable to specify EntityType.DIAGNOSTIC for write_attr_button zha#291

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 Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.19%. Comparing base (70f2e70) to head (e8f34e0).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3897      +/-   ##
==========================================
+ Coverage   91.17%   91.19%   +0.02%     
==========================================
  Files         334      335       +1     
  Lines       10855    10886      +31     
==========================================
+ Hits         9897     9928      +31     
  Misses        958      958              

☔ 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 added 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). labels Feb 26, 2025
@uvNikita
Copy link
Contributor Author

Successfully tested the "test mode" of the smoke alarm. Toggling the switch activates smoke alarm sound.

However, after around 15 seconds, test alarm stops, but the switch entity remains in "on" state. Going into "Manage zigbee device" and re-reading se_test_mode attribute clears the toggle back to "off" state.

So my guess is that ZHA doesn't get updated attribute state. @TheJulianJES is there something I can do to fix this?

@uvNikita uvNikita force-pushed the se/smoke branch 2 times, most recently from 76b7ceb to e810b85 Compare March 13, 2025 13:06
@uvNikita
Copy link
Contributor Author

I added reporting_config to both switches (test_mode and no_disturb_mode) with min_interval=15, max_interval=300, reportable_change=1.

This fixed the issue, now test_mode resets after 15 seconds. I hope this change will not have too big impact on the battery drain of the device?

@uvNikita
Copy link
Contributor Author

Do you have any comments regarding the following issues?

  • Home Assistant complains when "y" is set as a duration unit ("Entity is using native unit of measurement 'y' which is not a valid unit for the device class ('duration') it is using; expected one of ['min', 'd', 'h', 's', 'ms'];"
  • "Test mode" switch should probably be under "Diagnostics", but then it fails with "does not have an entity class mapping" error similar to
    Quirks v2 unable to specify EntityType.DIAGNOSTIC for write_attr_button zha#291

@TheJulianJES TheJulianJES removed the needs reviewer answer An answer from a reviewer is needed (e.g. why a PR isn't acceptable in the current state). label Apr 30, 2025
@TheJulianJES
Copy link
Collaborator

  • Home Assistant complains when "y" is set as a duration unit ("Entity is using native unit of measurement 'y' which is not a valid unit for the device class ('duration') it is using; expected one of ['min', 'd', 'h', 's', 'ms'];"

You'll need to remove the device class for that entity for now. It's a HA thing that years isn't allowed for the duration device class. We'd need an accepted architecture proposal, similar to this, before we can make changes to HA: home-assistant/architecture#1206

  • "Test mode" switch should probably be under "Diagnostics", but then it fails with "does not have an entity class mapping" error

We've generally not categorized switch entities as "diagnostic", as you're actively "configuring" the device with them. Diagnostics is generally reserved for read-only sensors (and alike), but "Test mode" might be a bit of an exception here though. I'd still keep it in configuration for now. If we want to adjust it, we can add a new discovery schema to ZHA here: https://github.com/zigpy/zha/blob/695475a927451524475bdcef90a25177727e2345/zha/application/discovery.py#L206-L215

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.

I think this looks good now. Thanks!

@TheJulianJES TheJulianJES added v2 quirk Quirks using v2 API. Might add custom entities that need translation keys in HA. and removed needs review This PR should be reviewed soon, as it generally looks good. labels Apr 30, 2025
@TheJulianJES TheJulianJES changed the title Add Schneider Electric Smoke Alarms Add Schneider Electric smoke alarms Apr 30, 2025
@TheJulianJES TheJulianJES merged commit d34ae41 into zigpy:dev Apr 30, 2025
9 checks passed
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants