test_eberg_qubo_q40hd_heatpump.py 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. from homeassistant.components.climate.const import (
  2. PRESET_COMFORT,
  3. PRESET_SLEEP,
  4. SWING_OFF,
  5. SWING_VERTICAL,
  6. ClimateEntityFeature,
  7. HVACAction,
  8. HVACMode,
  9. )
  10. from homeassistant.components.number import NumberDeviceClass
  11. from homeassistant.const import UnitOfTemperature, UnitOfTime
  12. from ..const import EBERG_QUBO_Q40HD_PAYLOAD
  13. from ..helpers import assert_device_properties_set
  14. from ..mixins.climate import TargetTemperatureTests
  15. from ..mixins.number import BasicNumberTests
  16. from .base_device_tests import TuyaDeviceTestCase
  17. POWER_DPS = "1"
  18. TEMPERATURE_DPS = "2"
  19. CURRENTTEMP_DPS = "3"
  20. HVACMODE_DPS = "4"
  21. FAN_DPS = "5"
  22. UNIT_DPS = "19"
  23. TIMER_DPS = "22"
  24. PRESET_DPS = "25"
  25. SWING_DPS = "30"
  26. HVACACTION_DPS = "101"
  27. class TestEbergQuboQ40HDHeatpump(
  28. BasicNumberTests, TargetTemperatureTests, TuyaDeviceTestCase
  29. ):
  30. def setUp(self):
  31. self.setUpForConfig(
  32. "eberg_qubo_q40hd_heatpump.yaml",
  33. EBERG_QUBO_Q40HD_PAYLOAD,
  34. )
  35. self.subject = self.entities.get("climate")
  36. self.setUpTargetTemperature(
  37. TEMPERATURE_DPS,
  38. self.subject,
  39. min=17.0,
  40. max=30.0,
  41. )
  42. self.setUpBasicNumber(
  43. TIMER_DPS,
  44. self.entities.get("number_timer"),
  45. max=24,
  46. device_class=NumberDeviceClass.DURATION,
  47. unit=UnitOfTime.HOURS,
  48. )
  49. self.mark_secondary(["number_timer"])
  50. def test_supported_features(self):
  51. self.assertEqual(
  52. self.subject.supported_features,
  53. (
  54. ClimateEntityFeature.TARGET_TEMPERATURE
  55. | ClimateEntityFeature.FAN_MODE
  56. | ClimateEntityFeature.PRESET_MODE
  57. | ClimateEntityFeature.SWING_MODE
  58. | ClimateEntityFeature.TURN_OFF
  59. | ClimateEntityFeature.TURN_ON
  60. ),
  61. )
  62. def test_temperature_unit(self):
  63. self.dps[UNIT_DPS] = "c"
  64. self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
  65. self.dps[UNIT_DPS] = "f"
  66. self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.FAHRENHEIT)
  67. def test_minimum_target_temperature_f(self):
  68. self.dps[UNIT_DPS] = "f"
  69. self.assertEqual(self.subject.min_temp, 63)
  70. def test_maximum_target_temperature_f(self):
  71. self.dps[UNIT_DPS] = "f"
  72. self.assertEqual(self.subject.max_temp, 86)
  73. def test_current_temperature(self):
  74. self.dps[CURRENTTEMP_DPS] = 25
  75. self.assertEqual(self.subject.current_temperature, 25)
  76. def test_hvac_mode(self):
  77. self.dps[POWER_DPS] = True
  78. self.dps[HVACMODE_DPS] = "cold"
  79. self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
  80. self.dps[HVACMODE_DPS] = "hot"
  81. self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
  82. self.dps[HVACMODE_DPS] = "dehumidify"
  83. self.assertEqual(self.subject.hvac_mode, HVACMode.DRY)
  84. self.dps[HVACMODE_DPS] = "cold"
  85. self.dps[POWER_DPS] = False
  86. self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
  87. def test_hvac_modes(self):
  88. self.assertCountEqual(
  89. self.subject.hvac_modes,
  90. [
  91. HVACMode.OFF,
  92. HVACMode.COOL,
  93. HVACMode.DRY,
  94. HVACMode.HEAT,
  95. ],
  96. )
  97. async def test_set_hvac_cool(self):
  98. async with assert_device_properties_set(
  99. self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "cold"}
  100. ):
  101. await self.subject.async_set_hvac_mode(HVACMode.COOL)
  102. async def test_set_hvac_off(self):
  103. async with assert_device_properties_set(
  104. self.subject._device, {POWER_DPS: False}
  105. ):
  106. await self.subject.async_set_hvac_mode(HVACMode.OFF)
  107. async def test_turn_on(self):
  108. async with assert_device_properties_set(
  109. self.subject._device, {POWER_DPS: True}
  110. ):
  111. await self.subject.async_turn_on()
  112. async def test_turn_off(self):
  113. async with assert_device_properties_set(
  114. self.subject._device, {POWER_DPS: False}
  115. ):
  116. await self.subject.async_turn_off()
  117. def test_fan_mode(self):
  118. self.dps[FAN_DPS] = "low"
  119. self.assertEqual(self.subject.fan_mode, "low")
  120. self.dps[FAN_DPS] = "middle"
  121. self.assertEqual(self.subject.fan_mode, "medium")
  122. self.dps[FAN_DPS] = "high"
  123. self.assertEqual(self.subject.fan_mode, "high")
  124. self.dps[FAN_DPS] = "auto"
  125. self.assertEqual(self.subject.fan_mode, "auto")
  126. def test_fan_modes(self):
  127. self.assertCountEqual(
  128. self.subject.fan_modes,
  129. [
  130. "auto",
  131. "low",
  132. "medium",
  133. "high",
  134. ],
  135. )
  136. async def test_set_fan_mode_to_low(self):
  137. async with assert_device_properties_set(
  138. self.subject._device,
  139. {FAN_DPS: "low"},
  140. ):
  141. await self.subject.async_set_fan_mode("low")
  142. async def test_set_fan_mode_to_medium(self):
  143. async with assert_device_properties_set(
  144. self.subject._device,
  145. {FAN_DPS: "middle"},
  146. ):
  147. await self.subject.async_set_fan_mode("medium")
  148. async def test_set_fan_mode_to_high(self):
  149. async with assert_device_properties_set(
  150. self.subject._device,
  151. {FAN_DPS: "high"},
  152. ):
  153. await self.subject.async_set_fan_mode("high")
  154. async def test_set_fan_mode_to_auto(self):
  155. async with assert_device_properties_set(
  156. self.subject._device,
  157. {FAN_DPS: "auto"},
  158. ):
  159. await self.subject.async_set_fan_mode("auto")
  160. def test_swing_mode(self):
  161. self.dps[SWING_DPS] = True
  162. self.assertEqual(self.subject.swing_mode, SWING_VERTICAL)
  163. self.dps[SWING_DPS] = False
  164. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  165. def test_swing_modes(self):
  166. self.assertCountEqual(
  167. self.subject.swing_modes,
  168. [
  169. SWING_VERTICAL,
  170. SWING_OFF,
  171. ],
  172. )
  173. async def test_set_swing_mode_to_vertical(self):
  174. async with assert_device_properties_set(
  175. self.subject._device,
  176. {SWING_DPS: True},
  177. ):
  178. await self.subject.async_set_swing_mode(SWING_VERTICAL)
  179. async def test_set_swing_mode_to_off(self):
  180. async with assert_device_properties_set(
  181. self.subject._device,
  182. {SWING_DPS: False},
  183. ):
  184. await self.subject.async_set_swing_mode(SWING_OFF)
  185. def test_preset_mode(self):
  186. self.dps[PRESET_DPS] = True
  187. self.assertEqual(self.subject.preset_mode, PRESET_SLEEP)
  188. self.dps[PRESET_DPS] = False
  189. self.assertEqual(self.subject.preset_mode, PRESET_COMFORT)
  190. def test_preset_modes(self):
  191. self.assertCountEqual(
  192. self.subject.preset_modes,
  193. [
  194. PRESET_COMFORT,
  195. PRESET_SLEEP,
  196. ],
  197. )
  198. async def test_set_preset_mode_to_sleep(self):
  199. async with assert_device_properties_set(
  200. self.subject._device,
  201. {PRESET_DPS: True},
  202. ):
  203. await self.subject.async_set_preset_mode(PRESET_SLEEP)
  204. async def test_set_preset_mode_to_normal(self):
  205. async with assert_device_properties_set(
  206. self.subject._device,
  207. {PRESET_DPS: False},
  208. ):
  209. await self.subject.async_set_preset_mode(PRESET_COMFORT)
  210. def test_hvac_action(self):
  211. self.dps[POWER_DPS] = True
  212. self.dps[HVACACTION_DPS] = "heat_s"
  213. self.assertEqual(self.subject.hvac_action, HVACAction.HEATING)
  214. self.dps[HVACACTION_DPS] = "hot"
  215. self.assertEqual(self.subject.hvac_action, HVACAction.HEATING)
  216. self.dps[HVACACTION_DPS] = "heating"
  217. self.assertEqual(self.subject.hvac_action, HVACAction.HEATING)
  218. self.dps[HVACACTION_DPS] = "cool_s"
  219. self.assertEqual(self.subject.hvac_action, HVACAction.COOLING)
  220. self.dps[HVACACTION_DPS] = "cooling"
  221. self.assertEqual(self.subject.hvac_action, HVACAction.COOLING)
  222. self.dps[HVACACTION_DPS] = "anti-clockwise"
  223. self.assertEqual(self.subject.hvac_action, HVACAction.FAN)
  224. self.dps[HVACACTION_DPS] = "ventilation"
  225. self.assertEqual(self.subject.hvac_action, HVACAction.FAN)
  226. self.dps[HVACACTION_DPS] = "wind"
  227. self.assertEqual(self.subject.hvac_action, HVACAction.FAN)
  228. self.dps[HVACACTION_DPS] = "appointment"
  229. self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
  230. self.dps[HVACACTION_DPS] = "auto"
  231. self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
  232. self.dps[HVACACTION_DPS] = "auto_clean"
  233. self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
  234. self.dps[HVACACTION_DPS] = "eco"
  235. self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
  236. self.dps[HVACACTION_DPS] = "wet"
  237. self.assertEqual(self.subject.hvac_action, HVACAction.DRYING)
  238. self.dps[HVACACTION_DPS] = "off"
  239. self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
  240. self.dps[POWER_DPS] = False
  241. self.assertEqual(self.subject.hvac_action, HVACAction.OFF)