test_zemismart_am25_blind.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. def setUp(self):
  18. self.setUpForConfig(
  19. "zemismart_am25_rollerblind.yaml",
  20. AM25_ROLLERBLIND_PAYLOAD,
  21. )
  22. self.subject = self.entities["cover_blind"]
  23. self.mark_secondary(
  24. [
  25. "binary_sensor_problem",
  26. "select_direction",
  27. "switch_limit_up",
  28. "switch_limit_down",
  29. "button_reset_limits",
  30. ]
  31. )
  32. def test_device_class_is_blind(self):
  33. self.assertEqual(self.subject.device_class, CoverDeviceClass.BLIND)
  34. def test_supported_features(self):
  35. self.assertEqual(
  36. self.subject.supported_features,
  37. (
  38. CoverEntityFeature.OPEN
  39. | CoverEntityFeature.CLOSE
  40. | CoverEntityFeature.SET_POSITION
  41. | CoverEntityFeature.STOP
  42. | CoverEntityFeature.SET_TILT_POSITION
  43. ),
  44. )
  45. def test_current_cover_tilt_position(self):
  46. self.dps[TILTPOS_DP] = 1
  47. self.assertEqual(self.subject.current_cover_tilt_position, 10)
  48. async def test_set_cover_tilt_position(self):
  49. async with assert_device_properties_set(
  50. self.subject._device,
  51. {TILTPOS_DP: 5},
  52. ):
  53. await self.subject.async_set_cover_tilt_position(50)