Import DOMAIN constants for Plugwise and implement (#120530)

This commit is contained in:
Bouwe Westerdijk 2024-06-26 12:17:17 +02:00 committed by GitHub
parent c49fce5541
commit d00fe1ce7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 61 additions and 49 deletions

View file

@ -6,7 +6,13 @@ from unittest.mock import MagicMock, patch
from plugwise.exceptions import PlugwiseError
import pytest
from homeassistant.components.climate import HVACMode
from homeassistant.components.climate import (
DOMAIN as CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
SERVICE_SET_PRESET_MODE,
SERVICE_SET_TEMPERATURE,
HVACMode,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.util.dt import utcnow
@ -153,8 +159,8 @@ async def test_adam_climate_adjust_negative_testing(
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
"climate",
"set_temperature",
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
blocking=True,
)
@ -165,8 +171,8 @@ async def test_adam_climate_entity_climate_changes(
) -> None:
"""Test handling of user requests in adam climate device environment."""
await hass.services.async_call(
"climate",
"set_temperature",
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
blocking=True,
)
@ -176,8 +182,8 @@ async def test_adam_climate_entity_climate_changes(
)
await hass.services.async_call(
"climate",
"set_temperature",
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
"entity_id": "climate.zone_lisa_wk",
"hvac_mode": "heat",
@ -192,15 +198,15 @@ async def test_adam_climate_entity_climate_changes(
with pytest.raises(ValueError):
await hass.services.async_call(
"climate",
"set_temperature",
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{"entity_id": "climate.zone_lisa_wk", "temperature": 150},
blocking=True,
)
await hass.services.async_call(
"climate",
"set_preset_mode",
CLIMATE_DOMAIN,
SERVICE_SET_PRESET_MODE,
{"entity_id": "climate.zone_lisa_wk", "preset_mode": "away"},
blocking=True,
)
@ -210,8 +216,8 @@ async def test_adam_climate_entity_climate_changes(
)
await hass.services.async_call(
"climate",
"set_hvac_mode",
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{"entity_id": "climate.zone_lisa_wk", "hvac_mode": "heat"},
blocking=True,
)
@ -222,8 +228,8 @@ async def test_adam_climate_entity_climate_changes(
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
"climate",
"set_hvac_mode",
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
"entity_id": "climate.zone_thermostat_jessie",
"hvac_mode": "dry",
@ -242,8 +248,8 @@ async def test_adam_climate_off_mode_change(
assert state
assert state.state == HVACMode.OFF
await hass.services.async_call(
"climate",
"set_hvac_mode",
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
"entity_id": "climate.slaapkamer",
"hvac_mode": "heat",
@ -258,8 +264,8 @@ async def test_adam_climate_off_mode_change(
assert state
assert state.state == HVACMode.HEAT
await hass.services.async_call(
"climate",
"set_hvac_mode",
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
"entity_id": "climate.kinderkamer",
"hvac_mode": "off",
@ -274,8 +280,8 @@ async def test_adam_climate_off_mode_change(
assert state
assert state.state == HVACMode.HEAT
await hass.services.async_call(
"climate",
"set_hvac_mode",
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{
"entity_id": "climate.logeerkamer",
"hvac_mode": "heat",
@ -353,8 +359,8 @@ async def test_anna_climate_entity_climate_changes(
) -> None:
"""Test handling of user requests in anna climate device environment."""
await hass.services.async_call(
"climate",
"set_temperature",
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{"entity_id": "climate.anna", "target_temp_high": 30, "target_temp_low": 20},
blocking=True,
)
@ -365,8 +371,8 @@ async def test_anna_climate_entity_climate_changes(
)
await hass.services.async_call(
"climate",
"set_preset_mode",
CLIMATE_DOMAIN,
SERVICE_SET_PRESET_MODE,
{"entity_id": "climate.anna", "preset_mode": "away"},
blocking=True,
)
@ -376,8 +382,8 @@ async def test_anna_climate_entity_climate_changes(
)
await hass.services.async_call(
"climate",
"set_hvac_mode",
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{"entity_id": "climate.anna", "hvac_mode": "auto"},
blocking=True,
)
@ -385,8 +391,8 @@ async def test_anna_climate_entity_climate_changes(
assert mock_smile_anna.set_schedule_state.call_count == 0
await hass.services.async_call(
"climate",
"set_hvac_mode",
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{"entity_id": "climate.anna", "hvac_mode": "heat_cool"},
blocking=True,
)