Home Assistant Unofficial Reference 2024.12.1
climate.py
Go to the documentation of this file.
1 """Support for Big Ass Fans auto comfort."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
8  ClimateEntity,
9  ClimateEntityFeature,
10  HVACAction,
11  HVACMode,
12 )
13 from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
14 from homeassistant.core import HomeAssistant, callback
15 from homeassistant.helpers.entity_platform import AddEntitiesCallback
16 
17 from . import BAFConfigEntry
18 from .entity import BAFEntity
19 
20 
22  hass: HomeAssistant,
23  entry: BAFConfigEntry,
24  async_add_entities: AddEntitiesCallback,
25 ) -> None:
26  """Set up BAF fan auto comfort."""
27  device = entry.runtime_data
28  if device.has_fan and device.has_auto_comfort:
30 
31 
33  """BAF climate auto comfort."""
34 
35  _attr_supported_features = (
36  ClimateEntityFeature.TARGET_TEMPERATURE
37  | ClimateEntityFeature.TURN_OFF
38  | ClimateEntityFeature.TURN_ON
39  )
40  _attr_temperature_unit = UnitOfTemperature.CELSIUS
41  _attr_hvac_modes = [HVACMode.OFF, HVACMode.FAN_ONLY]
42  _attr_translation_key = "auto_comfort"
43  _enable_turn_on_off_backwards_compatibility = False
44 
45  @callback
46  def _async_update_attrs(self) -> None:
47  """Update attrs from device."""
48  device = self._device_device
49  auto_on = device.auto_comfort_enable
50  self._attr_hvac_mode_attr_hvac_mode = HVACMode.FAN_ONLY if auto_on else HVACMode.OFF
51  self._attr_hvac_action_attr_hvac_action = HVACAction.FAN if device.speed else HVACAction.OFF
52  self._attr_target_temperature_attr_target_temperature = device.comfort_ideal_temperature
53  self._attr_current_temperature_attr_current_temperature = device.temperature
54 
55  async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
56  """Set the HVAC mode."""
57  self._device_device.auto_comfort_enable = hvac_mode == HVACMode.FAN_ONLY
58 
59  async def async_set_temperature(self, **kwargs: Any) -> None:
60  """Set the target temperature."""
61  if not self._device_device.auto_comfort_enable:
62  self._device_device.auto_comfort_enable = True
63  self._device_device.comfort_ideal_temperature = kwargs[ATTR_TEMPERATURE]
None async_set_hvac_mode(self, HVACMode hvac_mode)
Definition: climate.py:55
None async_set_temperature(self, **Any kwargs)
Definition: climate.py:59
None async_setup_entry(HomeAssistant hass, BAFConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: climate.py:25