test_madimack_elitev3_heatpump.py 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. from homeassistant.components.climate.const import (
  2. HVAC_MODE_COOL,
  3. HVAC_MODE_HEAT,
  4. HVAC_MODE_HEAT_COOL,
  5. HVAC_MODE_OFF,
  6. SUPPORT_PRESET_MODE,
  7. SUPPORT_TARGET_TEMPERATURE,
  8. )
  9. from homeassistant.const import (
  10. DEVICE_CLASS_POWER_FACTOR,
  11. DEVICE_CLASS_TEMPERATURE,
  12. PERCENTAGE,
  13. STATE_UNAVAILABLE,
  14. TEMP_CELSIUS,
  15. TEMP_FAHRENHEIT,
  16. )
  17. from ..const import MADIMACK_ELITEV3_HEATPUMP_PAYLOAD
  18. from ..helpers import assert_device_properties_set
  19. from ..mixins.climate import TargetTemperatureTests
  20. from ..mixins.sensor import MultiSensorTests
  21. from .base_device_tests import TuyaDeviceTestCase
  22. POWER_DPS = "1"
  23. HVACMODE_DPS = "2"
  24. TEMPERATURE_DPS = "4"
  25. PRESET_DPS = "5"
  26. UNIT_DPS = "6"
  27. UNKNOWN15_DPS = "15"
  28. PWRLEVEL_DPS = "20"
  29. TEMPMAX_DPS = "21"
  30. TEMPMIN_DPS = "22"
  31. COILTEMP_DPS = "23"
  32. EXHAUSTTEMP_DPS = "24"
  33. OUTLETTEMP_DPS = "25"
  34. AMBIENTTEMP_DPS = "26"
  35. UNKNOWN101_DPS = "101"
  36. CURRENTTEMP_DPS = "102"
  37. RETURNGASTEMP_DPS = "103"
  38. COOLCOILTEMP_DPS = "104"
  39. COOLPLATETEMP_DPS = "105"
  40. EEVOPENING_DPS = "106"
  41. UNKNOWN107_DPS = "107"
  42. class TestMadimackEliteV3Heatpump(
  43. MultiSensorTests,
  44. TargetTemperatureTests,
  45. TuyaDeviceTestCase,
  46. ):
  47. __test__ = True
  48. def setUp(self):
  49. self.setUpForConfig(
  50. "madimack_elite_v3_heatpump.yaml",
  51. MADIMACK_ELITEV3_HEATPUMP_PAYLOAD,
  52. )
  53. self.subject = self.entities.get("climate")
  54. self.setUpTargetTemperature(
  55. TEMPERATURE_DPS,
  56. self.subject,
  57. min=18,
  58. max=40,
  59. )
  60. self.setUpMultiSensors(
  61. [
  62. {
  63. "name": "sensor_power_level",
  64. "dps": PWRLEVEL_DPS,
  65. "device_class": DEVICE_CLASS_POWER_FACTOR,
  66. "unit": PERCENTAGE,
  67. },
  68. {
  69. "name": "sensor_evaporator_coil_pipe_temperature",
  70. "dps": COILTEMP_DPS,
  71. "device_class": DEVICE_CLASS_TEMPERATURE,
  72. "unit": TEMP_CELSIUS,
  73. },
  74. {
  75. "name": "sensor_exhaust_gas_temperature",
  76. "dps": EXHAUSTTEMP_DPS,
  77. "device_class": DEVICE_CLASS_TEMPERATURE,
  78. "unit": TEMP_CELSIUS,
  79. },
  80. {
  81. "name": "sensor_outlet_water_temperature",
  82. "dps": OUTLETTEMP_DPS,
  83. "device_class": DEVICE_CLASS_TEMPERATURE,
  84. "unit": TEMP_CELSIUS,
  85. },
  86. {
  87. "name": "sensor_ambient_temperature",
  88. "dps": AMBIENTTEMP_DPS,
  89. "device_class": DEVICE_CLASS_TEMPERATURE,
  90. "unit": TEMP_CELSIUS,
  91. },
  92. {
  93. "name": "sensor_return_gas_temperature",
  94. "dps": RETURNGASTEMP_DPS,
  95. "device_class": DEVICE_CLASS_TEMPERATURE,
  96. "unit": TEMP_CELSIUS,
  97. },
  98. {
  99. "name": "sensor_cooling_coil_pipe_temperature",
  100. "dps": COOLCOILTEMP_DPS,
  101. "device_class": DEVICE_CLASS_TEMPERATURE,
  102. "unit": TEMP_CELSIUS,
  103. },
  104. {
  105. "name": "sensor_cooling_plate_temperature",
  106. "dps": COOLPLATETEMP_DPS,
  107. "device_class": DEVICE_CLASS_TEMPERATURE,
  108. "unit": TEMP_CELSIUS,
  109. },
  110. {
  111. "name": "sensor_eev_opening",
  112. "dps": EEVOPENING_DPS,
  113. },
  114. ]
  115. )
  116. def test_supported_features(self):
  117. self.assertEqual(
  118. self.subject.supported_features,
  119. SUPPORT_PRESET_MODE | SUPPORT_TARGET_TEMPERATURE,
  120. )
  121. def test_icon(self):
  122. self.dps[POWER_DPS] = True
  123. self.dps[HVACMODE_DPS] = "auto"
  124. self.assertEqual(self.subject.icon, "mdi:refresh-auto")
  125. self.dps[HVACMODE_DPS] = "cold"
  126. self.assertEqual(self.subject.icon, "mdi:snowflake")
  127. self.dps[HVACMODE_DPS] = "heating"
  128. self.assertEqual(self.subject.icon, "mdi:hot-tub")
  129. self.dps[POWER_DPS] = False
  130. self.assertEqual(self.subject.icon, "mdi:hvac-off")
  131. def test_temperature_unit(self):
  132. self.dps[UNIT_DPS] = "c"
  133. self.assertEqual(self.subject.temperature_unit, TEMP_CELSIUS)
  134. self.dps[UNIT_DPS] = "f"
  135. self.assertEqual(self.subject.temperature_unit, TEMP_FAHRENHEIT)
  136. def test_minimum_target_temperature(self):
  137. self.dps[TEMPMIN_DPS] = 60
  138. self.assertEqual(self.subject.min_temp, 60)
  139. def test_maximum_target_temperature(self):
  140. self.dps[TEMPMAX_DPS] = 104
  141. self.assertEqual(self.subject.max_temp, 104)
  142. def test_current_temperature(self):
  143. self.dps[CURRENTTEMP_DPS] = 25
  144. self.assertEqual(self.subject.current_temperature, 25)
  145. def test_hvac_mode(self):
  146. self.dps[POWER_DPS] = True
  147. self.dps[HVACMODE_DPS] = "auto"
  148. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT_COOL)
  149. self.dps[HVACMODE_DPS] = "cold"
  150. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_COOL)
  151. self.dps[HVACMODE_DPS] = "heating"
  152. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT)
  153. self.dps[POWER_DPS] = False
  154. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_OFF)
  155. def test_hvac_modes(self):
  156. self.assertCountEqual(
  157. self.subject.hvac_modes,
  158. [HVAC_MODE_OFF, HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL],
  159. )
  160. async def test_set_hvac_mode_to_cool(self):
  161. async with assert_device_properties_set(
  162. self.subject._device,
  163. {POWER_DPS: True, HVACMODE_DPS: "cold"},
  164. ):
  165. await self.subject.async_set_hvac_mode(HVAC_MODE_COOL)
  166. async def test_set_hvac_mode_to_heat(self):
  167. async with assert_device_properties_set(
  168. self.subject._device,
  169. {POWER_DPS: True, HVACMODE_DPS: "heating"},
  170. ):
  171. await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT)
  172. async def test_set_hvac_mode_to_auto(self):
  173. async with assert_device_properties_set(
  174. self.subject._device,
  175. {POWER_DPS: True, HVACMODE_DPS: "auto"},
  176. ):
  177. await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT_COOL)
  178. async def test_set_hvac_mode_to_off(self):
  179. async with assert_device_properties_set(
  180. self.subject._device,
  181. {POWER_DPS: False},
  182. ):
  183. await self.subject.async_set_hvac_mode(HVAC_MODE_OFF)
  184. def test_preset_mode(self):
  185. self.dps[PRESET_DPS] = "silence"
  186. self.assertEqual(self.subject.preset_mode, "Silence")
  187. self.dps[PRESET_DPS] = "power"
  188. self.assertEqual(self.subject.preset_mode, "Perfect")
  189. self.dps[PRESET_DPS] = "boost"
  190. self.assertEqual(self.subject.preset_mode, "Power")
  191. def test_preset_modes(self):
  192. self.assertCountEqual(
  193. self.subject.preset_modes,
  194. ["Silence", "Perfect", "Power"],
  195. )
  196. async def test_set_preset_to_silence(self):
  197. async with assert_device_properties_set(
  198. self.subject._device,
  199. {PRESET_DPS: "silence"},
  200. ):
  201. await self.subject.async_set_preset_mode("Silence")
  202. async def test_set_preset_to_perfect(self):
  203. async with assert_device_properties_set(
  204. self.subject._device,
  205. {PRESET_DPS: "power"},
  206. ):
  207. await self.subject.async_set_preset_mode("Perfect")
  208. async def test_set_preset_to_boost(self):
  209. async with assert_device_properties_set(
  210. self.subject._device,
  211. {PRESET_DPS: "boost"},
  212. ):
  213. await self.subject.async_set_preset_mode("Power")
  214. def test_device_state_attributes(self):
  215. self.dps[UNKNOWN15_DPS] = 15
  216. self.dps[UNKNOWN101_DPS] = 101
  217. self.dps[UNKNOWN107_DPS] = True
  218. self.assertDictEqual(
  219. self.subject.device_state_attributes,
  220. {
  221. "unknown_15": 15,
  222. "unknown_101": 101,
  223. "unknown_107": True,
  224. },
  225. )