test_eberg_cooly_c35hd.py 8.0 KB

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