Add to demo

This commit is contained in:
G Johansson 2025-07-05 15:24:57 +00:00
parent ec47ef7cdb
commit a63c30a1a2

View File

@ -30,11 +30,27 @@ async def async_setup_entry(
async_add_entities( async_add_entities(
[ [
DemoWaterHeater( DemoWaterHeater(
"Demo Water Heater", 119, UnitOfTemperature.FAHRENHEIT, False, "eco", 1 "Demo Water Heater",
119,
None,
UnitOfTemperature.FAHRENHEIT,
False,
"eco",
1,
), ),
DemoWaterHeater( DemoWaterHeater(
"Demo Water Heater Celsius", "Demo Water Heater Celsius",
45, 45,
None,
UnitOfTemperature.CELSIUS,
True,
"eco",
1,
),
DemoWaterHeater(
"Demo Water Heater Range",
None,
(45, 60),
UnitOfTemperature.CELSIUS, UnitOfTemperature.CELSIUS,
True, True,
"eco", "eco",
@ -53,7 +69,8 @@ class DemoWaterHeater(WaterHeaterEntity):
def __init__( def __init__(
self, self,
name: str, name: str,
target_temperature: int, target_temperature: int | None,
target_temperature_range: tuple[int, int] | None,
unit_of_measurement: str, unit_of_measurement: str,
away: bool, away: bool,
current_operation: str, current_operation: str,
@ -63,11 +80,21 @@ class DemoWaterHeater(WaterHeaterEntity):
self._attr_name = name self._attr_name = name
if target_temperature is not None: if target_temperature is not None:
self._attr_supported_features |= WaterHeaterEntityFeature.TARGET_TEMPERATURE self._attr_supported_features |= WaterHeaterEntityFeature.TARGET_TEMPERATURE
if target_temperature_range is not None:
self._attr_supported_features |= (
WaterHeaterEntityFeature.TARGET_TEMPERATURE_RANGE
)
if away is not None: if away is not None:
self._attr_supported_features |= WaterHeaterEntityFeature.AWAY_MODE self._attr_supported_features |= WaterHeaterEntityFeature.AWAY_MODE
if current_operation is not None: if current_operation is not None:
self._attr_supported_features |= WaterHeaterEntityFeature.OPERATION_MODE self._attr_supported_features |= WaterHeaterEntityFeature.OPERATION_MODE
self._attr_target_temperature = target_temperature self._attr_target_temperature = target_temperature
self._attr_target_temperature_low = (
target_temperature_range[0] if target_temperature_range else None
)
self._attr_target_temperature_high = (
target_temperature_range[1] if target_temperature_range else None
)
self._attr_temperature_unit = unit_of_measurement self._attr_temperature_unit = unit_of_measurement
self._attr_is_away_mode_on = away self._attr_is_away_mode_on = away
self._attr_current_operation = current_operation self._attr_current_operation = current_operation