Skip to content
Merged
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions zhaquirks/tuya/tuya_door.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Senoro Window Sensor (TS0601)."""

from zigpy.quirks.v2 import EntityPlatform, EntityType
import zigpy.types as t

from zhaquirks.tuya import BatterySize
from zhaquirks.tuya.builder import TuyaQuirkBuilder


class OpeningStateEnum(t.enum8):
"""Enum for opening state."""

Open = 0
Closed = 1
Tilted = 2


(
TuyaQuirkBuilder("_TZE200_ytx9fudw", "TS0601")
.tuya_battery(
dp_id=2,
battery_type=BatterySize.CR2032,
battery_qty=3,
)
.tuya_enum(
dp_id=101,
attribute_name="opening_state",
enum_class=OpeningStateEnum,
entity_type=EntityType.STANDARD,
entity_platform=EntityPlatform.SENSOR,
translation_key="opening",
fallback_name="Opening",
)
.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 this switch cannot be turned on (when it's off) to turn on the alarm manually, we should think about doing the following instead:

Have a binary sensor entity (for dp 16) (with BinarySensorDeviceClass.TAMPER to show nicely in HA) and also provide a "write attribute button" to reset the dp back to 0/clear.
Implementing the button might require us to map the dp with tuya_dp and just use normal binary_sensor and write_attr_button (instead of the Tuya variants), or just use the mapped dp from tuya_binary_sensor then. That might work as well, but I'll take another look at this, since it's not exactly easy.

I think the approach with a binary sensor and button to reset might be a bit nicer than a switch entity though (that you cannot turn on).

I'll come back to this, but the beta cutoff for 2025.6.0 is already tomorrow, so we likely won't make that, as there are still some other things I have to take a look at.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have you had time to think about this?

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we remove the "Tamper alarm" from this initial PR? We can hopefully get the other stuff into 2025.7.0 then.
I've not had much time yet, unfortunately. You can immediately create another PR with the same "Tamper alarm" switch, so it's not forgotten about.

When I get to it, I can try to push/comment the button/binary sensor alternative. But if you can get that working, that'd be great too.

Choose a reason for hiding this comment

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

@TheJulianJES
ok, so I removed the tamper alarm switch. But currently, if the alarm turns on, you can't turn it off. The device activates the alarm for three minutes, then it turns off, or you have to remove the batteries...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I'll come back to you with the button and binary sensor entity for turning off the tamper alarm.

.skip_configuration()
.add_to_registry()
)
Loading