test_weau_pool_heatpump.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. from homeassistant.components.climate.const import (
  2. HVAC_MODE_HEAT,
  3. HVAC_MODE_OFF,
  4. HVAC_MODE_COOL,
  5. HVAC_MODE_HEAT_COOL,
  6. SUPPORT_TARGET_TEMPERATURE,
  7. )
  8. from homeassistant.const import TEMP_CELSIUS
  9. from ..const import WEAU_POOL_HEATPUMP_PAYLOAD
  10. from ..helpers import assert_device_properties_set
  11. from ..mixins.climate import TargetTemperatureTests
  12. from .base_device_tests import TuyaDeviceTestCase
  13. POWER_DPS = "1"
  14. TEMPERATURE_DPS = "2"
  15. CURRENTTEMP_DPS = "3"
  16. HVACMODE_DPS = "4"
  17. UNKNOWN6_DPS = "6"
  18. class TestWeauPoolHeatpump(
  19. TargetTemperatureTests,
  20. TuyaDeviceTestCase,
  21. ):
  22. __test__ = True
  23. def setUp(self):
  24. self.setUpForConfig("weau_pool_heatpump.yaml", WEAU_POOL_HEATPUMP_PAYLOAD)
  25. self.subject = self.entities.get("climate")
  26. self.setUpTargetTemperature(
  27. TEMPERATURE_DPS,
  28. self.subject,
  29. min=7,
  30. max=60,
  31. )
  32. def test_supported_features(self):
  33. self.assertEqual(
  34. self.subject.supported_features,
  35. SUPPORT_TARGET_TEMPERATURE,
  36. )
  37. def test_current_temperature(self):
  38. self.dps[CURRENTTEMP_DPS] = 194
  39. self.assertEqual(self.subject.current_temperature, 19.4)
  40. def test_hvac_mode(self):
  41. self.dps[POWER_DPS] = True
  42. self.dps[HVACMODE_DPS] = "hot"
  43. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT)
  44. self.dps[HVACMODE_DPS] = "cold"
  45. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_COOL)
  46. self.dps[HVACMODE_DPS] = "auto"
  47. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT_COOL)
  48. def test_hvac_modes(self):
  49. self.assertCountEqual(
  50. self.subject.hvac_modes,
  51. [HVAC_MODE_OFF, HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL],
  52. )
  53. async def test_turn_off(self):
  54. async with assert_device_properties_set(
  55. self.subject._device,
  56. {POWER_DPS: False},
  57. ):
  58. await self.subject.async_set_hvac_mode(HVAC_MODE_OFF)
  59. async def test_set_cool(self):
  60. async with assert_device_properties_set(
  61. self.subject._device,
  62. {POWER_DPS: True, HVACMODE_DPS: "cold"},
  63. ):
  64. await self.subject.async_set_hvac_mode(HVAC_MODE_COOL)
  65. async def test_set_heat(self):
  66. async with assert_device_properties_set(
  67. self.subject._device,
  68. {POWER_DPS: True, HVACMODE_DPS: "hot"},
  69. ):
  70. await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT)
  71. async def test_set_auto(self):
  72. async with assert_device_properties_set(
  73. self.subject._device,
  74. {POWER_DPS: True, HVACMODE_DPS: "auto"},
  75. ):
  76. await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT_COOL)
  77. def test_extra_state_attributes(self):
  78. self.dps[UNKNOWN6_DPS] = 6
  79. self.assertDictEqual(self.subject.extra_state_attributes, {"unknown_6": 6})