test_zemismart_am25_blind.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. """Tests for the tilt position feature of AM25 roller blind."""
  2. from homeassistant.components.cover import CoverDeviceClass, CoverEntityFeature
  3. from ..const import AM25_ROLLERBLIND_PAYLOAD
  4. from ..helpers import assert_device_properties_set
  5. from .base_device_tests import TuyaDeviceTestCase
  6. COMMAND_DPS = "1"
  7. POSITION_DPS = "2"
  8. CURRENTPOS_DPS = "3"
  9. WORKSTATE_DP = "7"
  10. FAULT_DP = "12"
  11. DIRECTION_DP = "103"
  12. LIMITUP_DP = "104"
  13. LIMITDOWN_DP = "105"
  14. LIMITRESET_DP = "107"
  15. TILTPOS_DP = "109"
  16. class TestAM25Blinds(TuyaDeviceTestCase):
  17. __test__ = True
  18. def setUp(self):
  19. self.setUpForConfig(
  20. "zemismart_am25_rollerblind.yaml",
  21. AM25_ROLLERBLIND_PAYLOAD,
  22. )
  23. self.subject = self.entities["cover_blind"]
  24. self.mark_secondary(
  25. [
  26. "binary_sensor_problem",
  27. "select_direction",
  28. "switch_limit_up",
  29. "switch_limit_down",
  30. "button_reset_limits",
  31. ]
  32. )
  33. def test_device_class_is_blind(self):
  34. self.assertEqual(self.subject.device_class, CoverDeviceClass.BLIND)
  35. def test_supported_features(self):
  36. self.assertEqual(
  37. self.subject.supported_features,
  38. (
  39. CoverEntityFeature.OPEN
  40. | CoverEntityFeature.CLOSE
  41. | CoverEntityFeature.SET_POSITION
  42. | CoverEntityFeature.STOP
  43. | CoverEntityFeature.SET_TILT_POSITION
  44. ),
  45. )
  46. def test_current_cover_tilt_position(self):
  47. self.dps[TILTPOS_DP] = 1
  48. self.assertEqual(self.subject.current_cover_tilt_position, 10)
  49. async def test_set_cover_tilt_position(self):
  50. async with assert_device_properties_set(
  51. self.subject._device,
  52. {TILTPOS_DP: 5},
  53. ):
  54. await self.subject.async_set_cover_tilt_position(50)