mirror of
https://github.com/home-assistant/core.git
synced 2026-03-21 10:14:52 +01:00
Compare commits
2 Commits
setpoint_c
...
water_heat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dabc0acb41 | ||
|
|
47fd3533a0 |
@@ -73,6 +73,7 @@ ATTR_TARGET_TEMP_HIGH = "target_temp_high"
|
||||
ATTR_TARGET_TEMP_LOW = "target_temp_low"
|
||||
ATTR_TARGET_TEMP_STEP = "target_temp_step"
|
||||
ATTR_CURRENT_TEMPERATURE = "current_temperature"
|
||||
ATTR_TEMPERATURE_UNIT = "temperature_unit"
|
||||
|
||||
CONVERTIBLE_ATTRIBUTE = [ATTR_TEMPERATURE]
|
||||
|
||||
@@ -245,6 +246,7 @@ class WaterHeaterEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
||||
self.temperature_unit,
|
||||
self.precision,
|
||||
),
|
||||
ATTR_TEMPERATURE_UNIT: self.hass.config.units.temperature_unit,
|
||||
}
|
||||
|
||||
supported_features = self.supported_features
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': 130,
|
||||
'temperature_unit': <UnitOfTemperature.FAHRENHEIT: '°F'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.my_water_heater',
|
||||
@@ -123,6 +124,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': 130,
|
||||
'temperature_unit': <UnitOfTemperature.FAHRENHEIT: '°F'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.my_water_heater',
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': 50.0,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.bsb_lan',
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
'target_temp_low': None,
|
||||
'target_temp_step': 1,
|
||||
'temperature': 55.0,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.r_900',
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': None,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.domestic_hot_water',
|
||||
@@ -104,6 +105,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': None,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.domestic_hot_water',
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': None,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.boiler',
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': 65,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.water_heater',
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
'target_temp_high': 63,
|
||||
'target_temp_low': 57,
|
||||
'temperature': 60,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.test_device',
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
'target_temp_high': 69,
|
||||
'target_temp_low': 38,
|
||||
'temperature': 56,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.heat_pump',
|
||||
@@ -140,6 +141,7 @@
|
||||
'target_temp_high': 55,
|
||||
'target_temp_low': 40,
|
||||
'temperature': 48,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.eco_heating_system',
|
||||
@@ -216,6 +218,7 @@
|
||||
'target_temp_high': 57,
|
||||
'target_temp_low': 40,
|
||||
'temperature': 52,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.warmepumpe',
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': 30.0,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.second_water_heater',
|
||||
@@ -132,6 +133,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': 65.0,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.water_heater',
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': None,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.model0_domestic_hot_water',
|
||||
@@ -110,6 +111,7 @@
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'temperature': None,
|
||||
'temperature_unit': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'water_heater.model0_domestic_hot_water_2',
|
||||
|
||||
@@ -32,6 +32,47 @@ from tests.common import (
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry_water_heater(
|
||||
hass: HomeAssistant, water_heater_entity: WaterHeaterEntity
|
||||
) -> None:
|
||||
"""Set up test config entry and platform."""
|
||||
|
||||
async def async_setup_entry_init(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry
|
||||
) -> bool:
|
||||
"""Set up test config entry."""
|
||||
await hass.config_entries.async_forward_entry_setups(
|
||||
config_entry, [Platform.WATER_HEATER]
|
||||
)
|
||||
return True
|
||||
|
||||
async def async_setup_entry_water_heater_platform(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up test water_heater platform via config entry."""
|
||||
async_add_entities([water_heater_entity])
|
||||
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule(
|
||||
"test",
|
||||
async_setup_entry=async_setup_entry_init,
|
||||
),
|
||||
built_in=False,
|
||||
)
|
||||
mock_platform(
|
||||
hass,
|
||||
"test.water_heater",
|
||||
MockPlatform(async_setup_entry=async_setup_entry_water_heater_platform),
|
||||
)
|
||||
|
||||
config_entry = MockConfigEntry(domain="test")
|
||||
config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_set_temp_schema_no_req(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
@@ -131,40 +172,7 @@ async def test_operation_mode_validation(
|
||||
water_heater_entity._attr_current_operation = None
|
||||
water_heater_entity._attr_operation_list = None
|
||||
|
||||
async def async_setup_entry_init(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry
|
||||
) -> bool:
|
||||
"""Set up test config entry."""
|
||||
await hass.config_entries.async_forward_entry_setups(
|
||||
config_entry, [Platform.WATER_HEATER]
|
||||
)
|
||||
return True
|
||||
|
||||
async def async_setup_entry_water_heater_platform(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up test water_heater platform via config entry."""
|
||||
async_add_entities([water_heater_entity])
|
||||
|
||||
mock_integration(
|
||||
hass,
|
||||
MockModule(
|
||||
"test",
|
||||
async_setup_entry=async_setup_entry_init,
|
||||
),
|
||||
built_in=False,
|
||||
)
|
||||
mock_platform(
|
||||
hass,
|
||||
"test.water_heater",
|
||||
MockPlatform(async_setup_entry=async_setup_entry_water_heater_platform),
|
||||
)
|
||||
|
||||
config_entry = MockConfigEntry(domain="test")
|
||||
config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await async_setup_entry_water_heater(hass, water_heater_entity)
|
||||
|
||||
data = {"entity_id": "water_heater.test", "operation_mode": "test"}
|
||||
|
||||
@@ -206,3 +214,35 @@ async def test_operation_mode_validation(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
water_heater_entity.set_operation_mode.assert_has_calls([mock.call("eco")])
|
||||
|
||||
|
||||
async def test_default_state(hass: HomeAssistant, config_flow_fixture: None) -> None:
|
||||
"""Test operation mode validation."""
|
||||
water_heater_entity = MockWaterHeaterEntity()
|
||||
water_heater_entity.hass = hass
|
||||
water_heater_entity._attr_name = "test"
|
||||
water_heater_entity._attr_unique_id = "test"
|
||||
water_heater_entity._attr_supported_features = (
|
||||
WaterHeaterEntityFeature.OPERATION_MODE
|
||||
)
|
||||
water_heater_entity._attr_current_operation = None
|
||||
water_heater_entity._attr_operation_list = None
|
||||
|
||||
await async_setup_entry_water_heater(hass, water_heater_entity)
|
||||
|
||||
state = hass.states.get("water_heater.test")
|
||||
assert state is not None
|
||||
assert state.state == "unknown"
|
||||
assert state.attributes == {
|
||||
"current_temperature": None,
|
||||
"friendly_name": "test",
|
||||
"max_temp": 60.0,
|
||||
"min_temp": 43.3,
|
||||
"operation_list": None,
|
||||
"operation_mode": None,
|
||||
"supported_features": WaterHeaterEntityFeature.OPERATION_MODE,
|
||||
"target_temp_high": None,
|
||||
"target_temp_low": None,
|
||||
"temperature": None,
|
||||
"temperature_unit": UnitOfTemperature.CELSIUS,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user