test_weau_pool_heatpump.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. from homeassistant.components.binary_sensor import BinarySensorDeviceClass
  2. from homeassistant.components.climate.const import (
  3. ClimateEntityFeature,
  4. HVACMode,
  5. )
  6. from ..const import WEAU_POOL_HEATPUMP_PAYLOAD
  7. from ..helpers import assert_device_properties_set
  8. from ..mixins.binary_sensor import BasicBinarySensorTests
  9. from ..mixins.climate import TargetTemperatureTests
  10. from .base_device_tests import TuyaDeviceTestCase
  11. POWER_DPS = "1"
  12. TEMPERATURE_DPS = "2"
  13. CURRENTTEMP_DPS = "3"
  14. MODE_DPS = "4"
  15. FAULT_DPS = "6"
  16. class TestWeauPoolHeatpump(
  17. BasicBinarySensorTests,
  18. TargetTemperatureTests,
  19. TuyaDeviceTestCase,
  20. ):
  21. __test__ = True
  22. def setUp(self):
  23. self.setUpForConfig("weau_pool_heatpump.yaml", WEAU_POOL_HEATPUMP_PAYLOAD)
  24. self.subject = self.entities.get("climate")
  25. self.setUpTargetTemperature(
  26. TEMPERATURE_DPS,
  27. self.subject,
  28. min=7,
  29. max=60,
  30. )
  31. self.setUpBasicBinarySensor(
  32. FAULT_DPS,
  33. self.entities.get("binary_sensor_fault"),
  34. device_class=BinarySensorDeviceClass.PROBLEM,
  35. testdata=(4, 0),
  36. )
  37. self.mark_secondary(["binary_sensor_fault"])
  38. def test_supported_features(self):
  39. self.assertEqual(
  40. self.subject.supported_features,
  41. ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE,
  42. )
  43. def test_current_temperature(self):
  44. self.dps[CURRENTTEMP_DPS] = 194
  45. self.assertEqual(self.subject.current_temperature, 19.4)
  46. def test_hvac_mode(self):
  47. self.dps[POWER_DPS] = True
  48. self.dps[MODE_DPS] = "hot"
  49. self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
  50. self.dps[MODE_DPS] = "cold"
  51. self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
  52. self.dps[MODE_DPS] = "auto"
  53. self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT_COOL)
  54. self.dps[MODE_DPS] = "eco"
  55. self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
  56. self.dps[POWER_DPS] = False
  57. self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
  58. def test_hvac_modes(self):
  59. self.assertCountEqual(
  60. self.subject.hvac_modes,
  61. [HVACMode.OFF, HVACMode.COOL, HVACMode.HEAT, HVACMode.HEAT_COOL],
  62. )
  63. async def test_turn_off(self):
  64. async with assert_device_properties_set(
  65. self.subject._device,
  66. {POWER_DPS: False},
  67. ):
  68. await self.subject.async_set_hvac_mode(HVACMode.OFF)
  69. async def test_set_cool(self):
  70. async with assert_device_properties_set(
  71. self.subject._device,
  72. {POWER_DPS: True, MODE_DPS: "cold"},
  73. ):
  74. await self.subject.async_set_hvac_mode(HVACMode.COOL)
  75. async def test_set_heat(self):
  76. async with assert_device_properties_set(
  77. self.subject._device,
  78. {POWER_DPS: True, MODE_DPS: "eco"},
  79. ):
  80. await self.subject.async_set_hvac_mode(HVACMode.HEAT)
  81. async def test_set_auto(self):
  82. async with assert_device_properties_set(
  83. self.subject._device,
  84. {POWER_DPS: True, MODE_DPS: "auto"},
  85. ):
  86. await self.subject.async_set_hvac_mode(HVACMode.HEAT_COOL)
  87. def test_preset_mode(self):
  88. self.dps[MODE_DPS] = "eco"
  89. self.assertEqual(self.subject.preset_mode, "Eco Heat")
  90. self.dps[MODE_DPS] = "hot"
  91. self.assertEqual(self.subject.preset_mode, "Boost Heat")
  92. self.dps[MODE_DPS] = "cold"
  93. self.assertEqual(self.subject.preset_mode, "Cool")
  94. self.dps[MODE_DPS] = "auto"
  95. self.assertEqual(self.subject.preset_mode, "Auto")
  96. def test_preset_modes(self):
  97. self.assertCountEqual(
  98. self.subject.preset_modes,
  99. ["Eco Heat", "Boost Heat", "Cool", "Auto"],
  100. )
  101. async def test_set_preset_to_boost(self):
  102. async with assert_device_properties_set(
  103. self.subject._device,
  104. {MODE_DPS: "hot"},
  105. ):
  106. await self.subject.async_set_preset_mode("Boost Heat")
  107. async def test_set_preset_to_eco(self):
  108. async with assert_device_properties_set(
  109. self.subject._device,
  110. {MODE_DPS: "eco"},
  111. ):
  112. await self.subject.async_set_preset_mode("Eco Heat")
  113. def test_extra_state_attributes(self):
  114. self.dps[FAULT_DPS] = 6
  115. self.assertDictEqual(self.subject.extra_state_attributes, {"fault": 6})