Skip to content

Add Senoro door sensor _TZE200_ytx9fudw #4086

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 11 commits into
base: dev
Choose a base branch
from

Conversation

ChristianGr1974
Copy link

@ChristianGr1974 ChristianGr1974 commented May 23, 2025

Proposed change

Support for the window/door contact from Senoro.

Additional information

Currently not supported.
Tested with hardware device as external quirk.

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 May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.20%. Comparing base (81108c4) to head (dc95999).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #4086   +/-   ##
=======================================
  Coverage   91.20%   91.20%           
=======================================
  Files         335      336    +1     
  Lines       10889    10898    +9     
=======================================
+ Hits         9931     9940    +9     
  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.

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.

Thanks for the PR. I've added some comments.

attribute_name="alarm",
entity_type=EntityType.STANDARD,
translation_key="alarm",
fallback_name="Tamper Alarm",
Copy link
Collaborator

Choose a reason for hiding this comment

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

To follow HA naming conventions, only the first word can start with an uppercase character (excluding abbreviations). So, this should be "Tamper alarm".

Suggested change
fallback_name="Tamper Alarm",
fallback_name="Tamper alarm",

Comment on lines +34 to +39
.tuya_switch(
dp_id=16,
attribute_name="alarm",
entity_type=EntityType.STANDARD,
translation_key="alarm",
fallback_name="Tamper Alarm",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the "Tamper alarm" is a switch (and not a binary sensor), what's the difference in device behavior when the switch is on or off?

.tuya_switch(
dp_id=16,
attribute_name="alarm",
entity_type=EntityType.STANDARD,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, should the "Tamper alarm" not be a configuration entity (default for quirks v2 switches) instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is supposed to be a binary sensor, we should also set:

        device_class=BinarySensorDeviceClass.TAMPER,
        entity_type=EntityType.DIAGNOSTIC,
        fallback_name="Tamper",

No translation key is required then, as the default device class name will be used, which is "Tamper".
The fallback name will not be used, but still needs to be present.

Comment on lines +13 to +15
open = 0
closed = 1
tilted = 2
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 make these uppercase to follow other enums:

Suggested change
open = 0
closed = 1
tilted = 2
Open = 0
Closed = 1
Tilted = 2

Due to some ZHA limitations, these are not translateable for now, but we'll work on changing that in the future.
Related PR: zigpy/zha#86

@@ -0,0 +1 @@
"""Module for Senoro quirks implementations."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is a (white-label) Tuya device, let's remove this and put the quirk file (named something like tuya_door.py) in the tuya folder.

Comment on lines +29 to +30
translation_key="opening_state",
fallback_name="Opening state",
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 move translation_key and fallback_name parameters to the bottom, to follow the style with how other quirks v2 entities are defined.

Comment on lines +29 to +30
translation_key="opening_state",
fallback_name="Opening state",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, should we only call this "Opening" or "Door" (removing the "state" part) to better match with other entity names in HA?

@TheJulianJES TheJulianJES added Tuya Request/PR regarding a Tuya device waiting for changes Waiting for changes to the PR labels May 24, 2025
@TheJulianJES TheJulianJES changed the title Add Senoro quirks implementation Add Senoro door sensor _TZE200_ytx9fudw May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tuya Request/PR regarding a Tuya device waiting for changes Waiting for changes to the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants