test_goldair_portable_airconditioner.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. SWINGH_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. SWINGV_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. ],
  44. )
  45. def test_swing_modes_with_vswing_unavailable(self):
  46. self.dps[FEATURE_DP] = 26
  47. self.assertCountEqual(self.subject.swing_modes, [])
  48. self.assertCountEqual(
  49. self.subject.swing_horizontal_modes, [SWING_OFF, SWING_ON]
  50. )
  51. def test_swing_modes_with_vswing_available(self):
  52. self.dps[FEATURE_DP] = 27
  53. self.assertCountEqual(self.subject.swing_modes, [SWING_OFF, SWING_ON])
  54. self.assertCountEqual(
  55. self.subject.swing_horizontal_modes, [SWING_OFF, SWING_ON]
  56. )
  57. def test_swing(self):
  58. self.dps[FEATURE_DP] = 27
  59. self.dps[SWINGH_DP] = "on"
  60. self.dps[SWINGV_DP] = True
  61. self.assertEqual(self.subject.swing_mode, SWING_ON)
  62. self.assertEqual(self.subject.swing_horizontal_mode, SWING_ON)
  63. self.dps[SWINGH_DP] = "off"
  64. self.assertEqual(self.subject.swing_horizontal_mode, SWING_OFF)
  65. self.dps[SWINGV_DP] = False
  66. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  67. def test_available(self):
  68. """Override the base class, as this has availability logic."""
  69. pass