Browse Source

Add support for ZX-DB11 doorbell alarm systems

Issue #763
Jason Rumney 2 years ago
parent
commit
aaf9992b6e

+ 1 - 1
ACKNOWLEDGEMENTS.md

@@ -290,7 +290,7 @@ Further device support has been made with the assistance of users.  Please consi
 - [jirijanu](https://github.com/jirijanu) for assisting with support for ZTH08ZTU zigbee temperature and humidity sensors.
 - [AndaPlays](https://github.com/AndaPlays) for assisting with support for Linkoze dual button wall switch.
 - [alexeyatbluescape](https://github.com/alexeyatbluescape) for contributing support for Feit dimmer.
-- [g470258](https://github.com/g470258) for contributing support for Thermex IF water heaters and Russian language translations.
+- [g470258](https://github.com/g470258) for contributing support for Thermex IF water heaters, ZX-DB11 doorbell alarms and Russian language translations.
 - [julianocomg](https://github.com/julianocomg) for contributing support for Adaprox fingerbot plus and 6-way simple switches.
 - [andyrak](https://github.com/andyrak) for assisting with support for Lytmi HDMI sync backlights.
 - [melvanderwal](https://github.com/melvanderwal) for assisting with support for Inkbird iBBQ-4T thermometers.

+ 1 - 0
DEVICES.md

@@ -380,6 +380,7 @@ of device.
 
 ### Alarm control panels
 
+- ZX-DB11 doorbell and alarm system
 - ZX-G30 alarm system
 
 ### Miscellaneous

+ 4 - 3
custom_components/tuya_local/alarm_control_panel.py

@@ -109,6 +109,7 @@ class TuyaLocalAlarmControlPanel(TuyaLocalEntity, AlarmControlPanelEntity):
         await self._alarm_send_command(STATE_ALARM_ARMED_CUSTOM_BYPASS)
 
     async def async_alarm_trigger(self, code=None):
-        if not self._trigger_dp:
-            raise NotImplementedError()
-        await self._trigger_dp.async_set_value(self._device, True)
+        if self._trigger_dp:
+            await self._trigger_dp.async_set_value(self._device, True)
+        else:
+            await self._alarm_send_command(STATE_ALARM_TRIGGERED)

+ 24 - 0
tests/test_alarm_control_panel.py

@@ -39,6 +39,30 @@ async def test_init_entry(hass):
     m_add_entities.assert_called_once()
 
 
+@pytest.mark.asyncio
+async def test_init_entry_as_secondary(hass):
+    """Test initialisation when alarm_control_panel is a secondary entity"""
+    entry = MockConfigEntry(
+        domain=DOMAIN,
+        data={
+            CONF_TYPE: "zx_db11_doorbell_alarm",
+            CONF_DEVICE_ID: "dummy",
+            CONF_PROTOCOL_VERSION: "auto",
+        },
+    )
+    m_add_entities = Mock()
+    m_device = AsyncMock()
+
+    hass.data[DOMAIN] = {"dummy": {"device": m_device}}
+
+    await async_setup_entry(hass, entry, m_add_entities)
+    assert (
+        type(hass.data[DOMAIN]["dummy"]["alarm_control_panel_alarm"])
+        == TuyaLocalAlarmControlPanel
+    )
+    m_add_entities.assert_called_once()
+
+
 @pytest.mark.asyncio
 async def test_init_entry_fails_if_device_has_no_alarm_control_panel(hass):
     """Test initialisation when device has no matching entity"""