test_madimack_elitev3_heatpump.py 8.9 KB

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