test_eberg_cooly_c35hd.py 8.0 KB

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