mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 08:26:41 +01:00
Add alarm control panel support for Tuya WG2 alarm panel (Duosmart C30) (#165837)
This commit is contained in:
committed by
GitHub
parent
0891d814fa
commit
7f33ac72ab
@@ -35,7 +35,13 @@ ALARM: dict[DeviceCategory, tuple[AlarmControlPanelEntityDescription, ...]] = {
|
||||
key=DPCode.MASTER_MODE,
|
||||
name="Alarm",
|
||||
),
|
||||
)
|
||||
),
|
||||
DeviceCategory.WG2: (
|
||||
AlarmControlPanelEntityDescription(
|
||||
key=DPCode.MASTER_MODE,
|
||||
name="Alarm",
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
_TUYA_TO_HA_STATE_MAPPINGS = {
|
||||
|
||||
@@ -1,4 +1,58 @@
|
||||
# serializer version: 1
|
||||
# name: test_platform_setup_and_discovery[alarm_control_panel.c30-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
None,
|
||||
]),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'alarm_control_panel',
|
||||
'entity_category': None,
|
||||
'entity_id': 'alarm_control_panel.c30',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'object_id_base': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'tuya',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <AlarmControlPanelEntityFeature: 11>,
|
||||
'translation_key': None,
|
||||
'unique_id': 'tuya.rirsc4vhpbv2whkp2gwmaster_mode',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_platform_setup_and_discovery[alarm_control_panel.c30-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'changed_by': None,
|
||||
'code_arm_required': False,
|
||||
'code_format': None,
|
||||
'friendly_name': 'C30',
|
||||
'supported_features': <AlarmControlPanelEntityFeature: 11>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'alarm_control_panel.c30',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'disarmed',
|
||||
})
|
||||
# ---
|
||||
# name: test_platform_setup_and_discovery[alarm_control_panel.multifunction_alarm-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
|
||||
@@ -43,8 +43,11 @@ async def test_platform_setup_and_discovery(
|
||||
|
||||
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.ALARM_CONTROL_PANEL])
|
||||
@pytest.mark.parametrize(
|
||||
"mock_device_code",
|
||||
["mal_gyitctrjj1kefxp2"],
|
||||
("mock_device_code", "entity_id"),
|
||||
[
|
||||
("mal_gyitctrjj1kefxp2", "alarm_control_panel.multifunction_alarm"),
|
||||
("wg2_pkhw2vbphv4csrir", "alarm_control_panel.c30"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
("service", "command"),
|
||||
@@ -62,9 +65,9 @@ async def test_service(
|
||||
mock_device: CustomerDevice,
|
||||
service: str,
|
||||
command: dict[str, Any],
|
||||
entity_id: str,
|
||||
) -> None:
|
||||
"""Test service."""
|
||||
entity_id = "alarm_control_panel.multifunction_alarm"
|
||||
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
@@ -82,8 +85,11 @@ async def test_service(
|
||||
|
||||
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.ALARM_CONTROL_PANEL])
|
||||
@pytest.mark.parametrize(
|
||||
"mock_device_code",
|
||||
["mal_gyitctrjj1kefxp2"],
|
||||
("mock_device_code", "entity_id"),
|
||||
[
|
||||
("mal_gyitctrjj1kefxp2", "alarm_control_panel.multifunction_alarm"),
|
||||
("wg2_pkhw2vbphv4csrir", "alarm_control_panel.c30"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
("status_updates", "expected_state"),
|
||||
@@ -131,9 +137,9 @@ async def test_state(
|
||||
mock_device: CustomerDevice,
|
||||
status_updates: dict[str, Any],
|
||||
expected_state: str,
|
||||
entity_id: str,
|
||||
) -> None:
|
||||
"""Test state."""
|
||||
entity_id = "alarm_control_panel.multifunction_alarm"
|
||||
mock_device.status.update(status_updates)
|
||||
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user