test_weau_pool_heatpumpv2.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_HEATPUMPV2_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. MODE_DPS = "2"
  13. TEMPERATURE_DPS = "9"
  14. CURRENTTEMP_DPS = "10"
  15. FAULT_DPS = "20"
  16. UNKNOWN101_DPS = "101"
  17. UNKNOWN102_DPS = "102"
  18. UNKNOWN103_DPS = "103"
  19. UNKNOWN104_DPS = "104"
  20. class TestWeauPoolHeatpumpV2(
  21. BasicBinarySensorTests,
  22. TargetTemperatureTests,
  23. TuyaDeviceTestCase,
  24. ):
  25. __test__ = True
  26. def setUp(self):
  27. self.setUpForConfig("weau_pool_heatpump_v2.yaml", WEAU_POOL_HEATPUMPV2_PAYLOAD)
  28. self.subject = self.entities.get("climate")
  29. self.setUpTargetTemperature(
  30. TEMPERATURE_DPS,
  31. self.subject,
  32. min=7,
  33. max=60,
  34. )
  35. self.setUpBasicBinarySensor(
  36. FAULT_DPS,
  37. self.entities.get("binary_sensor_fault"),
  38. device_class=BinarySensorDeviceClass.PROBLEM,
  39. testdata=(4, 0),
  40. )
  41. self.mark_secondary(["binary_sensor_fault"])
  42. def test_supported_features(self):
  43. self.assertEqual(
  44. self.subject.supported_features, ClimateEntityFeature.TARGET_TEMPERATURE
  45. )
  46. def test_current_temperature(self):
  47. self.dps[CURRENTTEMP_DPS] = 194
  48. self.assertEqual(self.subject.current_temperature, 19.4)
  49. def test_hvac_mode(self):
  50. self.dps[POWER_DPS] = True
  51. self.dps[MODE_DPS] = "eheat"
  52. self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
  53. self.dps[MODE_DPS] = "ecool"
  54. self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
  55. self.dps[POWER_DPS] = False
  56. self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
  57. def test_hvac_modes(self):
  58. self.assertCountEqual(
  59. self.subject.hvac_modes,
  60. [HVACMode.OFF, HVACMode.COOL, HVACMode.HEAT],
  61. )
  62. async def test_turn_off(self):
  63. async with assert_device_properties_set(
  64. self.subject._device,
  65. {POWER_DPS: False},
  66. ):
  67. await self.subject.async_set_hvac_mode(HVACMode.OFF)
  68. async def test_set_cool(self):
  69. async with assert_device_properties_set(
  70. self.subject._device,
  71. {POWER_DPS: True, MODE_DPS: "ecool"},
  72. ):
  73. await self.subject.async_set_hvac_mode(HVACMode.COOL)
  74. async def test_set_heat(self):
  75. async with assert_device_properties_set(
  76. self.subject._device,
  77. {POWER_DPS: True, MODE_DPS: "eheat"},
  78. ):
  79. await self.subject.async_set_hvac_mode(HVACMode.HEAT)
  80. def test_extra_state_attributes(self):
  81. self.dps[FAULT_DPS] = 4
  82. self.dps[UNKNOWN101_DPS] = 101
  83. self.dps[UNKNOWN102_DPS] = 102
  84. self.dps[UNKNOWN103_DPS] = 103
  85. self.dps[UNKNOWN104_DPS] = True
  86. self.assertDictEqual(
  87. self.subject.extra_state_attributes,
  88. {
  89. "fault": "flow_fault",
  90. "unknown_101": 101,
  91. "unknown_102": 102,
  92. "unknown_103": 103,
  93. "unknown_104": True,
  94. },
  95. )