4
0

test_weau_pool_heatpump.py 2.9 KB

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