1 """BSBLAN platform to control a compatible Climate Device."""
3 from __future__
import annotations
7 from bsblan
import BSBLANError
25 from .
import BSBLanConfigEntry, BSBLanData
26 from .const
import ATTR_TARGET_TEMPERATURE, DOMAIN
27 from .entity
import BSBLanEntity
45 entry: BSBLanConfigEntry,
46 async_add_entities: AddEntitiesCallback,
48 """Set up BSBLAN device based on a config entry."""
49 data = entry.runtime_data
54 """Defines a BSBLAN climate device."""
56 _attr_has_entity_name =
True
59 _attr_supported_features = (
60 ClimateEntityFeature.TARGET_TEMPERATURE
61 | ClimateEntityFeature.PRESET_MODE
62 | ClimateEntityFeature.TURN_OFF
63 | ClimateEntityFeature.TURN_ON
66 _attr_preset_modes = PRESET_MODES
67 _attr_hvac_modes = HVAC_MODES
68 _enable_turn_on_off_backwards_compatibility =
False
74 """Initialize BSBLAN climate device."""
75 super().
__init__(data.coordinator, data)
84 """Return the current temperature."""
85 return self.coordinator.data.state.current_temperature.value
89 """Return the temperature we try to reach."""
90 return self.coordinator.data.state.target_temperature.value
94 """Return hvac operation ie. heat, cool mode."""
95 if self.coordinator.data.state.hvac_mode.value == PRESET_ECO:
97 return try_parse_enum(HVACMode, self.coordinator.data.state.hvac_mode.value)
101 """Return the current preset mode."""
104 and self.coordinator.data.state.hvac_mode.value == PRESET_ECO
114 """Set preset mode."""
117 "Preset mode can only be set when HVAC mode is set to 'auto'",
118 translation_domain=DOMAIN,
119 translation_key=
"set_preset_mode_error",
120 translation_placeholders={
"preset_mode": preset_mode},
125 """Set new target temperatures."""
129 """Set device settings using BSBLAN."""
131 if ATTR_TEMPERATURE
in kwargs:
132 data[ATTR_TARGET_TEMPERATURE] = kwargs[ATTR_TEMPERATURE]
133 if ATTR_HVAC_MODE
in kwargs:
134 data[ATTR_HVAC_MODE] = kwargs[ATTR_HVAC_MODE]
135 if ATTR_PRESET_MODE
in kwargs:
136 if kwargs[ATTR_PRESET_MODE] == PRESET_ECO:
137 data[ATTR_HVAC_MODE] = PRESET_ECO
138 elif kwargs[ATTR_PRESET_MODE] == PRESET_NONE:
139 data[ATTR_HVAC_MODE] = PRESET_NONE
142 await self.coordinator.client.thermostat(**data)
143 except BSBLANError
as err:
145 "An error occurred while updating the BSBLAN device",
146 translation_domain=DOMAIN,
147 translation_key=
"set_data_error",
None async_set_hvac_mode(self, HVACMode hvac_mode)
None __init__(self, BSBLanData data)
str|None preset_mode(self)
None async_set_preset_mode(self, str preset_mode)
HVACMode|None hvac_mode(self)
float|None target_temperature(self)
None async_set_temperature(self, **Any kwargs)
None async_set_data(self, **Any kwargs)
float|None current_temperature(self)
HVACMode|None hvac_mode(self)
None async_request_refresh(self)
None async_setup_entry(HomeAssistant hass, BSBLanConfigEntry entry, AddEntitiesCallback async_add_entities)