Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions zhaquirks/senoro/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module for Senoro quirks implementations."""
43 changes: 43 additions & 0 deletions zhaquirks/senoro/senorowin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Sensoro Window Sensor (TS0601)."""

from zigpy.quirks.v2.homeassistant 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,
translation_key="opening_state",
fallback_name="Opening state",
entity_type=EntityType.STANDARD,
entity_platform=EntityPlatform.SENSOR,
)
.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.

Copy link
Contributor Author

@ChristianGr1974 ChristianGr1974 May 24, 2025

Choose a reason for hiding this comment

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

Honestly I'm not very familiar with the ZHA integration, I just started with it and tried to integrate this device.
I did this by trial and error with a custom quirk under /config/custom_zha_quirks in Home-Assistant. The only important thing here is that you need to be able to read and write boolean on Tuya datapoint 16.

Copy link
Collaborator

@TheJulianJES TheJulianJES May 25, 2025

Choose a reason for hiding this comment

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

Yeah, all good. I've never come across something where you can turn on/off the tamper alarm yourself.

I think a switch for this should be fine then. No device class that's really applicable then. We can maybe set some alarm icon (which could be done here after a quirks bump PR with the quirk is merged to HA).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good!

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Senoro.Win is a window/door contact that can report the open/closed/tilt status (low-power device). At the same time, it offers burglary protection in the form of an alarm. This is sent via Tuya data point 16 (boolean). If the alarm is triggered, the device switches to a normal device and you can write boolean false to data point 16 to deactivate the alarm again.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, okay. That's interesting. I guess this is fine then.

Just curious, what do you mean by "If the alarm is triggered, the device switches to a normal device"?
Like, the sensor won't make any sounds or lights when the alarm is on, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can see the device here: www.senoro.de
It is primarily a door/window sensor that sends the Open/Close/Tilt statuses. The device is battery operated. If a burglar shakes the window or tries to force it open, the device registers this by vibration. The device then makes a very high-frequency sound via a siren (like a smoke detector). From this moment on, it switches to a different mode and allows writing to data point 16 (not possible before) in order to switch off the siren (the alarm) again.

)
.skip_configuration()
.add_to_registry()
)
Loading