test_poolex_qline_heatpump.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. from homeassistant.components.binary_sensor import BinarySensorDeviceClass
  2. from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode
  3. from homeassistant.const import UnitOfTemperature
  4. from ..const import POOLEX_QLINE_HEATPUMP_PAYLOAD
  5. from ..helpers import assert_device_properties_set
  6. from ..mixins.binary_sensor import MultiBinarySensorTests
  7. from ..mixins.climate import TargetTemperatureTests
  8. from .base_device_tests import TuyaDeviceTestCase
  9. HVACMODE_DPS = "1"
  10. MODE_DPS = "2"
  11. TEMPERATURE_DPS = "4"
  12. CURRENTTEMP_DPS = "16"
  13. ERROR_DPS = "15"
  14. class TestPoolexQlineHeatpump(
  15. MultiBinarySensorTests,
  16. TargetTemperatureTests,
  17. TuyaDeviceTestCase,
  18. ):
  19. def setUp(self):
  20. self.setUpForConfig("poolex_qline_heatpump.yaml", POOLEX_QLINE_HEATPUMP_PAYLOAD)
  21. self.subject = self.entities.get("climate")
  22. self.setUpTargetTemperature(
  23. TEMPERATURE_DPS,
  24. self.subject,
  25. min=8.0,
  26. max=40.0,
  27. )
  28. self.setUpMultiBinarySensors(
  29. [
  30. {
  31. "dps": ERROR_DPS,
  32. "name": "binary_sensor_water_flow",
  33. "device_class": BinarySensorDeviceClass.PROBLEM,
  34. "testdata": (1, 0),
  35. },
  36. {
  37. "dps": ERROR_DPS,
  38. "name": "binary_sensor_defrost",
  39. "testdata": (2, 0),
  40. },
  41. ],
  42. )
  43. self.mark_secondary(
  44. [
  45. "binary_sensor_water_flow",
  46. "binary_sensor_defrost",
  47. "binary_sensor_problem",
  48. ]
  49. )
  50. def test_supported_features(self):
  51. self.assertEqual(
  52. self.subject.supported_features,
  53. ClimateEntityFeature.TARGET_TEMPERATURE
  54. | ClimateEntityFeature.TURN_OFF
  55. | ClimateEntityFeature.TURN_ON,
  56. )
  57. def test_temperature_unit_returns_celsius(self):
  58. self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
  59. def test_current_temperature(self):
  60. self.dps[CURRENTTEMP_DPS] = 25
  61. self.assertEqual(self.subject.current_temperature, 25)
  62. def test_hvac_mode(self):
  63. self.dps[HVACMODE_DPS] = True
  64. self.dps[MODE_DPS] = "heating"
  65. self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
  66. self.dps[MODE_DPS] = "cold"
  67. self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
  68. self.dps[MODE_DPS] = "mute"
  69. self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT_COOL)
  70. self.dps[HVACMODE_DPS] = False
  71. self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
  72. def test_hvac_modes(self):
  73. self.assertCountEqual(
  74. self.subject.hvac_modes,
  75. [HVACMode.OFF, HVACMode.COOL, HVACMode.HEAT, HVACMode.HEAT_COOL],
  76. )
  77. async def test_hvac_mode_heat(self):
  78. async with assert_device_properties_set(
  79. self.subject._device, {HVACMODE_DPS: True, MODE_DPS: "heating"}
  80. ):
  81. await self.subject.async_set_hvac_mode(HVACMode.HEAT)
  82. async def test_hvac_mode_cool(self):
  83. async with assert_device_properties_set(
  84. self.subject._device, {HVACMODE_DPS: True, MODE_DPS: "cold"}
  85. ):
  86. await self.subject.async_set_hvac_mode(HVACMode.COOL)
  87. async def test_hvac_mode_mute(self):
  88. async with assert_device_properties_set(
  89. self.subject._device, {HVACMODE_DPS: True, MODE_DPS: "mute"}
  90. ):
  91. await self.subject.async_set_hvac_mode(HVACMode.HEAT_COOL)
  92. async def test_turn_off(self):
  93. async with assert_device_properties_set(
  94. self.subject._device, {HVACMODE_DPS: False}
  95. ):
  96. await self.subject.async_set_hvac_mode(HVACMode.OFF)