test_goldair_portable_airconditioner.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. from homeassistant.components.climate.const import (
  2. SWING_OFF,
  3. SWING_ON,
  4. )
  5. from ..const import GOLDAIR_PORTABLE_AIR_CONDITIONER_PAYLOAD
  6. from ..mixins.climate import TargetTemperatureTests
  7. from .base_device_tests import TuyaDeviceTestCase
  8. POWER_DP = "1"
  9. TEMPERATURE_DP = "2"
  10. CURRENT_TEMPERATURE_DP = "3"
  11. MODE_DP = "4"
  12. FANMODE_DP = "5"
  13. IONIZER_DP = "11"
  14. SWINGV_DP = "15"
  15. FAULT_DP = "20"
  16. SLEEP_DP = "103"
  17. ONTIMER_DP = "104"
  18. OFFTIMER_DP = "105"
  19. TEMPF_DP = "107"
  20. CURTEMPF_DP = "108"
  21. FEATURE_DP = "109"
  22. SWINGH_DP = "110"
  23. class TestGoldairPortableAir(TargetTemperatureTests, TuyaDeviceTestCase):
  24. __test__ = True
  25. def setUp(self):
  26. self.setUpForConfig(
  27. "goldair_portable_airconditioner.yaml",
  28. GOLDAIR_PORTABLE_AIR_CONDITIONER_PAYLOAD,
  29. )
  30. self.subject = self.entities.get("climate")
  31. self.setUpTargetTemperature(
  32. TEMPERATURE_DP,
  33. self.subject,
  34. min=16.0,
  35. max=31.0,
  36. )
  37. self.mark_secondary(
  38. [
  39. "binary_sensor_problem",
  40. "binary_sensor_tank_full",
  41. "number_on_timer",
  42. "number_off_timer",
  43. "time_on_timer",
  44. "time_off_timer",
  45. ],
  46. )
  47. def test_swing_modes_with_vswing_unavailable(self):
  48. self.dps[FEATURE_DP] = 26
  49. # config should arrange for hswing to move to swing_mode in this case
  50. self.assertCountEqual(self.subject.swing_horizontal_modes, [])
  51. self.assertCountEqual(self.subject.swing_modes, [SWING_OFF, SWING_ON])
  52. def test_swing_modes_with_vswing_available(self):
  53. self.dps[FEATURE_DP] = 27
  54. self.assertCountEqual(self.subject.swing_modes, [SWING_OFF, SWING_ON])
  55. self.assertCountEqual(
  56. self.subject.swing_horizontal_modes, [SWING_OFF, SWING_ON]
  57. )
  58. def test_swing(self):
  59. self.dps[FEATURE_DP] = 27
  60. self.dps[SWINGV_DP] = "on"
  61. self.dps[SWINGH_DP] = True
  62. self.assertEqual(self.subject.swing_mode, SWING_ON)
  63. self.assertEqual(self.subject.swing_horizontal_mode, SWING_ON)
  64. self.dps[SWINGV_DP] = "off"
  65. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  66. self.dps[SWINGH_DP] = False
  67. self.assertEqual(self.subject.swing_horizontal_mode, SWING_OFF)
  68. def test_available(self):
  69. """Override the base class, as this has availability logic."""
  70. pass