test_ailrinni_fplock.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. def setUp(self):
  24. self.setUpForConfig(
  25. "ailrinni_fingerprint_lock.yaml", AILRINNI_FINGERPRINTLOCK_PAYLOAD
  26. )
  27. self.subject = self.entities.get("lock")
  28. self.mark_secondary(
  29. [
  30. "sensor_alert",
  31. "number_lock_volume",
  32. "text_remote_unlock_code",
  33. "text_new_credential",
  34. "text_delete_credential",
  35. "text_modify_credential",
  36. "text_new_temp_password",
  37. "text_delete_temp_password",
  38. "text_modify_temp_password",
  39. "text_sync_credentials",
  40. "text_offline_password_timestamp",
  41. "sensor_used_offline_password",
  42. "sensor_cleared_offline_passwords",
  43. ]
  44. )
  45. async def test_lock(self):
  46. """Test locking the lock."""
  47. expected = b64encode(
  48. b"\x00\x00\x01" + b"12345678" + b"\x00\x00",
  49. ).decode("utf-8")
  50. async with assert_device_properties_set(
  51. self.subject._device,
  52. {CODE_UNLOCK_DP: expected},
  53. ):
  54. await self.subject.async_lock(code="12345678")
  55. async def test_unlock(self):
  56. """Test unlocking the lock."""
  57. expected = b64encode(
  58. b"\x01\x00\x01" + b"12345678" + b"\x00\x00",
  59. ).decode("utf-8")
  60. async with assert_device_properties_set(
  61. self.subject._device,
  62. {CODE_UNLOCK_DP: expected},
  63. ):
  64. await self.subject.async_unlock(code="12345678")