test_eberg_qubo_q40hd_heatpump.py 10 KB

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