Import DOMAIN constants for Plugwise and implement (#120530)
This commit is contained in:
parent
c49fce5541
commit
d00fe1ce7f
2 changed files with 61 additions and 49 deletions
|
@ -6,7 +6,13 @@ from unittest.mock import MagicMock, patch
|
||||||
from plugwise.exceptions import PlugwiseError
|
from plugwise.exceptions import PlugwiseError
|
||||||
import pytest
|
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.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
@ -153,8 +159,8 @@ async def test_adam_climate_adjust_negative_testing(
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_temperature",
|
SERVICE_SET_TEMPERATURE,
|
||||||
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
|
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -165,8 +171,8 @@ async def test_adam_climate_entity_climate_changes(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test handling of user requests in adam climate device environment."""
|
"""Test handling of user requests in adam climate device environment."""
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_temperature",
|
SERVICE_SET_TEMPERATURE,
|
||||||
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
|
{"entity_id": "climate.zone_lisa_wk", "temperature": 25},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -176,8 +182,8 @@ async def test_adam_climate_entity_climate_changes(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_temperature",
|
SERVICE_SET_TEMPERATURE,
|
||||||
{
|
{
|
||||||
"entity_id": "climate.zone_lisa_wk",
|
"entity_id": "climate.zone_lisa_wk",
|
||||||
"hvac_mode": "heat",
|
"hvac_mode": "heat",
|
||||||
|
@ -192,15 +198,15 @@ async def test_adam_climate_entity_climate_changes(
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_temperature",
|
SERVICE_SET_TEMPERATURE,
|
||||||
{"entity_id": "climate.zone_lisa_wk", "temperature": 150},
|
{"entity_id": "climate.zone_lisa_wk", "temperature": 150},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_preset_mode",
|
SERVICE_SET_PRESET_MODE,
|
||||||
{"entity_id": "climate.zone_lisa_wk", "preset_mode": "away"},
|
{"entity_id": "climate.zone_lisa_wk", "preset_mode": "away"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -210,8 +216,8 @@ async def test_adam_climate_entity_climate_changes(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_hvac_mode",
|
SERVICE_SET_HVAC_MODE,
|
||||||
{"entity_id": "climate.zone_lisa_wk", "hvac_mode": "heat"},
|
{"entity_id": "climate.zone_lisa_wk", "hvac_mode": "heat"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -222,8 +228,8 @@ async def test_adam_climate_entity_climate_changes(
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_hvac_mode",
|
SERVICE_SET_HVAC_MODE,
|
||||||
{
|
{
|
||||||
"entity_id": "climate.zone_thermostat_jessie",
|
"entity_id": "climate.zone_thermostat_jessie",
|
||||||
"hvac_mode": "dry",
|
"hvac_mode": "dry",
|
||||||
|
@ -242,8 +248,8 @@ async def test_adam_climate_off_mode_change(
|
||||||
assert state
|
assert state
|
||||||
assert state.state == HVACMode.OFF
|
assert state.state == HVACMode.OFF
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_hvac_mode",
|
SERVICE_SET_HVAC_MODE,
|
||||||
{
|
{
|
||||||
"entity_id": "climate.slaapkamer",
|
"entity_id": "climate.slaapkamer",
|
||||||
"hvac_mode": "heat",
|
"hvac_mode": "heat",
|
||||||
|
@ -258,8 +264,8 @@ async def test_adam_climate_off_mode_change(
|
||||||
assert state
|
assert state
|
||||||
assert state.state == HVACMode.HEAT
|
assert state.state == HVACMode.HEAT
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_hvac_mode",
|
SERVICE_SET_HVAC_MODE,
|
||||||
{
|
{
|
||||||
"entity_id": "climate.kinderkamer",
|
"entity_id": "climate.kinderkamer",
|
||||||
"hvac_mode": "off",
|
"hvac_mode": "off",
|
||||||
|
@ -274,8 +280,8 @@ async def test_adam_climate_off_mode_change(
|
||||||
assert state
|
assert state
|
||||||
assert state.state == HVACMode.HEAT
|
assert state.state == HVACMode.HEAT
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_hvac_mode",
|
SERVICE_SET_HVAC_MODE,
|
||||||
{
|
{
|
||||||
"entity_id": "climate.logeerkamer",
|
"entity_id": "climate.logeerkamer",
|
||||||
"hvac_mode": "heat",
|
"hvac_mode": "heat",
|
||||||
|
@ -353,8 +359,8 @@ async def test_anna_climate_entity_climate_changes(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test handling of user requests in anna climate device environment."""
|
"""Test handling of user requests in anna climate device environment."""
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_temperature",
|
SERVICE_SET_TEMPERATURE,
|
||||||
{"entity_id": "climate.anna", "target_temp_high": 30, "target_temp_low": 20},
|
{"entity_id": "climate.anna", "target_temp_high": 30, "target_temp_low": 20},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -365,8 +371,8 @@ async def test_anna_climate_entity_climate_changes(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_preset_mode",
|
SERVICE_SET_PRESET_MODE,
|
||||||
{"entity_id": "climate.anna", "preset_mode": "away"},
|
{"entity_id": "climate.anna", "preset_mode": "away"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -376,8 +382,8 @@ async def test_anna_climate_entity_climate_changes(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_hvac_mode",
|
SERVICE_SET_HVAC_MODE,
|
||||||
{"entity_id": "climate.anna", "hvac_mode": "auto"},
|
{"entity_id": "climate.anna", "hvac_mode": "auto"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -385,8 +391,8 @@ async def test_anna_climate_entity_climate_changes(
|
||||||
assert mock_smile_anna.set_schedule_state.call_count == 0
|
assert mock_smile_anna.set_schedule_state.call_count == 0
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"climate",
|
CLIMATE_DOMAIN,
|
||||||
"set_hvac_mode",
|
SERVICE_SET_HVAC_MODE,
|
||||||
{"entity_id": "climate.anna", "hvac_mode": "heat_cool"},
|
{"entity_id": "climate.anna", "hvac_mode": "heat_cool"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,6 +7,12 @@ import pytest
|
||||||
|
|
||||||
from homeassistant.components.plugwise.const import DOMAIN
|
from homeassistant.components.plugwise.const import DOMAIN
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
|
from homeassistant.const import (
|
||||||
|
SERVICE_TOGGLE,
|
||||||
|
SERVICE_TURN_OFF,
|
||||||
|
SERVICE_TURN_ON,
|
||||||
|
STATE_ON,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
@ -20,11 +26,11 @@ async def test_adam_climate_switch_entities(
|
||||||
"""Test creation of climate related switch entities."""
|
"""Test creation of climate related switch entities."""
|
||||||
state = hass.states.get("switch.cv_pomp_relay")
|
state = hass.states.get("switch.cv_pomp_relay")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "on"
|
assert state.state == STATE_ON
|
||||||
|
|
||||||
state = hass.states.get("switch.fibaro_hc2_relay")
|
state = hass.states.get("switch.fibaro_hc2_relay")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "on"
|
assert state.state == STATE_ON
|
||||||
|
|
||||||
|
|
||||||
async def test_adam_climate_switch_negative_testing(
|
async def test_adam_climate_switch_negative_testing(
|
||||||
|
@ -35,8 +41,8 @@ async def test_adam_climate_switch_negative_testing(
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
SWITCH_DOMAIN,
|
||||||
"turn_off",
|
SERVICE_TURN_OFF,
|
||||||
{"entity_id": "switch.cv_pomp_relay"},
|
{"entity_id": "switch.cv_pomp_relay"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -48,8 +54,8 @@ async def test_adam_climate_switch_negative_testing(
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
SWITCH_DOMAIN,
|
||||||
"turn_on",
|
SERVICE_TURN_ON,
|
||||||
{"entity_id": "switch.fibaro_hc2_relay"},
|
{"entity_id": "switch.fibaro_hc2_relay"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -65,8 +71,8 @@ async def test_adam_climate_switch_changes(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test changing of climate related switch entities."""
|
"""Test changing of climate related switch entities."""
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
SWITCH_DOMAIN,
|
||||||
"turn_off",
|
SERVICE_TURN_OFF,
|
||||||
{"entity_id": "switch.cv_pomp_relay"},
|
{"entity_id": "switch.cv_pomp_relay"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -77,8 +83,8 @@ async def test_adam_climate_switch_changes(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
SWITCH_DOMAIN,
|
||||||
"toggle",
|
SERVICE_TOGGLE,
|
||||||
{"entity_id": "switch.fibaro_hc2_relay"},
|
{"entity_id": "switch.fibaro_hc2_relay"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -89,8 +95,8 @@ async def test_adam_climate_switch_changes(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
SWITCH_DOMAIN,
|
||||||
"turn_on",
|
SERVICE_TURN_ON,
|
||||||
{"entity_id": "switch.fibaro_hc2_relay"},
|
{"entity_id": "switch.fibaro_hc2_relay"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -107,11 +113,11 @@ async def test_stretch_switch_entities(
|
||||||
"""Test creation of climate related switch entities."""
|
"""Test creation of climate related switch entities."""
|
||||||
state = hass.states.get("switch.koelkast_92c4a_relay")
|
state = hass.states.get("switch.koelkast_92c4a_relay")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "on"
|
assert state.state == STATE_ON
|
||||||
|
|
||||||
state = hass.states.get("switch.droger_52559_relay")
|
state = hass.states.get("switch.droger_52559_relay")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "on"
|
assert state.state == STATE_ON
|
||||||
|
|
||||||
|
|
||||||
async def test_stretch_switch_changes(
|
async def test_stretch_switch_changes(
|
||||||
|
@ -119,8 +125,8 @@ async def test_stretch_switch_changes(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test changing of power related switch entities."""
|
"""Test changing of power related switch entities."""
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
SWITCH_DOMAIN,
|
||||||
"turn_off",
|
SERVICE_TURN_OFF,
|
||||||
{"entity_id": "switch.koelkast_92c4a_relay"},
|
{"entity_id": "switch.koelkast_92c4a_relay"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -130,8 +136,8 @@ async def test_stretch_switch_changes(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
SWITCH_DOMAIN,
|
||||||
"toggle",
|
SERVICE_TOGGLE,
|
||||||
{"entity_id": "switch.droger_52559_relay"},
|
{"entity_id": "switch.droger_52559_relay"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -141,8 +147,8 @@ async def test_stretch_switch_changes(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"switch",
|
SWITCH_DOMAIN,
|
||||||
"turn_on",
|
SERVICE_TURN_ON,
|
||||||
{"entity_id": "switch.droger_52559_relay"},
|
{"entity_id": "switch.droger_52559_relay"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue