mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 01:58:20 +00:00
Improve Tado climate tests (#149808)
This commit is contained in:
parent
5ce2729dc2
commit
37579440e6
@ -93,6 +93,429 @@
|
||||
}),
|
||||
)
|
||||
# ---
|
||||
# name: test_entities[climate.air_conditioning-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'fan_modes': list([
|
||||
'auto',
|
||||
'high',
|
||||
'medium',
|
||||
'low',
|
||||
]),
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT_COOL: 'heat_cool'>,
|
||||
<HVACMode.DRY: 'dry'>,
|
||||
<HVACMode.FAN_ONLY: 'fan_only'>,
|
||||
]),
|
||||
'max_temp': 31.0,
|
||||
'min_temp': 16.0,
|
||||
'preset_modes': list([
|
||||
'away',
|
||||
'home',
|
||||
'auto',
|
||||
]),
|
||||
'target_temp_step': 1,
|
||||
}),
|
||||
'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.air_conditioning',
|
||||
'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': 'tado',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 409>,
|
||||
'translation_key': 'tado',
|
||||
'unique_id': 'AIR_CONDITIONING 3 1',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_entities[climate.air_conditioning-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_humidity': 60.9,
|
||||
'current_temperature': 24.8,
|
||||
'default_overlay_seconds': None,
|
||||
'default_overlay_type': 'MANUAL',
|
||||
'fan_mode': 'auto',
|
||||
'fan_modes': list([
|
||||
'auto',
|
||||
'high',
|
||||
'medium',
|
||||
'low',
|
||||
]),
|
||||
'friendly_name': 'Air Conditioning',
|
||||
'hvac_action': <HVACAction.COOLING: 'cooling'>,
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT_COOL: 'heat_cool'>,
|
||||
<HVACMode.DRY: 'dry'>,
|
||||
<HVACMode.FAN_ONLY: 'fan_only'>,
|
||||
]),
|
||||
'max_temp': 31.0,
|
||||
'min_temp': 16.0,
|
||||
'offset_celsius': -1.0,
|
||||
'offset_fahrenheit': -1.8,
|
||||
'preset_mode': 'auto',
|
||||
'preset_modes': list([
|
||||
'away',
|
||||
'home',
|
||||
'auto',
|
||||
]),
|
||||
'supported_features': <ClimateEntityFeature: 409>,
|
||||
'target_temp_step': 1,
|
||||
'temperature': 17.8,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.air_conditioning',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'cool',
|
||||
})
|
||||
# ---
|
||||
# name: test_entities[climate.air_conditioning_with_fanlevel-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'fan_modes': list([
|
||||
'high',
|
||||
'medium',
|
||||
'auto',
|
||||
'low',
|
||||
]),
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT_COOL: 'heat_cool'>,
|
||||
<HVACMode.DRY: 'dry'>,
|
||||
<HVACMode.FAN_ONLY: 'fan_only'>,
|
||||
]),
|
||||
'max_temp': 31.0,
|
||||
'min_temp': 16.0,
|
||||
'preset_modes': list([
|
||||
'away',
|
||||
'home',
|
||||
'auto',
|
||||
]),
|
||||
'swing_modes': list([
|
||||
'vertical',
|
||||
'horizontal',
|
||||
'both',
|
||||
'off',
|
||||
]),
|
||||
'target_temp_step': 1.0,
|
||||
}),
|
||||
'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.air_conditioning_with_fanlevel',
|
||||
'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': 'tado',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 441>,
|
||||
'translation_key': 'tado',
|
||||
'unique_id': 'AIR_CONDITIONING 6 1',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_entities[climate.air_conditioning_with_fanlevel-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_humidity': 70.9,
|
||||
'current_temperature': 24.3,
|
||||
'default_overlay_seconds': None,
|
||||
'default_overlay_type': 'MANUAL',
|
||||
'fan_mode': 'high',
|
||||
'fan_modes': list([
|
||||
'high',
|
||||
'medium',
|
||||
'auto',
|
||||
'low',
|
||||
]),
|
||||
'friendly_name': 'Air Conditioning with fanlevel',
|
||||
'hvac_action': <HVACAction.HEATING: 'heating'>,
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT_COOL: 'heat_cool'>,
|
||||
<HVACMode.DRY: 'dry'>,
|
||||
<HVACMode.FAN_ONLY: 'fan_only'>,
|
||||
]),
|
||||
'max_temp': 31.0,
|
||||
'min_temp': 16.0,
|
||||
'preset_mode': 'auto',
|
||||
'preset_modes': list([
|
||||
'away',
|
||||
'home',
|
||||
'auto',
|
||||
]),
|
||||
'supported_features': <ClimateEntityFeature: 441>,
|
||||
'swing_mode': 'both',
|
||||
'swing_modes': list([
|
||||
'vertical',
|
||||
'horizontal',
|
||||
'both',
|
||||
'off',
|
||||
]),
|
||||
'target_temp_step': 1.0,
|
||||
'temperature': 25.0,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.air_conditioning_with_fanlevel',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'heat',
|
||||
})
|
||||
# ---
|
||||
# name: test_entities[climate.air_conditioning_with_swing-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'fan_modes': list([
|
||||
'auto',
|
||||
'high',
|
||||
'medium',
|
||||
'low',
|
||||
]),
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT_COOL: 'heat_cool'>,
|
||||
<HVACMode.DRY: 'dry'>,
|
||||
<HVACMode.FAN_ONLY: 'fan_only'>,
|
||||
]),
|
||||
'max_temp': 30.0,
|
||||
'min_temp': 16.0,
|
||||
'preset_modes': list([
|
||||
'away',
|
||||
'home',
|
||||
'auto',
|
||||
]),
|
||||
'swing_modes': list([
|
||||
'on',
|
||||
'off',
|
||||
]),
|
||||
'target_temp_step': 1.0,
|
||||
}),
|
||||
'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.air_conditioning_with_swing',
|
||||
'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': 'tado',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 441>,
|
||||
'translation_key': 'tado',
|
||||
'unique_id': 'AIR_CONDITIONING 5 1',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_entities[climate.air_conditioning_with_swing-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_humidity': 42.3,
|
||||
'current_temperature': 20.9,
|
||||
'default_overlay_seconds': None,
|
||||
'default_overlay_type': 'MANUAL',
|
||||
'fan_mode': 'auto',
|
||||
'fan_modes': list([
|
||||
'auto',
|
||||
'high',
|
||||
'medium',
|
||||
'low',
|
||||
]),
|
||||
'friendly_name': 'Air Conditioning with swing',
|
||||
'hvac_action': <HVACAction.HEATING: 'heating'>,
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.HEAT_COOL: 'heat_cool'>,
|
||||
<HVACMode.DRY: 'dry'>,
|
||||
<HVACMode.FAN_ONLY: 'fan_only'>,
|
||||
]),
|
||||
'max_temp': 30.0,
|
||||
'min_temp': 16.0,
|
||||
'offset_celsius': -1.0,
|
||||
'offset_fahrenheit': -1.8,
|
||||
'preset_mode': 'auto',
|
||||
'preset_modes': list([
|
||||
'away',
|
||||
'home',
|
||||
'auto',
|
||||
]),
|
||||
'supported_features': <ClimateEntityFeature: 441>,
|
||||
'swing_mode': 'off',
|
||||
'swing_modes': list([
|
||||
'on',
|
||||
'off',
|
||||
]),
|
||||
'target_temp_step': 1.0,
|
||||
'temperature': 20.0,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.air_conditioning_with_swing',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'auto',
|
||||
})
|
||||
# ---
|
||||
# name: test_entities[climate.baseboard_heater-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 31.0,
|
||||
'min_temp': 16.0,
|
||||
'preset_modes': list([
|
||||
'away',
|
||||
'home',
|
||||
'auto',
|
||||
]),
|
||||
'target_temp_step': 1,
|
||||
}),
|
||||
'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.baseboard_heater',
|
||||
'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': 'tado',
|
||||
'previous_unique_id': None,
|
||||
'suggested_object_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 401>,
|
||||
'translation_key': 'tado',
|
||||
'unique_id': 'HEATING 1 1',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_entities[climate.baseboard_heater-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_humidity': 45.2,
|
||||
'current_temperature': 20.6,
|
||||
'default_overlay_seconds': None,
|
||||
'default_overlay_type': 'MANUAL',
|
||||
'friendly_name': 'Baseboard Heater',
|
||||
'hvac_action': <HVACAction.IDLE: 'idle'>,
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.AUTO: 'auto'>,
|
||||
<HVACMode.HEAT: 'heat'>,
|
||||
]),
|
||||
'max_temp': 31.0,
|
||||
'min_temp': 16.0,
|
||||
'offset_celsius': -1.0,
|
||||
'offset_fahrenheit': -1.8,
|
||||
'preset_mode': 'auto',
|
||||
'preset_modes': list([
|
||||
'away',
|
||||
'home',
|
||||
'auto',
|
||||
]),
|
||||
'supported_features': <ClimateEntityFeature: 401>,
|
||||
'target_temp_step': 1,
|
||||
'temperature': 20.5,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.baseboard_heater',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'heat',
|
||||
})
|
||||
# ---
|
||||
# name: test_heater_set_temperature
|
||||
_Call(
|
||||
tuple(
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""The sensor tests for the tado platform."""
|
||||
"""The climate tests for the tado platform."""
|
||||
|
||||
from collections.abc import AsyncGenerator
|
||||
from unittest.mock import patch
|
||||
|
||||
from PyTado.interface.api.my_tado import TadoZone
|
||||
@ -13,128 +14,33 @@ from homeassistant.components.climate import (
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
|
||||
from homeassistant.components.tado import DOMAIN
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .util import async_init_integration
|
||||
|
||||
|
||||
async def test_air_con(hass: HomeAssistant) -> None:
|
||||
"""Test creation of aircon climate."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
||||
state = hass.states.get("climate.air_conditioning")
|
||||
assert state.state == "cool"
|
||||
|
||||
expected_attributes = {
|
||||
"current_humidity": 60.9,
|
||||
"current_temperature": 24.8,
|
||||
"fan_mode": "auto",
|
||||
"fan_modes": ["auto", "high", "medium", "low"],
|
||||
"friendly_name": "Air Conditioning",
|
||||
"hvac_action": "cooling",
|
||||
"hvac_modes": ["off", "auto", "heat", "cool", "heat_cool", "dry", "fan_only"],
|
||||
"max_temp": 31.0,
|
||||
"min_temp": 16.0,
|
||||
"preset_mode": "auto",
|
||||
"preset_modes": ["away", "home", "auto"],
|
||||
"supported_features": 409,
|
||||
"target_temp_step": 1,
|
||||
"temperature": 17.8,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
async def test_heater(hass: HomeAssistant) -> None:
|
||||
"""Test creation of heater climate."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
||||
state = hass.states.get("climate.baseboard_heater")
|
||||
assert state.state == "heat"
|
||||
|
||||
expected_attributes = {
|
||||
"current_humidity": 45.2,
|
||||
"current_temperature": 20.6,
|
||||
"friendly_name": "Baseboard Heater",
|
||||
"hvac_action": "idle",
|
||||
"hvac_modes": ["off", "auto", "heat"],
|
||||
"max_temp": 31.0,
|
||||
"min_temp": 16.0,
|
||||
"preset_mode": "auto",
|
||||
"preset_modes": ["away", "home", "auto"],
|
||||
"supported_features": 401,
|
||||
"target_temp_step": 1,
|
||||
"temperature": 20.5,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_platforms() -> AsyncGenerator[None]:
|
||||
"""Set up the platforms for the tests."""
|
||||
with patch("homeassistant.components.tado.PLATFORMS", [Platform.CLIMATE]):
|
||||
yield
|
||||
|
||||
|
||||
async def test_smartac_with_swing(hass: HomeAssistant) -> None:
|
||||
"""Test creation of smart ac with swing climate."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
||||
state = hass.states.get("climate.air_conditioning_with_swing")
|
||||
assert state.state == "auto"
|
||||
|
||||
expected_attributes = {
|
||||
"current_humidity": 42.3,
|
||||
"current_temperature": 20.9,
|
||||
"fan_mode": "auto",
|
||||
"fan_modes": ["auto", "high", "medium", "low"],
|
||||
"friendly_name": "Air Conditioning with swing",
|
||||
"hvac_action": "heating",
|
||||
"hvac_modes": ["off", "auto", "heat", "cool", "heat_cool", "dry", "fan_only"],
|
||||
"max_temp": 30.0,
|
||||
"min_temp": 16.0,
|
||||
"preset_mode": "auto",
|
||||
"preset_modes": ["away", "home", "auto"],
|
||||
"swing_modes": ["on", "off"],
|
||||
"supported_features": 441,
|
||||
"target_temp_step": 1.0,
|
||||
"temperature": 20.0,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
||||
|
||||
|
||||
async def test_smartac_with_fanlevel_vertical_and_horizontal_swing(
|
||||
hass: HomeAssistant,
|
||||
async def test_entities(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, snapshot: SnapshotAssertion
|
||||
) -> None:
|
||||
"""Test creation of smart ac with swing climate."""
|
||||
"""Test creation of climate entities."""
|
||||
|
||||
await async_init_integration(hass)
|
||||
|
||||
state = hass.states.get("climate.air_conditioning_with_fanlevel")
|
||||
assert state.state == "heat"
|
||||
config_entry: MockConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
|
||||
expected_attributes = {
|
||||
"current_humidity": 70.9,
|
||||
"current_temperature": 24.3,
|
||||
"fan_mode": "high",
|
||||
"fan_modes": ["high", "medium", "auto", "low"],
|
||||
"friendly_name": "Air Conditioning with fanlevel",
|
||||
"hvac_action": "heating",
|
||||
"hvac_modes": ["off", "auto", "heat", "cool", "heat_cool", "dry", "fan_only"],
|
||||
"max_temp": 31.0,
|
||||
"min_temp": 16.0,
|
||||
"preset_mode": "auto",
|
||||
"preset_modes": ["away", "home", "auto"],
|
||||
"swing_modes": ["vertical", "horizontal", "both", "off"],
|
||||
"supported_features": 441,
|
||||
"target_temp_step": 1.0,
|
||||
"temperature": 25.0,
|
||||
}
|
||||
# Only test for a subset of attributes in case
|
||||
# HA changes the implementation and a new one appears
|
||||
assert all(item in state.attributes.items() for item in expected_attributes.items())
|
||||
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_heater_set_temperature(
|
||||
|
Loading…
x
Reference in New Issue
Block a user