test_eberg_cooly_c35hd.py 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. from homeassistant.components.climate.const import (
  2. HVAC_MODE_COOL,
  3. HVAC_MODE_DRY,
  4. HVAC_MODE_FAN_ONLY,
  5. HVAC_MODE_HEAT,
  6. HVAC_MODE_OFF,
  7. SUPPORT_FAN_MODE,
  8. SUPPORT_SWING_MODE,
  9. SUPPORT_TARGET_TEMPERATURE,
  10. SWING_OFF,
  11. SWING_VERTICAL,
  12. )
  13. from homeassistant.const import (
  14. STATE_UNAVAILABLE,
  15. TEMP_CELSIUS,
  16. TEMP_FAHRENHEIT,
  17. )
  18. from ..const import EBERG_COOLY_C35HD_PAYLOAD
  19. from ..helpers import assert_device_properties_set
  20. from ..mixins.climate import TargetTemperatureTests
  21. from ..mixins.select import BasicSelectTests
  22. from .base_device_tests import TuyaDeviceTestCase
  23. POWER_DPS = "1"
  24. UNKNOWN4_DPS = "4"
  25. HVACMODE_DPS = "5"
  26. TEMPERATURE_DPS = "6"
  27. FAN_DPS = "8"
  28. UNIT_DPS = "10"
  29. UNKNOWN13_DPS = "13"
  30. UNKNOWN14_DPS = "14"
  31. UNKNOWN15_DPS = "15"
  32. SWING_DPS = "16"
  33. UNKNOWN17_DPS = "17"
  34. TEMPF_DPS = "18"
  35. UNKNOWN19_DPS = "19"
  36. class TestEbergCoolyC35HDHeatpump(
  37. BasicSelectTests, TargetTemperatureTests, TuyaDeviceTestCase
  38. ):
  39. __test__ = True
  40. def setUp(self):
  41. self.setUpForConfig(
  42. "eberg_cooly_c35hd.yaml",
  43. EBERG_COOLY_C35HD_PAYLOAD,
  44. )
  45. self.subject = self.entities.get("climate")
  46. self.setUpTargetTemperature(
  47. TEMPERATURE_DPS,
  48. self.subject,
  49. min=13,
  50. max=32,
  51. )
  52. self.setUpBasicSelect(
  53. UNIT_DPS,
  54. self.entities.get("select_temperature_unit"),
  55. {
  56. True: "Fahrenheit",
  57. False: "Celsius",
  58. },
  59. )
  60. self.mark_secondary(["select_temperature_unit"])
  61. def test_supported_features(self):
  62. self.assertEqual(
  63. self.subject.supported_features,
  64. (SUPPORT_TARGET_TEMPERATURE | SUPPORT_FAN_MODE | SUPPORT_SWING_MODE),
  65. )
  66. def test_icon(self):
  67. self.dps[POWER_DPS] = True
  68. self.dps[HVACMODE_DPS] = "1"
  69. self.assertEqual(self.subject.icon, "mdi:fire")
  70. self.dps[HVACMODE_DPS] = "2"
  71. self.assertEqual(self.subject.icon, "mdi:water")
  72. self.dps[HVACMODE_DPS] = "3"
  73. self.assertEqual(self.subject.icon, "mdi:snowflake")
  74. self.dps[HVACMODE_DPS] = "4"
  75. self.assertEqual(self.subject.icon, "mdi:fan")
  76. self.dps[POWER_DPS] = False
  77. self.assertEqual(self.subject.icon, "mdi:hvac-off")
  78. def test_temperature_unit(self):
  79. self.dps[UNIT_DPS] = False
  80. self.assertEqual(self.subject.temperature_unit, TEMP_CELSIUS)
  81. self.dps[UNIT_DPS] = True
  82. self.assertEqual(self.subject.temperature_unit, TEMP_FAHRENHEIT)
  83. def test_minimum_target_temperature_f(self):
  84. self.dps[UNIT_DPS] = True
  85. self.assertEqual(self.subject.min_temp, 55)
  86. def test_maximum_target_temperature_f(self):
  87. self.dps[UNIT_DPS] = True
  88. self.assertEqual(self.subject.max_temp, 90)
  89. def test_temperature_redirects_f(self):
  90. self.dps[UNIT_DPS] = True
  91. self.dps[TEMPERATURE_DPS] = 20
  92. self.dps[TEMPF_DPS] = 90
  93. self.assertEqual(self.subject.target_temperature, 90)
  94. async def test_set_temperature_redirects_f(self):
  95. self.dps[UNIT_DPS] = True
  96. async with assert_device_properties_set(
  97. self.subject._device,
  98. {TEMPF_DPS: 85},
  99. ):
  100. await self.subject.async_set_target_temperature(85)
  101. def test_hvac_mode(self):
  102. self.dps[POWER_DPS] = True
  103. self.dps[HVACMODE_DPS] = "1"
  104. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_HEAT)
  105. self.dps[HVACMODE_DPS] = "2"
  106. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_DRY)
  107. self.dps[HVACMODE_DPS] = "3"
  108. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_COOL)
  109. self.dps[HVACMODE_DPS] = "4"
  110. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_FAN_ONLY)
  111. self.dps[HVACMODE_DPS] = None
  112. self.assertEqual(self.subject.hvac_mode, STATE_UNAVAILABLE)
  113. self.dps[HVACMODE_DPS] = "3"
  114. self.dps[POWER_DPS] = False
  115. self.assertEqual(self.subject.hvac_mode, HVAC_MODE_OFF)
  116. def test_hvac_modes(self):
  117. self.assertCountEqual(
  118. self.subject.hvac_modes,
  119. [
  120. HVAC_MODE_OFF,
  121. HVAC_MODE_COOL,
  122. HVAC_MODE_DRY,
  123. HVAC_MODE_FAN_ONLY,
  124. HVAC_MODE_HEAT,
  125. ],
  126. )
  127. async def test_set_hvac_mode_to_heat(self):
  128. async with assert_device_properties_set(
  129. self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "1"}
  130. ):
  131. await self.subject.async_set_hvac_mode(HVAC_MODE_HEAT)
  132. async def test_set_hvac_mode_to_dry(self):
  133. async with assert_device_properties_set(
  134. self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "2"}
  135. ):
  136. await self.subject.async_set_hvac_mode(HVAC_MODE_DRY)
  137. async def test_set_hvac_mode_to_cool(self):
  138. async with assert_device_properties_set(
  139. self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "3"}
  140. ):
  141. await self.subject.async_set_hvac_mode(HVAC_MODE_COOL)
  142. async def test_set_hvac_mode_to_fan(self):
  143. async with assert_device_properties_set(
  144. self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "4"}
  145. ):
  146. await self.subject.async_set_hvac_mode(HVAC_MODE_FAN_ONLY)
  147. async def test_turn_off(self):
  148. async with assert_device_properties_set(
  149. self.subject._device, {POWER_DPS: False}
  150. ):
  151. await self.subject.async_set_hvac_mode(HVAC_MODE_OFF)
  152. def test_fan_mode(self):
  153. self.dps[FAN_DPS] = "1"
  154. self.assertEqual(self.subject.fan_mode, "low")
  155. self.dps[FAN_DPS] = "2"
  156. self.assertEqual(self.subject.fan_mode, "medium")
  157. self.dps[FAN_DPS] = "3"
  158. self.assertEqual(self.subject.fan_mode, "high")
  159. self.dps[FAN_DPS] = "0"
  160. self.assertEqual(self.subject.fan_mode, "auto")
  161. def test_fan_modes(self):
  162. self.assertCountEqual(
  163. self.subject.fan_modes,
  164. [
  165. "auto",
  166. "low",
  167. "medium",
  168. "high",
  169. ],
  170. )
  171. async def test_set_fan_mode_to_low(self):
  172. async with assert_device_properties_set(
  173. self.subject._device,
  174. {FAN_DPS: "1"},
  175. ):
  176. await self.subject.async_set_fan_mode("low")
  177. async def test_set_fan_mode_to_medium(self):
  178. async with assert_device_properties_set(
  179. self.subject._device,
  180. {FAN_DPS: "2"},
  181. ):
  182. await self.subject.async_set_fan_mode("medium")
  183. async def test_set_fan_mode_to_high(self):
  184. async with assert_device_properties_set(
  185. self.subject._device,
  186. {FAN_DPS: "3"},
  187. ):
  188. await self.subject.async_set_fan_mode("high")
  189. async def test_set_fan_mode_to_auto(self):
  190. async with assert_device_properties_set(
  191. self.subject._device,
  192. {FAN_DPS: "0"},
  193. ):
  194. await self.subject.async_set_fan_mode("auto")
  195. def test_swing_mode(self):
  196. self.dps[SWING_DPS] = True
  197. self.assertEqual(self.subject.swing_mode, SWING_VERTICAL)
  198. self.dps[SWING_DPS] = False
  199. self.assertEqual(self.subject.swing_mode, SWING_OFF)
  200. def test_swing_modes(self):
  201. self.assertCountEqual(
  202. self.subject.swing_modes,
  203. [
  204. SWING_VERTICAL,
  205. SWING_OFF,
  206. ],
  207. )
  208. async def test_set_swing_mode_to_vertical(self):
  209. async with assert_device_properties_set(
  210. self.subject._device,
  211. {SWING_DPS: True},
  212. ):
  213. await self.subject.async_set_swing_mode(SWING_VERTICAL)
  214. async def test_set_swing_mode_to_off(self):
  215. async with assert_device_properties_set(
  216. self.subject._device,
  217. {SWING_DPS: False},
  218. ):
  219. await self.subject.async_set_swing_mode(SWING_OFF)
  220. def test_extra_state_attributes(self):
  221. self.dps[UNKNOWN4_DPS] = 4
  222. self.dps[UNKNOWN13_DPS] = 13
  223. self.dps[UNKNOWN14_DPS] = 14
  224. self.dps[UNKNOWN15_DPS] = 15
  225. self.dps[UNKNOWN17_DPS] = True
  226. self.dps[UNKNOWN19_DPS] = False
  227. self.assertDictEqual(
  228. self.subject.extra_state_attributes,
  229. {
  230. "unknown_4": 4,
  231. "unknown_13": 13,
  232. "unknown_14": 14,
  233. "unknown_15": 15,
  234. "unknown_17": True,
  235. "unknown_19": False,
  236. },
  237. )