test_ailrinni_fplock.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from base64 import b64encode
  2. from ..const import AILRINNI_FINGERPRINTLOCK_PAYLOAD
  3. from ..helpers import assert_device_properties_set
  4. from .base_device_tests import TuyaDeviceTestCase
  5. BATTERY_DP = "8"
  6. UNLOCK_FP_DP = "12"
  7. UNLOCK_PWD_DP = "13"
  8. UNLOCK_DYN_DP = "14"
  9. UNLOCK_BLE_DP = "19"
  10. ALERT_DP = "21"
  11. VOLUME_DP = "31"
  12. LOCK_STATE_DP = "47"
  13. TMPPW_CREATE_DP = "51"
  14. TMPPW_DELETE_DP = "52"
  15. TMPPW_MODIFY_DP = "53"
  16. UNLOCK_TMP_DP = "55"
  17. CODESET_DP = "60"
  18. CODE_UNLOCK_DP = "61"
  19. UNLOCK_APP_DP = "62"
  20. UNLOCK_VOICE_DP = "63"
  21. UNLOCK_OFFLINE_DP = "67"
  22. class TestAilrinniFingerprintLock(TuyaDeviceTestCase):
  23. __test__ = True
  24. def setUp(self):
  25. self.setUpForConfig(
  26. "ailrinni_fingerprint_lock.yaml", AILRINNI_FINGERPRINTLOCK_PAYLOAD
  27. )
  28. self.subject = self.entities.get("lock")
  29. self.mark_secondary(
  30. [
  31. "sensor_alert",
  32. "number_lock_volume",
  33. "text_remote_unlock_code",
  34. "text_new_credential",
  35. "text_delete_credential",
  36. "text_modify_credential",
  37. "text_new_temp_password",
  38. "text_delete_temp_password",
  39. "text_modify_temp_password",
  40. "text_sync_credentials",
  41. "text_offline_password_timestamp",
  42. "sensor_used_offline_password",
  43. "sensor_cleared_offline_passwords",
  44. ]
  45. )
  46. async def test_lock(self):
  47. """Test locking the lock."""
  48. expected = b64encode(
  49. b"\x00\x00\x01" + b"12345678" + b"\x00\x00",
  50. ).decode("utf-8")
  51. async with assert_device_properties_set(
  52. self.subject._device,
  53. {CODE_UNLOCK_DP: expected},
  54. ):
  55. await self.subject.async_lock(code="12345678")
  56. async def test_unlock(self):
  57. """Test unlocking the lock."""
  58. expected = b64encode(
  59. b"\x01\x00\x01" + b"12345678" + b"\x00\x00",
  60. ).decode("utf-8")
  61. async with assert_device_properties_set(
  62. self.subject._device,
  63. {CODE_UNLOCK_DP: expected},
  64. ):
  65. await self.subject.async_unlock(code="12345678")