Return expected state in SmartThings water heater (#146449)

This commit is contained in:
Joost Lekkerkerker 2025-06-10 14:52:24 +02:00 committed by GitHub
parent b77ef7304a
commit 110627e16e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 39 additions and 42 deletions

View File

@ -619,15 +619,6 @@
"keep_fresh_mode": {
"name": "Keep fresh mode"
}
},
"water_heater": {
"water_heater": {
"state": {
"standard": "Standard",
"force": "Forced",
"power": "Power"
}
}
}
},
"issues": {

View File

@ -10,6 +10,9 @@ from homeassistant.components.water_heater import (
DEFAULT_MAX_TEMP,
DEFAULT_MIN_TEMP,
STATE_ECO,
STATE_HEAT_PUMP,
STATE_HIGH_DEMAND,
STATE_PERFORMANCE,
WaterHeaterEntity,
WaterHeaterEntityFeature,
)
@ -24,9 +27,9 @@ from .entity import SmartThingsEntity
OPERATION_MAP_TO_HA: dict[str, str] = {
"eco": STATE_ECO,
"std": "standard",
"force": "force",
"power": "power",
"std": STATE_HEAT_PUMP,
"force": STATE_HIGH_DEMAND,
"power": STATE_PERFORMANCE,
}
HA_TO_OPERATION_MAP = {v: k for k, v in OPERATION_MAP_TO_HA.items()}

View File

@ -10,9 +10,9 @@
'operation_list': list([
'off',
'eco',
'standard',
'power',
'force',
'heat_pump',
'performance',
'high_demand',
]),
}),
'config_entry_id': <ANY>,
@ -55,9 +55,9 @@
'operation_list': list([
'off',
'eco',
'standard',
'power',
'force',
'heat_pump',
'performance',
'high_demand',
]),
'operation_mode': 'off',
'supported_features': <WaterHeaterEntityFeature: 14>,
@ -84,8 +84,8 @@
'operation_list': list([
'off',
'eco',
'standard',
'force',
'heat_pump',
'high_demand',
]),
}),
'config_entry_id': <ANY>,
@ -128,8 +128,8 @@
'operation_list': list([
'off',
'eco',
'standard',
'force',
'heat_pump',
'high_demand',
]),
'operation_mode': 'off',
'supported_features': <WaterHeaterEntityFeature: 14>,
@ -156,9 +156,9 @@
'operation_list': list([
'off',
'eco',
'standard',
'power',
'force',
'heat_pump',
'performance',
'high_demand',
]),
}),
'config_entry_id': <ANY>,
@ -201,11 +201,11 @@
'operation_list': list([
'off',
'eco',
'standard',
'power',
'force',
'heat_pump',
'performance',
'high_demand',
]),
'operation_mode': 'standard',
'operation_mode': 'heat_pump',
'supported_features': <WaterHeaterEntityFeature: 15>,
'target_temp_high': 57,
'target_temp_low': 40,
@ -216,6 +216,6 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'standard',
'state': 'heat_pump',
})
# ---

View File

@ -20,6 +20,9 @@ from homeassistant.components.water_heater import (
SERVICE_SET_OPERATION_MODE,
SERVICE_SET_TEMPERATURE,
STATE_ECO,
STATE_HEAT_PUMP,
STATE_HIGH_DEMAND,
STATE_PERFORMANCE,
WaterHeaterEntityFeature,
)
from homeassistant.const import (
@ -66,9 +69,9 @@ async def test_all_entities(
("operation_mode", "argument"),
[
(STATE_ECO, "eco"),
("standard", "std"),
("force", "force"),
("power", "power"),
(STATE_HEAT_PUMP, "std"),
(STATE_HIGH_DEMAND, "force"),
(STATE_PERFORMANCE, "power"),
],
)
async def test_set_operation_mode(
@ -299,9 +302,9 @@ async def test_operation_list_update(
] == [
STATE_OFF,
STATE_ECO,
"standard",
"power",
"force",
STATE_HEAT_PUMP,
STATE_PERFORMANCE,
STATE_HIGH_DEMAND,
]
await trigger_update(
@ -318,8 +321,8 @@ async def test_operation_list_update(
] == [
STATE_OFF,
STATE_ECO,
"force",
"power",
STATE_HIGH_DEMAND,
STATE_PERFORMANCE,
]
@ -332,7 +335,7 @@ async def test_current_operation_update(
"""Test state update."""
await setup_integration(hass, mock_config_entry)
assert hass.states.get("water_heater.warmepumpe").state == "standard"
assert hass.states.get("water_heater.warmepumpe").state == STATE_HEAT_PUMP
await trigger_update(
hass,
@ -356,7 +359,7 @@ async def test_switch_update(
await setup_integration(hass, mock_config_entry)
state = hass.states.get("water_heater.warmepumpe")
assert state.state == "standard"
assert state.state == STATE_HEAT_PUMP
assert (
state.attributes[ATTR_SUPPORTED_FEATURES]
== WaterHeaterEntityFeature.ON_OFF
@ -516,7 +519,7 @@ async def test_availability(
"""Test availability."""
await setup_integration(hass, mock_config_entry)
assert hass.states.get("water_heater.warmepumpe").state == "standard"
assert hass.states.get("water_heater.warmepumpe").state == STATE_HEAT_PUMP
await trigger_health_update(
hass, devices, "3810e5ad-5351-d9f9-12ff-000001200000", HealthStatus.OFFLINE
@ -528,7 +531,7 @@ async def test_availability(
hass, devices, "3810e5ad-5351-d9f9-12ff-000001200000", HealthStatus.ONLINE
)
assert hass.states.get("water_heater.warmepumpe").state == "standard"
assert hass.states.get("water_heater.warmepumpe").state == STATE_HEAT_PUMP
@pytest.mark.parametrize("device_fixture", ["da_sac_ehs_000002_sub"])