1 """BSBLAN platform to control a compatible Water Heater Device."""
3 from __future__
import annotations
7 from bsblan
import BSBLANError
13 WaterHeaterEntityFeature,
21 from .
import BSBLanConfigEntry, BSBLanData
22 from .const
import DOMAIN
23 from .entity
import BSBLanEntity
34 OPERATION_MODES_REVERSE = {v: k
for k, v
in OPERATION_MODES.items()}
39 entry: BSBLanConfigEntry,
40 async_add_entities: AddEntitiesCallback,
42 """Set up BSBLAN water heater based on a config entry."""
43 data = entry.runtime_data
48 """Defines a BSBLAN water heater entity."""
51 _attr_supported_features = (
52 WaterHeaterEntityFeature.TARGET_TEMPERATURE
53 | WaterHeaterEntityFeature.OPERATION_MODE
57 """Initialize BSBLAN water heater."""
58 super().
__init__(data.coordinator, data)
64 self.
_attr_min_temp_attr_min_temp = data.coordinator.data.dhw.reduced_setpoint.value
65 self.
_attr_max_temp_attr_max_temp = data.coordinator.data.dhw.nominal_setpoint_max.value
69 """Return current operation."""
70 current_mode = self.coordinator.data.dhw.operating_mode.desc
71 return OPERATION_MODES.get(current_mode)
75 """Return the current temperature."""
76 return self.coordinator.data.dhw.dhw_actual_value_top_temperature.value
80 """Return the temperature we try to reach."""
81 return self.coordinator.data.dhw.nominal_setpoint.value
84 """Set new target temperature."""
85 temperature = kwargs.get(ATTR_TEMPERATURE)
87 await self.coordinator.client.set_hot_water(nominal_setpoint=temperature)
88 except BSBLANError
as err:
90 translation_domain=DOMAIN,
91 translation_key=
"set_temperature_error",
97 """Set new operation mode."""
98 bsblan_mode = OPERATION_MODES_REVERSE.get(operation_mode)
100 await self.coordinator.client.set_hot_water(operating_mode=bsblan_mode)
101 except BSBLANError
as err:
103 translation_domain=DOMAIN,
104 translation_key=
"set_operation_mode_error",
None async_set_temperature(self, **Any kwargs)
float|None target_temperature(self)
None __init__(self, BSBLanData data)
float|None current_temperature(self)
str|None current_operation(self)
None async_set_operation_mode(self, str operation_mode)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, BSBLanConfigEntry entry, AddEntitiesCallback async_add_entities)