| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- from homeassistant.components.climate.const import (
- ClimateEntityFeature,
- HVACAction,
- HVACMode,
- PRESET_SLEEP,
- PRESET_COMFORT,
- SWING_OFF,
- SWING_VERTICAL,
- )
- from homeassistant.const import (
- UnitOfTime,
- UnitOfTemperature,
- )
- from ..const import EBERG_QUBO_Q40HD_PAYLOAD
- from ..helpers import assert_device_properties_set
- from ..mixins.climate import TargetTemperatureTests
- from ..mixins.number import BasicNumberTests
- from .base_device_tests import TuyaDeviceTestCase
- POWER_DPS = "1"
- TEMPERATURE_DPS = "2"
- CURRENTTEMP_DPS = "3"
- HVACMODE_DPS = "4"
- FAN_DPS = "5"
- UNIT_DPS = "19"
- TIMER_DPS = "22"
- PRESET_DPS = "25"
- SWING_DPS = "30"
- HVACACTION_DPS = "101"
- class TestEbergQuboQ40HDHeatpump(
- BasicNumberTests, TargetTemperatureTests, TuyaDeviceTestCase
- ):
- __test__ = True
- def setUp(self):
- self.setUpForConfig(
- "eberg_qubo_q40hd_heatpump.yaml",
- EBERG_QUBO_Q40HD_PAYLOAD,
- )
- self.subject = self.entities.get("climate")
- self.setUpTargetTemperature(
- TEMPERATURE_DPS,
- self.subject,
- min=17,
- max=30,
- )
- self.setUpBasicNumber(
- TIMER_DPS,
- self.entities.get("number_timer"),
- max=24,
- unit=UnitOfTime.HOURS,
- )
- self.mark_secondary(["number_timer"])
- def test_supported_features(self):
- self.assertEqual(
- self.subject.supported_features,
- (
- ClimateEntityFeature.TARGET_TEMPERATURE
- | ClimateEntityFeature.FAN_MODE
- | ClimateEntityFeature.PRESET_MODE
- | ClimateEntityFeature.SWING_MODE
- ),
- )
- def test_icon(self):
- self.dps[POWER_DPS] = True
- self.dps[HVACMODE_DPS] = "cold"
- self.assertEqual(self.subject.icon, "mdi:snowflake")
- self.dps[HVACMODE_DPS] = "hot"
- self.assertEqual(self.subject.icon, "mdi:fire")
- self.dps[HVACMODE_DPS] = "dehumidify"
- self.assertEqual(self.subject.icon, "mdi:water-percent")
- self.dps[POWER_DPS] = False
- self.assertEqual(self.subject.icon, "mdi:hvac-off")
- def test_temperature_unit(self):
- self.dps[UNIT_DPS] = "c"
- self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.CELSIUS)
- self.dps[UNIT_DPS] = "f"
- self.assertEqual(self.subject.temperature_unit, UnitOfTemperature.FAHRENHEIT)
- def test_minimum_target_temperature_f(self):
- self.dps[UNIT_DPS] = "f"
- self.assertEqual(self.subject.min_temp, 63)
- def test_maximum_target_temperature_f(self):
- self.dps[UNIT_DPS] = "f"
- self.assertEqual(self.subject.max_temp, 86)
- def test_current_temperature(self):
- self.dps[CURRENTTEMP_DPS] = 25
- self.assertEqual(self.subject.current_temperature, 25)
- def test_hvac_mode(self):
- self.dps[POWER_DPS] = True
- self.dps[HVACMODE_DPS] = "cold"
- self.assertEqual(self.subject.hvac_mode, HVACMode.COOL)
- self.dps[HVACMODE_DPS] = "hot"
- self.assertEqual(self.subject.hvac_mode, HVACMode.HEAT)
- self.dps[HVACMODE_DPS] = "dehumidify"
- self.assertEqual(self.subject.hvac_mode, HVACMode.DRY)
- self.dps[HVACMODE_DPS] = "cold"
- self.dps[POWER_DPS] = False
- self.assertEqual(self.subject.hvac_mode, HVACMode.OFF)
- def test_hvac_modes(self):
- self.assertCountEqual(
- self.subject.hvac_modes,
- [
- HVACMode.OFF,
- HVACMode.COOL,
- HVACMode.DRY,
- HVACMode.HEAT,
- ],
- )
- async def test_set_hvac_cool(self):
- async with assert_device_properties_set(
- self.subject._device, {POWER_DPS: True, HVACMODE_DPS: "cold"}
- ):
- await self.subject.async_set_hvac_mode(HVACMode.COOL)
- async def test_set_hvac_off(self):
- async with assert_device_properties_set(
- self.subject._device, {POWER_DPS: False}
- ):
- await self.subject.async_set_hvac_mode(HVACMode.OFF)
- async def test_turn_on(self):
- async with assert_device_properties_set(
- self.subject._device, {POWER_DPS: True}
- ):
- await self.subject.async_turn_on()
- async def test_turn_off(self):
- async with assert_device_properties_set(
- self.subject._device, {POWER_DPS: False}
- ):
- await self.subject.async_turn_off()
- def test_fan_mode(self):
- self.dps[FAN_DPS] = "low"
- self.assertEqual(self.subject.fan_mode, "low")
- self.dps[FAN_DPS] = "middle"
- self.assertEqual(self.subject.fan_mode, "medium")
- self.dps[FAN_DPS] = "high"
- self.assertEqual(self.subject.fan_mode, "high")
- self.dps[FAN_DPS] = "auto"
- self.assertEqual(self.subject.fan_mode, "auto")
- def test_fan_modes(self):
- self.assertCountEqual(
- self.subject.fan_modes,
- [
- "auto",
- "low",
- "medium",
- "high",
- ],
- )
- async def test_set_fan_mode_to_low(self):
- async with assert_device_properties_set(
- self.subject._device,
- {FAN_DPS: "low"},
- ):
- await self.subject.async_set_fan_mode("low")
- async def test_set_fan_mode_to_medium(self):
- async with assert_device_properties_set(
- self.subject._device,
- {FAN_DPS: "middle"},
- ):
- await self.subject.async_set_fan_mode("medium")
- async def test_set_fan_mode_to_high(self):
- async with assert_device_properties_set(
- self.subject._device,
- {FAN_DPS: "high"},
- ):
- await self.subject.async_set_fan_mode("high")
- async def test_set_fan_mode_to_auto(self):
- async with assert_device_properties_set(
- self.subject._device,
- {FAN_DPS: "auto"},
- ):
- await self.subject.async_set_fan_mode("auto")
- def test_swing_mode(self):
- self.dps[SWING_DPS] = True
- self.assertEqual(self.subject.swing_mode, SWING_VERTICAL)
- self.dps[SWING_DPS] = False
- self.assertEqual(self.subject.swing_mode, SWING_OFF)
- def test_swing_modes(self):
- self.assertCountEqual(
- self.subject.swing_modes,
- [
- SWING_VERTICAL,
- SWING_OFF,
- ],
- )
- async def test_set_swing_mode_to_vertical(self):
- async with assert_device_properties_set(
- self.subject._device,
- {SWING_DPS: True},
- ):
- await self.subject.async_set_swing_mode(SWING_VERTICAL)
- async def test_set_swing_mode_to_off(self):
- async with assert_device_properties_set(
- self.subject._device,
- {SWING_DPS: False},
- ):
- await self.subject.async_set_swing_mode(SWING_OFF)
- def test_preset_mode(self):
- self.dps[PRESET_DPS] = True
- self.assertEqual(self.subject.preset_mode, PRESET_SLEEP)
- self.dps[PRESET_DPS] = False
- self.assertEqual(self.subject.preset_mode, PRESET_COMFORT)
- def test_preset_modes(self):
- self.assertCountEqual(
- self.subject.preset_modes,
- [
- PRESET_COMFORT,
- PRESET_SLEEP,
- ],
- )
- async def test_set_preset_mode_to_sleep(self):
- async with assert_device_properties_set(
- self.subject._device,
- {PRESET_DPS: True},
- ):
- await self.subject.async_set_preset_mode(PRESET_SLEEP)
- async def test_set_preset_mode_to_normal(self):
- async with assert_device_properties_set(
- self.subject._device,
- {PRESET_DPS: False},
- ):
- await self.subject.async_set_preset_mode(PRESET_COMFORT)
- def test_hvac_action(self):
- self.dps[POWER_DPS] = True
- self.dps[HVACACTION_DPS] = "heat_s"
- self.assertEqual(self.subject.hvac_action, HVACAction.HEATING)
- self.dps[HVACACTION_DPS] = "hot"
- self.assertEqual(self.subject.hvac_action, HVACAction.HEATING)
- self.dps[HVACACTION_DPS] = "heating"
- self.assertEqual(self.subject.hvac_action, HVACAction.HEATING)
- self.dps[HVACACTION_DPS] = "cool_s"
- self.assertEqual(self.subject.hvac_action, HVACAction.COOLING)
- self.dps[HVACACTION_DPS] = "cooling"
- self.assertEqual(self.subject.hvac_action, HVACAction.COOLING)
- self.dps[HVACACTION_DPS] = "anti-clockwise"
- self.assertEqual(self.subject.hvac_action, HVACAction.FAN)
- self.dps[HVACACTION_DPS] = "ventilation"
- self.assertEqual(self.subject.hvac_action, HVACAction.FAN)
- self.dps[HVACACTION_DPS] = "wind"
- self.assertEqual(self.subject.hvac_action, HVACAction.FAN)
- self.dps[HVACACTION_DPS] = "appointment"
- self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
- self.dps[HVACACTION_DPS] = "auto"
- self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
- self.dps[HVACACTION_DPS] = "auto_clean"
- self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
- self.dps[HVACACTION_DPS] = "eco"
- self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
- self.dps[HVACACTION_DPS] = "wet"
- self.assertEqual(self.subject.hvac_action, HVACAction.DRYING)
- self.dps[HVACACTION_DPS] = "off"
- self.assertEqual(self.subject.hvac_action, HVACAction.IDLE)
- self.dps[POWER_DPS] = False
- self.assertEqual(self.subject.hvac_action, HVACAction.OFF)
- def test_extra_state_attributes(self):
- self.dps[TIMER_DPS] = 22
- self.assertDictEqual(
- self.subject.extra_state_attributes,
- {
- "timer": 22,
- },
- )
|