test_eberg_qubo_q40hd_heatpump.py 9.5 KB

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