test_eberg_qubo_q40hd_heatpump.py 10.0 KB

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