mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Add climate entity for heatpump zones in SmartThings (#144991)
* Add climate entity for heatpump zones in SmartThings * Fix * Fix * Fix * Fix * Fix * Fix * Sync SmartThings EHS fixture
This commit is contained in:
parent
4c6e854cad
commit
613aa9b2cf
@ -289,7 +289,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: SmartThingsConfigEntry)
|
||||
for identifier in device_entry.identifiers
|
||||
if identifier[0] == DOMAIN
|
||||
)
|
||||
if device_id in device_status:
|
||||
if any(
|
||||
device_id.startswith(device_identifier)
|
||||
for device_identifier in device_status
|
||||
):
|
||||
continue
|
||||
device_registry.async_update_device(
|
||||
device_entry.id, remove_config_entry_id=entry.entry_id
|
||||
|
@ -12,6 +12,8 @@ from homeassistant.components.climate import (
|
||||
ATTR_HVAC_MODE,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
DEFAULT_MAX_TEMP,
|
||||
DEFAULT_MIN_TEMP,
|
||||
SWING_BOTH,
|
||||
SWING_HORIZONTAL,
|
||||
SWING_OFF,
|
||||
@ -23,10 +25,11 @@ from homeassistant.components.climate import (
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import FullDevice, SmartThingsConfigEntry
|
||||
from .const import MAIN, UNIT_MAP
|
||||
from .const import DOMAIN, MAIN, UNIT_MAP
|
||||
from .entity import SmartThingsEntity
|
||||
|
||||
ATTR_OPERATION_STATE = "operation_state"
|
||||
@ -88,6 +91,14 @@ FAN_OSCILLATION_TO_SWING = {
|
||||
value: key for key, value in SWING_TO_FAN_OSCILLATION.items()
|
||||
}
|
||||
|
||||
HEAT_PUMP_AC_MODE_TO_HA = {
|
||||
"auto": HVACMode.AUTO,
|
||||
"cool": HVACMode.COOL,
|
||||
"heat": HVACMode.HEAT,
|
||||
}
|
||||
|
||||
HA_MODE_TO_HEAT_PUMP_AC_MODE = {v: k for k, v in HEAT_PUMP_AC_MODE_TO_HA.items()}
|
||||
|
||||
WIND = "wind"
|
||||
FAN = "fan"
|
||||
WINDFREE = "windFree"
|
||||
@ -110,6 +121,14 @@ THERMOSTAT_CAPABILITIES = [
|
||||
Capability.THERMOSTAT_MODE,
|
||||
]
|
||||
|
||||
HEAT_PUMP_CAPABILITIES = [
|
||||
Capability.TEMPERATURE_MEASUREMENT,
|
||||
Capability.CUSTOM_THERMOSTAT_SETPOINT_CONTROL,
|
||||
Capability.AIR_CONDITIONER_MODE,
|
||||
Capability.THERMOSTAT_COOLING_SETPOINT,
|
||||
Capability.SWITCH,
|
||||
]
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
@ -130,6 +149,16 @@ async def async_setup_entry(
|
||||
capability in device.status[MAIN] for capability in THERMOSTAT_CAPABILITIES
|
||||
)
|
||||
)
|
||||
entities.extend(
|
||||
SmartThingsHeatPumpZone(entry_data.client, device, component)
|
||||
for device in entry_data.devices.values()
|
||||
for component in device.status
|
||||
if component in {"INDOOR", "INDOOR1", "INDOOR2"}
|
||||
and all(
|
||||
capability in device.status[component]
|
||||
for capability in HEAT_PUMP_CAPABILITIES
|
||||
)
|
||||
)
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
@ -592,3 +621,148 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity):
|
||||
if state not in modes
|
||||
)
|
||||
return modes
|
||||
|
||||
|
||||
class SmartThingsHeatPumpZone(SmartThingsEntity, ClimateEntity):
|
||||
"""Define a SmartThings heat pump zone."""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
def __init__(self, client: SmartThings, device: FullDevice, component: str) -> None:
|
||||
"""Init the class."""
|
||||
super().__init__(
|
||||
client,
|
||||
device,
|
||||
{
|
||||
Capability.AIR_CONDITIONER_MODE,
|
||||
Capability.SWITCH,
|
||||
Capability.CUSTOM_THERMOSTAT_SETPOINT_CONTROL,
|
||||
Capability.THERMOSTAT_COOLING_SETPOINT,
|
||||
Capability.TEMPERATURE_MEASUREMENT,
|
||||
},
|
||||
component=component,
|
||||
)
|
||||
self._attr_hvac_modes = self._determine_hvac_modes()
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, f"{device.device.device_id}_{component}")},
|
||||
via_device=(DOMAIN, device.device.device_id),
|
||||
name=f"{device.device.label} {component}",
|
||||
)
|
||||
|
||||
@property
|
||||
def supported_features(self) -> ClimateEntityFeature:
|
||||
"""Return the list of supported features."""
|
||||
features = ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
|
||||
if (
|
||||
self.get_attribute_value(
|
||||
Capability.AIR_CONDITIONER_MODE, Attribute.AIR_CONDITIONER_MODE
|
||||
)
|
||||
!= "auto"
|
||||
):
|
||||
features |= ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
return features
|
||||
|
||||
@property
|
||||
def min_temp(self) -> float:
|
||||
"""Return the minimum temperature."""
|
||||
min_setpoint = self.get_attribute_value(
|
||||
Capability.CUSTOM_THERMOSTAT_SETPOINT_CONTROL, Attribute.MINIMUM_SETPOINT
|
||||
)
|
||||
if min_setpoint == -1000:
|
||||
return DEFAULT_MIN_TEMP
|
||||
return min_setpoint
|
||||
|
||||
@property
|
||||
def max_temp(self) -> float:
|
||||
"""Return the maximum temperature."""
|
||||
max_setpoint = self.get_attribute_value(
|
||||
Capability.CUSTOM_THERMOSTAT_SETPOINT_CONTROL, Attribute.MAXIMUM_SETPOINT
|
||||
)
|
||||
if max_setpoint == -1000:
|
||||
return DEFAULT_MAX_TEMP
|
||||
return max_setpoint
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set new target operation mode."""
|
||||
if hvac_mode == HVACMode.OFF:
|
||||
await self.async_turn_off()
|
||||
return
|
||||
if self.get_attribute_value(Capability.SWITCH, Attribute.SWITCH) == "off":
|
||||
await self.async_turn_on()
|
||||
|
||||
await self.execute_device_command(
|
||||
Capability.AIR_CONDITIONER_MODE,
|
||||
Command.SET_AIR_CONDITIONER_MODE,
|
||||
argument=HA_MODE_TO_HEAT_PUMP_AC_MODE[hvac_mode],
|
||||
)
|
||||
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
await self.execute_device_command(
|
||||
Capability.THERMOSTAT_COOLING_SETPOINT,
|
||||
Command.SET_COOLING_SETPOINT,
|
||||
argument=kwargs[ATTR_TEMPERATURE],
|
||||
)
|
||||
|
||||
async def async_turn_on(self) -> None:
|
||||
"""Turn device on."""
|
||||
await self.execute_device_command(
|
||||
Capability.SWITCH,
|
||||
Command.ON,
|
||||
)
|
||||
|
||||
async def async_turn_off(self) -> None:
|
||||
"""Turn device off."""
|
||||
await self.execute_device_command(
|
||||
Capability.SWITCH,
|
||||
Command.OFF,
|
||||
)
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> float | None:
|
||||
"""Return the current temperature."""
|
||||
return self.get_attribute_value(
|
||||
Capability.TEMPERATURE_MEASUREMENT, Attribute.TEMPERATURE
|
||||
)
|
||||
|
||||
@property
|
||||
def hvac_mode(self) -> HVACMode | None:
|
||||
"""Return current operation ie. heat, cool, idle."""
|
||||
if self.get_attribute_value(Capability.SWITCH, Attribute.SWITCH) == "off":
|
||||
return HVACMode.OFF
|
||||
return HEAT_PUMP_AC_MODE_TO_HA.get(
|
||||
self.get_attribute_value(
|
||||
Capability.AIR_CONDITIONER_MODE, Attribute.AIR_CONDITIONER_MODE
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> float:
|
||||
"""Return the temperature we try to reach."""
|
||||
return self.get_attribute_value(
|
||||
Capability.THERMOSTAT_COOLING_SETPOINT, Attribute.COOLING_SETPOINT
|
||||
)
|
||||
|
||||
@property
|
||||
def temperature_unit(self) -> str:
|
||||
"""Return the unit of measurement."""
|
||||
unit = self._internal_state[Capability.TEMPERATURE_MEASUREMENT][
|
||||
Attribute.TEMPERATURE
|
||||
].unit
|
||||
assert unit
|
||||
return UNIT_MAP[unit]
|
||||
|
||||
def _determine_hvac_modes(self) -> list[HVACMode]:
|
||||
"""Determine the supported HVAC modes."""
|
||||
modes = [HVACMode.OFF]
|
||||
if (
|
||||
ac_modes := self.get_attribute_value(
|
||||
Capability.AIR_CONDITIONER_MODE, Attribute.SUPPORTED_AC_MODES
|
||||
)
|
||||
) is not None:
|
||||
modes.extend(
|
||||
state
|
||||
for mode in ac_modes
|
||||
if (state := HEAT_PUMP_AC_MODE_TO_HA.get(mode)) is not None
|
||||
)
|
||||
return modes
|
||||
|
@ -128,6 +128,73 @@
|
||||
'state': 'heat',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_ac_ehs_01001][climate.heat_pump_indoor1-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
]),
|
||||
'max_temp': 65,
|
||||
'min_temp': 26,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'climate',
|
||||
'entity_category': None,
|
||||
'entity_id': 'climate.heat_pump_indoor1',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
'translation_key': None,
|
||||
'unique_id': '4165c51e-bf6b-c5b6-fd53-127d6248754b_INDOOR1',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_ac_ehs_01001][climate.heat_pump_indoor1-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_temperature': 18.5,
|
||||
'friendly_name': 'Heat pump INDOOR1',
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
]),
|
||||
'max_temp': 65,
|
||||
'min_temp': 26,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
'temperature': 35,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.heat_pump_indoor1',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_ac_rac_000001][climate.ac_office_granit-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
@ -528,6 +595,272 @@
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_sac_ehs_000001_sub][climate.eco_heating_system_indoor-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 65,
|
||||
'min_temp': 25,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'climate',
|
||||
'entity_category': None,
|
||||
'entity_id': 'climate.eco_heating_system_indoor',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
'translation_key': None,
|
||||
'unique_id': '1f98ebd0-ac48-d802-7f62-000001200100_INDOOR',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_sac_ehs_000001_sub][climate.eco_heating_system_indoor-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_temperature': 23.1,
|
||||
'friendly_name': 'Eco Heating System INDOOR',
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 65,
|
||||
'min_temp': 25,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
'temperature': 25,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.eco_heating_system_indoor',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_sac_ehs_000001_sub_1][climate.heat_pump_main_indoor-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 65,
|
||||
'min_temp': 25,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'climate',
|
||||
'entity_category': None,
|
||||
'entity_id': 'climate.heat_pump_main_indoor',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
'translation_key': None,
|
||||
'unique_id': '6a7d5349-0a66-0277-058d-000001200101_INDOOR',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_sac_ehs_000001_sub_1][climate.heat_pump_main_indoor-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_temperature': 31,
|
||||
'friendly_name': 'Heat Pump Main INDOOR',
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 65,
|
||||
'min_temp': 25,
|
||||
'supported_features': <ClimateEntityFeature: 385>,
|
||||
'temperature': 30,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.heat_pump_main_indoor',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'heat',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_sac_ehs_000002_sub][climate.warmepumpe_indoor1-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 35,
|
||||
'min_temp': 7,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'climate',
|
||||
'entity_category': None,
|
||||
'entity_id': 'climate.warmepumpe_indoor1',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 384>,
|
||||
'translation_key': None,
|
||||
'unique_id': '3810e5ad-5351-d9f9-12ff-000001200000_INDOOR1',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_sac_ehs_000002_sub][climate.warmepumpe_indoor1-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_temperature': 31.2,
|
||||
'friendly_name': 'Wärmepumpe INDOOR1',
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 35,
|
||||
'min_temp': 7,
|
||||
'supported_features': <ClimateEntityFeature: 384>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.warmepumpe_indoor1',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'auto',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_sac_ehs_000002_sub][climate.warmepumpe_indoor2-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 35,
|
||||
'min_temp': 7,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'climate',
|
||||
'entity_category': None,
|
||||
'entity_id': 'climate.warmepumpe_indoor2',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'smartthings',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 384>,
|
||||
'translation_key': None,
|
||||
'unique_id': '3810e5ad-5351-d9f9-12ff-000001200000_INDOOR2',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[da_sac_ehs_000002_sub][climate.warmepumpe_indoor2-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_temperature': 29.1,
|
||||
'friendly_name': 'Wärmepumpe INDOOR2',
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 35,
|
||||
'min_temp': 7,
|
||||
'supported_features': <ClimateEntityFeature: 384>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.warmepumpe_indoor2',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[ecobee_thermostat][climate.main_floor-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
@ -16,6 +16,8 @@ from homeassistant.components.climate import (
|
||||
ATTR_HVAC_ACTION,
|
||||
ATTR_HVAC_MODE,
|
||||
ATTR_HVAC_MODES,
|
||||
ATTR_MAX_TEMP,
|
||||
ATTR_MIN_TEMP,
|
||||
ATTR_PRESET_MODE,
|
||||
ATTR_SWING_MODE,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
@ -865,6 +867,258 @@ async def test_thermostat_state_attributes_update(
|
||||
assert hass.states.get("climate.asd").attributes[state_attribute] == expected_value
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_sac_ehs_000002_sub"])
|
||||
async def test_heat_pump_hvac_mode(
|
||||
hass: HomeAssistant,
|
||||
devices: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test heat pump set HVAC mode."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: "climate.warmepumpe_indoor1", ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
devices.execute_device_command.assert_called_once_with(
|
||||
"3810e5ad-5351-d9f9-12ff-000001200000",
|
||||
Capability.AIR_CONDITIONER_MODE,
|
||||
Command.SET_AIR_CONDITIONER_MODE,
|
||||
"INDOOR1",
|
||||
argument="heat",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_sac_ehs_000002_sub"])
|
||||
async def test_heat_pump_hvac_mode_off(
|
||||
hass: HomeAssistant,
|
||||
devices: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test heat pump set HVAC mode."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: "climate.warmepumpe_indoor1", ATTR_HVAC_MODE: HVACMode.OFF},
|
||||
blocking=True,
|
||||
)
|
||||
devices.execute_device_command.assert_called_once_with(
|
||||
"3810e5ad-5351-d9f9-12ff-000001200000",
|
||||
Capability.SWITCH,
|
||||
Command.OFF,
|
||||
"INDOOR1",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_sac_ehs_000002_sub"])
|
||||
async def test_heat_pump_hvac_mode_from_off(
|
||||
hass: HomeAssistant,
|
||||
devices: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test heat pump set HVAC mode."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: "climate.warmepumpe_indoor2", ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
assert devices.execute_device_command.mock_calls == [
|
||||
call(
|
||||
"3810e5ad-5351-d9f9-12ff-000001200000",
|
||||
Capability.SWITCH,
|
||||
Command.ON,
|
||||
"INDOOR2",
|
||||
),
|
||||
call(
|
||||
"3810e5ad-5351-d9f9-12ff-000001200000",
|
||||
Capability.AIR_CONDITIONER_MODE,
|
||||
Command.SET_AIR_CONDITIONER_MODE,
|
||||
"INDOOR2",
|
||||
argument="heat",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_sac_ehs_000002_sub"])
|
||||
async def test_heat_pump_set_temperature(
|
||||
hass: HomeAssistant,
|
||||
devices: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test heat pump set temperature."""
|
||||
set_attribute_value(
|
||||
devices,
|
||||
Capability.AIR_CONDITIONER_MODE,
|
||||
Attribute.AIR_CONDITIONER_MODE,
|
||||
"heat",
|
||||
component="INDOOR1",
|
||||
)
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: "climate.warmepumpe_indoor1", ATTR_TEMPERATURE: 35},
|
||||
blocking=True,
|
||||
)
|
||||
devices.execute_device_command.assert_called_once_with(
|
||||
"3810e5ad-5351-d9f9-12ff-000001200000",
|
||||
Capability.THERMOSTAT_COOLING_SETPOINT,
|
||||
Command.SET_COOLING_SETPOINT,
|
||||
"INDOOR1",
|
||||
argument=35,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_sac_ehs_000002_sub"])
|
||||
@pytest.mark.parametrize(
|
||||
("service", "command"),
|
||||
[
|
||||
(SERVICE_TURN_ON, Command.ON),
|
||||
(SERVICE_TURN_OFF, Command.OFF),
|
||||
],
|
||||
)
|
||||
async def test_heat_pump_turn_on_off(
|
||||
hass: HomeAssistant,
|
||||
devices: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
service: str,
|
||||
command: Command,
|
||||
) -> None:
|
||||
"""Test heat pump turn on/off."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
service,
|
||||
{ATTR_ENTITY_ID: "climate.warmepumpe_indoor1"},
|
||||
blocking=True,
|
||||
)
|
||||
devices.execute_device_command.assert_called_once_with(
|
||||
"3810e5ad-5351-d9f9-12ff-000001200000",
|
||||
Capability.SWITCH,
|
||||
command,
|
||||
"INDOOR1",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_sac_ehs_000002_sub"])
|
||||
async def test_heat_pump_hvac_update(
|
||||
hass: HomeAssistant,
|
||||
devices: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test state update."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
assert hass.states.get("climate.warmepumpe_indoor1").state == HVACMode.AUTO
|
||||
|
||||
await trigger_update(
|
||||
hass,
|
||||
devices,
|
||||
"3810e5ad-5351-d9f9-12ff-000001200000",
|
||||
Capability.AIR_CONDITIONER_MODE,
|
||||
Attribute.AIR_CONDITIONER_MODE,
|
||||
"cool",
|
||||
component="INDOOR1",
|
||||
)
|
||||
|
||||
assert hass.states.get("climate.warmepumpe_indoor1").state == HVACMode.COOL
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_sac_ehs_000001_sub"])
|
||||
@pytest.mark.parametrize(
|
||||
(
|
||||
"capability",
|
||||
"attribute",
|
||||
"value",
|
||||
"state_attribute",
|
||||
"original_value",
|
||||
"expected_value",
|
||||
),
|
||||
[
|
||||
(
|
||||
Capability.TEMPERATURE_MEASUREMENT,
|
||||
Attribute.TEMPERATURE,
|
||||
20,
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
23.1,
|
||||
20,
|
||||
),
|
||||
(
|
||||
Capability.THERMOSTAT_COOLING_SETPOINT,
|
||||
Attribute.COOLING_SETPOINT,
|
||||
20,
|
||||
ATTR_TEMPERATURE,
|
||||
25,
|
||||
20,
|
||||
),
|
||||
(
|
||||
Capability.CUSTOM_THERMOSTAT_SETPOINT_CONTROL,
|
||||
Attribute.MINIMUM_SETPOINT,
|
||||
6,
|
||||
ATTR_MIN_TEMP,
|
||||
25,
|
||||
6,
|
||||
),
|
||||
(
|
||||
Capability.CUSTOM_THERMOSTAT_SETPOINT_CONTROL,
|
||||
Attribute.MAXIMUM_SETPOINT,
|
||||
36,
|
||||
ATTR_MAX_TEMP,
|
||||
65,
|
||||
36,
|
||||
),
|
||||
],
|
||||
ids=[
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
ATTR_TEMPERATURE,
|
||||
ATTR_MIN_TEMP,
|
||||
ATTR_MAX_TEMP,
|
||||
],
|
||||
)
|
||||
async def test_heat_pump_state_attributes_update(
|
||||
hass: HomeAssistant,
|
||||
devices: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
capability: Capability,
|
||||
attribute: Attribute,
|
||||
value: Any,
|
||||
state_attribute: str,
|
||||
original_value: Any,
|
||||
expected_value: Any,
|
||||
) -> None:
|
||||
"""Test state attributes update."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
assert (
|
||||
hass.states.get("climate.eco_heating_system_indoor").attributes[state_attribute]
|
||||
== original_value
|
||||
)
|
||||
|
||||
await trigger_update(
|
||||
hass,
|
||||
devices,
|
||||
"1f98ebd0-ac48-d802-7f62-000001200100",
|
||||
capability,
|
||||
attribute,
|
||||
value,
|
||||
component="INDOOR",
|
||||
)
|
||||
|
||||
assert (
|
||||
hass.states.get("climate.eco_heating_system_indoor").attributes[state_attribute]
|
||||
== expected_value
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["da_ac_rac_000001"])
|
||||
async def test_availability(
|
||||
hass: HomeAssistant,
|
||||
|
Loading…
x
Reference in New Issue
Block a user