test_eberg_cooly_c35hd.py 8.5 KB

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