test_eberg_cooly_c35hd.py 8.6 KB

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