mirror of
https://github.com/home-assistant/core.git
synced 2026-09-28 02:18:10 -04:00
Add sensor description for Lock state in Switchbot Cloud (#168607)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
co-authored by
Copilot
Joost Lekkerkerker
parent
e1a73fbeed
commit
5a9bb972d0
@@ -113,3 +113,11 @@ HUMIDIFIER2_INFO = Device(
|
||||
deviceType="Humidifier2",
|
||||
hubDeviceId="test-hub-id",
|
||||
)
|
||||
|
||||
LOCK_ULTRA_INFO = Device(
|
||||
version="V1.0",
|
||||
deviceId="lock-id-1",
|
||||
deviceName="Lock Ultra",
|
||||
deviceType="Smart Lock Ultra",
|
||||
hubDeviceId="test-hub-id",
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from switchbot_api import Device
|
||||
|
||||
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN, LockState
|
||||
@@ -18,14 +19,28 @@ from homeassistant.core import HomeAssistant
|
||||
from . import configure_integration
|
||||
|
||||
|
||||
async def test_lock(hass: HomeAssistant, mock_list_devices, mock_get_status) -> None:
|
||||
@pytest.mark.parametrize(
|
||||
("device_info", "test_index"),
|
||||
[
|
||||
("Smart Lock", 0),
|
||||
("Smart Lock Lite", 1),
|
||||
("Smart Lock Pro", 2),
|
||||
("Smart Lock Ultra", 3),
|
||||
("Lock Vision", 4),
|
||||
("Lock Vision Pro", 5),
|
||||
("Smart Lock Pro Wifi", 6),
|
||||
],
|
||||
)
|
||||
async def test_lock(
|
||||
hass: HomeAssistant, mock_list_devices, mock_get_status, device_info, test_index
|
||||
) -> None:
|
||||
"""Test locking and unlocking."""
|
||||
mock_list_devices.return_value = [
|
||||
Device(
|
||||
version="V1.0",
|
||||
deviceId="lock-id-1",
|
||||
deviceName="lock-1",
|
||||
deviceType="Smart Lock",
|
||||
deviceType=device_info,
|
||||
hubDeviceId="test-hub-id",
|
||||
),
|
||||
]
|
||||
@@ -52,16 +67,27 @@ async def test_lock(hass: HomeAssistant, mock_list_devices, mock_get_status) ->
|
||||
assert hass.states.get(lock_id).state == LockState.LOCKED
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_info", "test_index"),
|
||||
[
|
||||
("Smart Lock", 0),
|
||||
("Smart Lock Pro", 1),
|
||||
("Smart Lock Ultra", 2),
|
||||
("Lock Vision", 3),
|
||||
("Lock Vision Pro", 4),
|
||||
("Smart Lock Pro Wifi", 5),
|
||||
],
|
||||
)
|
||||
async def test_lock_open(
|
||||
hass: HomeAssistant, mock_list_devices, mock_get_status
|
||||
hass: HomeAssistant, mock_list_devices, mock_get_status, device_info, test_index
|
||||
) -> None:
|
||||
"""Test lock open."""
|
||||
"""Test locking and unlocking."""
|
||||
mock_list_devices.return_value = [
|
||||
Device(
|
||||
version="V1.0",
|
||||
deviceId="lock-id-1",
|
||||
deviceName="lock-1",
|
||||
deviceType="Smart Lock Pro",
|
||||
deviceType=device_info,
|
||||
hubDeviceId="test-hub-id",
|
||||
),
|
||||
]
|
||||
|
||||
@@ -14,6 +14,7 @@ from homeassistant.helpers import entity_registry as er
|
||||
from . import (
|
||||
CONTACT_SENSOR_INFO,
|
||||
HUB3_INFO,
|
||||
LOCK_ULTRA_INFO,
|
||||
METER_INFO,
|
||||
MOTION_SENSOR_INFO,
|
||||
WATER_DETECTOR_INFO,
|
||||
@@ -32,6 +33,7 @@ from tests.common import snapshot_platform
|
||||
(HUB3_INFO, 3),
|
||||
(MOTION_SENSOR_INFO, 4),
|
||||
(WATER_DETECTOR_INFO, 5),
|
||||
(LOCK_ULTRA_INFO, 5),
|
||||
],
|
||||
)
|
||||
async def test_meter(
|
||||
|
||||
Reference in New Issue
Block a user