Plugwise improve platform tests (#132748)
parent
6a323a1d3c
commit
2b17037edc
|
@ -77,8 +77,3 @@ class PlugwiseEntity(CoordinatorEntity[PlugwiseDataUpdateCoordinator]):
|
|||
def device(self) -> GwEntityData:
|
||||
"""Return data for this device."""
|
||||
return self.coordinator.data.devices[self._dev_id]
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Subscribe to updates."""
|
||||
self._handle_coordinator_update()
|
||||
await super().async_added_to_hass()
|
||||
|
|
|
@ -14,9 +14,7 @@ rules:
|
|||
action-setup:
|
||||
status: exempt
|
||||
comment: Plugwise integration has no custom actions
|
||||
common-modules:
|
||||
status: todo
|
||||
comment: Verify entity for async_added_to_hass usage (discard?)
|
||||
common-modules: done
|
||||
docs-high-level-description:
|
||||
status: todo
|
||||
comment: Rewrite top section, docs PR prepared waiting for 36087 merge
|
||||
|
@ -37,9 +35,7 @@ rules:
|
|||
parallel-updates:
|
||||
status: todo
|
||||
comment: Using coordinator, but required due to mutable platform
|
||||
test-coverage:
|
||||
status: todo
|
||||
comment: Consider using snapshots + consistency in setup calls + add numerical tests + use fixtures
|
||||
test-coverage: done
|
||||
integration-owner: done
|
||||
docs-installation-parameters:
|
||||
status: todo
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
"off"
|
||||
],
|
||||
"climate_mode": "cool",
|
||||
"control_state": "auto",
|
||||
"control_state": "idle",
|
||||
"dev_class": "climate",
|
||||
"model": "ThermoZone",
|
||||
"name": "Bathroom",
|
||||
|
|
|
@ -8,12 +8,31 @@ from plugwise.exceptions import PlugwiseError
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_CURRENT_TEMPERATURE,
|
||||
ATTR_HVAC_ACTION,
|
||||
ATTR_HVAC_MODE,
|
||||
ATTR_HVAC_MODES,
|
||||
ATTR_MAX_TEMP,
|
||||
ATTR_MIN_TEMP,
|
||||
ATTR_PRESET_MODE,
|
||||
ATTR_PRESET_MODES,
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
ATTR_TARGET_TEMP_STEP,
|
||||
DOMAIN as CLIMATE_DOMAIN,
|
||||
PRESET_AWAY,
|
||||
PRESET_HOME,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
HVACAction,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_SUPPORTED_FEATURES,
|
||||
ATTR_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||
|
||||
|
@ -31,33 +50,33 @@ async def test_adam_climate_entity_attributes(
|
|||
state = hass.states.get("climate.woonkamer")
|
||||
assert state
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes["hvac_action"] == "heating"
|
||||
assert state.attributes["hvac_modes"] == [HVACMode.AUTO, HVACMode.HEAT]
|
||||
assert "preset_modes" in state.attributes
|
||||
assert "no_frost" in state.attributes["preset_modes"]
|
||||
assert "home" in state.attributes["preset_modes"]
|
||||
assert state.attributes["preset_mode"] == "home"
|
||||
assert state.attributes["current_temperature"] == 20.9
|
||||
assert state.attributes["supported_features"] == 17
|
||||
assert state.attributes["temperature"] == 21.5
|
||||
assert state.attributes["min_temp"] == 0.0
|
||||
assert state.attributes["max_temp"] == 35.0
|
||||
assert state.attributes["target_temp_step"] == 0.1
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.AUTO, HVACMode.HEAT]
|
||||
assert ATTR_PRESET_MODES in state.attributes
|
||||
assert "no_frost" in state.attributes[ATTR_PRESET_MODES]
|
||||
assert PRESET_HOME in state.attributes[ATTR_PRESET_MODES]
|
||||
assert state.attributes[ATTR_PRESET_MODE] == PRESET_HOME
|
||||
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 20.9
|
||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 17
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 21.5
|
||||
assert state.attributes[ATTR_MIN_TEMP] == 0.0
|
||||
assert state.attributes[ATTR_MAX_TEMP] == 35.0
|
||||
assert state.attributes[ATTR_TARGET_TEMP_STEP] == 0.1
|
||||
|
||||
state = hass.states.get("climate.jessie")
|
||||
assert state
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes["hvac_action"] == "idle"
|
||||
assert state.attributes["hvac_modes"] == [HVACMode.AUTO, HVACMode.HEAT]
|
||||
assert "preset_modes" in state.attributes
|
||||
assert "no_frost" in state.attributes["preset_modes"]
|
||||
assert "home" in state.attributes["preset_modes"]
|
||||
assert state.attributes["preset_mode"] == "asleep"
|
||||
assert state.attributes["current_temperature"] == 17.2
|
||||
assert state.attributes["temperature"] == 15.0
|
||||
assert state.attributes["min_temp"] == 0.0
|
||||
assert state.attributes["max_temp"] == 35.0
|
||||
assert state.attributes["target_temp_step"] == 0.1
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.AUTO, HVACMode.HEAT]
|
||||
assert ATTR_PRESET_MODES in state.attributes
|
||||
assert "no_frost" in state.attributes[ATTR_PRESET_MODES]
|
||||
assert PRESET_HOME in state.attributes[ATTR_PRESET_MODES]
|
||||
assert state.attributes[ATTR_PRESET_MODE] == "asleep"
|
||||
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 17.2
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 15.0
|
||||
assert state.attributes[ATTR_MIN_TEMP] == 0.0
|
||||
assert state.attributes[ATTR_MAX_TEMP] == 35.0
|
||||
assert state.attributes[ATTR_TARGET_TEMP_STEP] == 0.1
|
||||
|
||||
|
||||
async def test_adam_2_climate_entity_attributes(
|
||||
|
@ -67,8 +86,8 @@ async def test_adam_2_climate_entity_attributes(
|
|||
state = hass.states.get("climate.living_room")
|
||||
assert state
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes["hvac_action"] == "preheating"
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.PREHEATING
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [
|
||||
HVACMode.OFF,
|
||||
HVACMode.AUTO,
|
||||
HVACMode.HEAT,
|
||||
|
@ -77,8 +96,8 @@ async def test_adam_2_climate_entity_attributes(
|
|||
state = hass.states.get("climate.bathroom")
|
||||
assert state
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes["hvac_action"] == "idle"
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [
|
||||
HVACMode.OFF,
|
||||
HVACMode.AUTO,
|
||||
HVACMode.HEAT,
|
||||
|
@ -95,8 +114,8 @@ async def test_adam_3_climate_entity_attributes(
|
|||
state = hass.states.get("climate.living_room")
|
||||
assert state
|
||||
assert state.state == HVACMode.COOL
|
||||
assert state.attributes["hvac_action"] == "cooling"
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [
|
||||
HVACMode.OFF,
|
||||
HVACMode.AUTO,
|
||||
HVACMode.COOL,
|
||||
|
@ -105,7 +124,9 @@ async def test_adam_3_climate_entity_attributes(
|
|||
data.devices["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = (
|
||||
"heating"
|
||||
)
|
||||
data.devices["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = "heating"
|
||||
data.devices["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = (
|
||||
HVACAction.HEATING
|
||||
)
|
||||
data.devices["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
|
||||
"cooling_state"
|
||||
] = False
|
||||
|
@ -120,8 +141,8 @@ async def test_adam_3_climate_entity_attributes(
|
|||
state = hass.states.get("climate.living_room")
|
||||
assert state
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes["hvac_action"] == "heating"
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [
|
||||
HVACMode.OFF,
|
||||
HVACMode.AUTO,
|
||||
HVACMode.HEAT,
|
||||
|
@ -131,7 +152,9 @@ async def test_adam_3_climate_entity_attributes(
|
|||
data.devices["da224107914542988a88561b4452b0f6"]["select_regulation_mode"] = (
|
||||
"cooling"
|
||||
)
|
||||
data.devices["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = "cooling"
|
||||
data.devices["f2bf9048bef64cc5b6d5110154e33c81"]["control_state"] = (
|
||||
HVACAction.COOLING
|
||||
)
|
||||
data.devices["056ee145a816487eaa69243c3280f8bf"]["binary_sensors"][
|
||||
"cooling_state"
|
||||
] = True
|
||||
|
@ -146,8 +169,8 @@ async def test_adam_3_climate_entity_attributes(
|
|||
state = hass.states.get("climate.living_room")
|
||||
assert state
|
||||
assert state.state == HVACMode.COOL
|
||||
assert state.attributes["hvac_action"] == "cooling"
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [
|
||||
HVACMode.OFF,
|
||||
HVACMode.AUTO,
|
||||
HVACMode.COOL,
|
||||
|
@ -164,7 +187,7 @@ async def test_adam_climate_adjust_negative_testing(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{"entity_id": "climate.woonkamer", "temperature": 25},
|
||||
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_TEMPERATURE: 25},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -176,7 +199,7 @@ async def test_adam_climate_entity_climate_changes(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{"entity_id": "climate.woonkamer", "temperature": 25},
|
||||
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_TEMPERATURE: 25},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_smile_adam.set_temperature.call_count == 1
|
||||
|
@ -188,9 +211,9 @@ async def test_adam_climate_entity_climate_changes(
|
|||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{
|
||||
"entity_id": "climate.woonkamer",
|
||||
"hvac_mode": "heat",
|
||||
"temperature": 25,
|
||||
ATTR_ENTITY_ID: "climate.woonkamer",
|
||||
ATTR_HVAC_MODE: HVACMode.HEAT,
|
||||
ATTR_TEMPERATURE: 25,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -199,43 +222,43 @@ async def test_adam_climate_entity_climate_changes(
|
|||
"c50f167537524366a5af7aa3942feb1e", {"setpoint": 25.0}
|
||||
)
|
||||
|
||||
with pytest.raises(ServiceValidationError):
|
||||
with pytest.raises(ServiceValidationError, match="Accepted range"):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{"entity_id": "climate.woonkamer", "temperature": 150},
|
||||
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_TEMPERATURE: 150},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{"entity_id": "climate.woonkamer", "preset_mode": "away"},
|
||||
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_smile_adam.set_preset.call_count == 1
|
||||
mock_smile_adam.set_preset.assert_called_with(
|
||||
"c50f167537524366a5af7aa3942feb1e", "away"
|
||||
"c50f167537524366a5af7aa3942feb1e", PRESET_AWAY
|
||||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.woonkamer", "hvac_mode": "heat"},
|
||||
{ATTR_ENTITY_ID: "climate.woonkamer", ATTR_HVAC_MODE: HVACMode.HEAT},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_smile_adam.set_schedule_state.call_count == 2
|
||||
mock_smile_adam.set_schedule_state.assert_called_with(
|
||||
"c50f167537524366a5af7aa3942feb1e", "off"
|
||||
"c50f167537524366a5af7aa3942feb1e", HVACMode.OFF
|
||||
)
|
||||
|
||||
with pytest.raises(ServiceValidationError):
|
||||
with pytest.raises(ServiceValidationError, match="valid modes are"):
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{
|
||||
"entity_id": "climate.jessie",
|
||||
"hvac_mode": "dry",
|
||||
ATTR_ENTITY_ID: "climate.jessie",
|
||||
ATTR_HVAC_MODE: HVACMode.DRY,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -254,8 +277,8 @@ async def test_adam_climate_off_mode_change(
|
|||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{
|
||||
"entity_id": "climate.slaapkamer",
|
||||
"hvac_mode": "heat",
|
||||
ATTR_ENTITY_ID: "climate.slaapkamer",
|
||||
ATTR_HVAC_MODE: HVACMode.HEAT,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -270,8 +293,8 @@ async def test_adam_climate_off_mode_change(
|
|||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{
|
||||
"entity_id": "climate.kinderkamer",
|
||||
"hvac_mode": "off",
|
||||
ATTR_ENTITY_ID: "climate.kinderkamer",
|
||||
ATTR_HVAC_MODE: HVACMode.OFF,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -286,8 +309,8 @@ async def test_adam_climate_off_mode_change(
|
|||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{
|
||||
"entity_id": "climate.logeerkamer",
|
||||
"hvac_mode": "heat",
|
||||
ATTR_ENTITY_ID: "climate.logeerkamer",
|
||||
ATTR_HVAC_MODE: HVACMode.HEAT,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -304,20 +327,20 @@ async def test_anna_climate_entity_attributes(
|
|||
state = hass.states.get("climate.anna")
|
||||
assert state
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes["hvac_action"] == "heating"
|
||||
assert state.attributes["hvac_modes"] == [HVACMode.AUTO, HVACMode.HEAT_COOL]
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.HEATING
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.AUTO, HVACMode.HEAT_COOL]
|
||||
|
||||
assert "no_frost" in state.attributes["preset_modes"]
|
||||
assert "home" in state.attributes["preset_modes"]
|
||||
assert "no_frost" in state.attributes[ATTR_PRESET_MODES]
|
||||
assert PRESET_HOME in state.attributes[ATTR_PRESET_MODES]
|
||||
|
||||
assert state.attributes["current_temperature"] == 19.3
|
||||
assert state.attributes["preset_mode"] == "home"
|
||||
assert state.attributes["supported_features"] == 18
|
||||
assert state.attributes["target_temp_high"] == 30
|
||||
assert state.attributes["target_temp_low"] == 20.5
|
||||
assert state.attributes["min_temp"] == 4
|
||||
assert state.attributes["max_temp"] == 30
|
||||
assert state.attributes["target_temp_step"] == 0.1
|
||||
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 19.3
|
||||
assert state.attributes[ATTR_PRESET_MODE] == PRESET_HOME
|
||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 18
|
||||
assert state.attributes[ATTR_TARGET_TEMP_HIGH] == 30
|
||||
assert state.attributes[ATTR_TARGET_TEMP_LOW] == 20.5
|
||||
assert state.attributes[ATTR_MIN_TEMP] == 4
|
||||
assert state.attributes[ATTR_MAX_TEMP] == 30
|
||||
assert state.attributes[ATTR_TARGET_TEMP_STEP] == 0.1
|
||||
|
||||
|
||||
async def test_anna_2_climate_entity_attributes(
|
||||
|
@ -329,14 +352,14 @@ async def test_anna_2_climate_entity_attributes(
|
|||
state = hass.states.get("climate.anna")
|
||||
assert state
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes["hvac_action"] == "cooling"
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.COOLING
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [
|
||||
HVACMode.AUTO,
|
||||
HVACMode.HEAT_COOL,
|
||||
]
|
||||
assert state.attributes["supported_features"] == 18
|
||||
assert state.attributes["target_temp_high"] == 30
|
||||
assert state.attributes["target_temp_low"] == 20.5
|
||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 18
|
||||
assert state.attributes[ATTR_TARGET_TEMP_HIGH] == 30
|
||||
assert state.attributes[ATTR_TARGET_TEMP_LOW] == 20.5
|
||||
|
||||
|
||||
async def test_anna_3_climate_entity_attributes(
|
||||
|
@ -348,8 +371,8 @@ async def test_anna_3_climate_entity_attributes(
|
|||
state = hass.states.get("climate.anna")
|
||||
assert state
|
||||
assert state.state == HVACMode.AUTO
|
||||
assert state.attributes["hvac_action"] == "idle"
|
||||
assert state.attributes["hvac_modes"] == [
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == HVACAction.IDLE
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [
|
||||
HVACMode.AUTO,
|
||||
HVACMode.HEAT_COOL,
|
||||
]
|
||||
|
@ -365,7 +388,11 @@ async def test_anna_climate_entity_climate_changes(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{"entity_id": "climate.anna", "target_temp_high": 30, "target_temp_low": 20},
|
||||
{
|
||||
ATTR_ENTITY_ID: "climate.anna",
|
||||
ATTR_TARGET_TEMP_HIGH: 30,
|
||||
ATTR_TARGET_TEMP_LOW: 20,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_smile_anna.set_temperature.call_count == 1
|
||||
|
@ -377,18 +404,18 @@ async def test_anna_climate_entity_climate_changes(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{"entity_id": "climate.anna", "preset_mode": "away"},
|
||||
{ATTR_ENTITY_ID: "climate.anna", ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_smile_anna.set_preset.call_count == 1
|
||||
mock_smile_anna.set_preset.assert_called_with(
|
||||
"c784ee9fdab44e1395b8dee7d7a497d5", "away"
|
||||
"c784ee9fdab44e1395b8dee7d7a497d5", PRESET_AWAY
|
||||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.anna", "hvac_mode": "auto"},
|
||||
{ATTR_ENTITY_ID: "climate.anna", ATTR_HVAC_MODE: HVACMode.AUTO},
|
||||
blocking=True,
|
||||
)
|
||||
# hvac_mode is already auto so not called.
|
||||
|
@ -397,12 +424,12 @@ async def test_anna_climate_entity_climate_changes(
|
|||
await hass.services.async_call(
|
||||
CLIMATE_DOMAIN,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{"entity_id": "climate.anna", "hvac_mode": "heat_cool"},
|
||||
{ATTR_ENTITY_ID: "climate.anna", ATTR_HVAC_MODE: HVACMode.HEAT_COOL},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_smile_anna.set_schedule_state.call_count == 1
|
||||
mock_smile_anna.set_schedule_state.assert_called_with(
|
||||
"c784ee9fdab44e1395b8dee7d7a497d5", "off"
|
||||
"c784ee9fdab44e1395b8dee7d7a497d5", HVACMode.OFF
|
||||
)
|
||||
|
||||
data = mock_smile_anna.async_update.return_value
|
||||
|
@ -414,4 +441,4 @@ async def test_anna_climate_entity_climate_changes(
|
|||
|
||||
state = hass.states.get("climate.anna")
|
||||
assert state.state == HVACMode.HEAT
|
||||
assert state.attributes["hvac_modes"] == [HVACMode.HEAT_COOL]
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [HVACMode.HEAT_COOL]
|
||||
|
|
|
@ -19,7 +19,6 @@ from homeassistant.config_entries import ConfigEntryState
|
|||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
@ -118,7 +117,7 @@ async def test_device_in_dr(
|
|||
) -> None:
|
||||
"""Test Gateway device registry data."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device_entry = device_registry.async_get_device(
|
||||
|
@ -237,7 +236,7 @@ async def test_update_device(
|
|||
data = mock_smile_adam_2.async_update.return_value
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.number import (
|
||||
ATTR_VALUE,
|
||||
DOMAIN as NUMBER_DOMAIN,
|
||||
|
@ -9,6 +11,7 @@ from homeassistant.components.number import (
|
|||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -101,3 +104,19 @@ async def test_adam_temperature_offset_change(
|
|||
mock_smile_adam.set_number.assert_called_with(
|
||||
"6a3bf693d05e48e0b460c815a4fdd09d", "temperature_offset", 1.0
|
||||
)
|
||||
|
||||
|
||||
async def test_adam_temperature_offset_out_of_bounds_change(
|
||||
hass: HomeAssistant, mock_smile_adam: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test changing of the temperature_offset number beyond limits."""
|
||||
with pytest.raises(ServiceValidationError, match="valid range"):
|
||||
await hass.services.async_call(
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{
|
||||
ATTR_ENTITY_ID: "number.zone_thermostat_jessie_temperature_offset",
|
||||
ATTR_VALUE: 3.0,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.select import (
|
||||
ATTR_OPTION,
|
||||
DOMAIN as SELECT_DOMAIN,
|
||||
|
@ -9,6 +11,7 @@ from homeassistant.components.select import (
|
|||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -65,8 +68,8 @@ async def test_adam_select_regulation_mode(
|
|||
SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
{
|
||||
"entity_id": "select.adam_regulation_mode",
|
||||
"option": "heating",
|
||||
ATTR_ENTITY_ID: "select.adam_regulation_mode",
|
||||
ATTR_OPTION: "heating",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -86,3 +89,20 @@ async def test_legacy_anna_select_entities(
|
|||
) -> None:
|
||||
"""Test not creating a select-entity for a legacy Anna without a thermostat-schedule."""
|
||||
assert not hass.states.get("select.anna_thermostat_schedule")
|
||||
|
||||
|
||||
async def test_adam_select_unavailable_regulation_mode(
|
||||
hass: HomeAssistant, mock_smile_anna: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test a regulation_mode non-available preset."""
|
||||
|
||||
with pytest.raises(ServiceValidationError, match="valid options"):
|
||||
await hass.services.async_call(
|
||||
SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
{
|
||||
ATTR_ENTITY_ID: "select.anna_thermostat_schedule",
|
||||
ATTR_OPTION: "freezing",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.plugwise.const import DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -135,6 +137,7 @@ async def test_p1_dsmr_sensor_entities(
|
|||
assert not state
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_p1_3ph_dsmr_sensor_entities(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
|
@ -154,21 +157,23 @@ async def test_p1_3ph_dsmr_sensor_entities(
|
|||
assert state
|
||||
assert int(state.state) == 2080
|
||||
|
||||
entity_id = "sensor.p1_voltage_phase_one"
|
||||
state = hass.states.get(entity_id)
|
||||
assert not state
|
||||
|
||||
entity_registry.async_update_entity(entity_id=entity_id, disabled_by=None)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await hass.config_entries.async_reload(init_integration.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Default disabled sensor test
|
||||
state = hass.states.get("sensor.p1_voltage_phase_one")
|
||||
assert state
|
||||
assert float(state.state) == 233.2
|
||||
|
||||
|
||||
async def test_p1_3ph_dsmr_sensor_disabled_entities(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_smile_p1_2: MagicMock,
|
||||
init_integration: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test disabled power related sensor entities intent."""
|
||||
state = hass.states.get("sensor.p1_voltage_phase_one")
|
||||
assert not state
|
||||
|
||||
|
||||
async def test_stretch_sensor_entities(
|
||||
hass: HomeAssistant, mock_stretch: MagicMock, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
|
|
|
@ -8,6 +8,7 @@ import pytest
|
|||
from homeassistant.components.plugwise.const import DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
SERVICE_TOGGLE,
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
|
@ -44,7 +45,7 @@ async def test_adam_climate_switch_negative_testing(
|
|||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{"entity_id": "switch.cv_pomp_relay"},
|
||||
{ATTR_ENTITY_ID: "switch.cv_pomp_relay"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -57,7 +58,7 @@ async def test_adam_climate_switch_negative_testing(
|
|||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{"entity_id": "switch.fibaro_hc2_relay"},
|
||||
{ATTR_ENTITY_ID: "switch.fibaro_hc2_relay"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -74,7 +75,7 @@ async def test_adam_climate_switch_changes(
|
|||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{"entity_id": "switch.cv_pomp_relay"},
|
||||
{ATTR_ENTITY_ID: "switch.cv_pomp_relay"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -86,7 +87,7 @@ async def test_adam_climate_switch_changes(
|
|||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TOGGLE,
|
||||
{"entity_id": "switch.fibaro_hc2_relay"},
|
||||
{ATTR_ENTITY_ID: "switch.fibaro_hc2_relay"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -98,7 +99,7 @@ async def test_adam_climate_switch_changes(
|
|||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{"entity_id": "switch.fibaro_hc2_relay"},
|
||||
{ATTR_ENTITY_ID: "switch.fibaro_hc2_relay"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
@ -128,7 +129,7 @@ async def test_stretch_switch_changes(
|
|||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
{"entity_id": "switch.koelkast_92c4a_relay"},
|
||||
{ATTR_ENTITY_ID: "switch.koelkast_92c4a_relay"},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_stretch.set_switch_state.call_count == 1
|
||||
|
@ -139,7 +140,7 @@ async def test_stretch_switch_changes(
|
|||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TOGGLE,
|
||||
{"entity_id": "switch.droger_52559_relay"},
|
||||
{ATTR_ENTITY_ID: "switch.droger_52559_relay"},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_stretch.set_switch_state.call_count == 2
|
||||
|
@ -150,7 +151,7 @@ async def test_stretch_switch_changes(
|
|||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{"entity_id": "switch.droger_52559_relay"},
|
||||
{ATTR_ENTITY_ID: "switch.droger_52559_relay"},
|
||||
blocking=True,
|
||||
)
|
||||
assert mock_stretch.set_switch_state.call_count == 3
|
||||
|
|
Loading…
Reference in New Issue