test_madimack_elitev3_heatpump.py 8.9 KB

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