1 """The Flexit Nordic (BACnet) integration."""
3 import asyncio.exceptions
6 from flexit_bacnet
import (
11 from flexit_bacnet.bacnet
import DecodingError
32 PRESET_TO_VENTILATION_MODE_MAP,
33 VENTILATION_TO_PRESET_MODE_MAP,
35 from .coordinator
import FlexitCoordinator
36 from .entity
import FlexitEntity
41 config_entry: ConfigEntry,
42 async_add_entities: AddEntitiesCallback,
44 """Set up the Flexit Nordic unit."""
45 coordinator: FlexitCoordinator = hass.data[DOMAIN][config_entry.entry_id]
51 """Flexit air handling unit."""
60 _attr_preset_modes = [
66 _attr_supported_features = (
67 ClimateEntityFeature.PRESET_MODE
68 | ClimateEntityFeature.TARGET_TEMPERATURE
69 | ClimateEntityFeature.TURN_OFF
70 | ClimateEntityFeature.TURN_ON
73 _attr_target_temperature_step = PRECISION_HALVES
74 _attr_temperature_unit = UnitOfTemperature.CELSIUS
75 _attr_max_temp = MAX_TEMP
76 _attr_min_temp = MIN_TEMP
77 _enable_turn_on_off_backwards_compatibility =
False
79 def __init__(self, coordinator: FlexitCoordinator) ->
None:
80 """Initialize the Flexit unit."""
85 """Refresh unit state."""
90 """Return current HVAC action."""
92 return HVACAction.HEATING
97 """Return the current temperature."""
102 """Return the temperature we try to reach."""
103 if self.
devicedevicedevice.ventilation_mode == VENTILATION_MODE_AWAY:
109 """Set new target temperature."""
110 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is None:
114 if self.
devicedevicedevice.ventilation_mode == VENTILATION_MODE_AWAY:
115 await self.
devicedevicedevice.set_air_temp_setpoint_away(temperature)
117 await self.
devicedevicedevice.set_air_temp_setpoint_home(temperature)
118 except (asyncio.exceptions.TimeoutError, ConnectionError, DecodingError)
as exc:
119 raise HomeAssistantError
from exc
125 """Return the current preset mode, e.g., home, away, temp.
127 Requires ClimateEntityFeature.PRESET_MODE.
129 return VENTILATION_TO_PRESET_MODE_MAP[self.
devicedevicedevice.ventilation_mode]
132 """Set new preset mode."""
133 ventilation_mode = PRESET_TO_VENTILATION_MODE_MAP[preset_mode]
136 await self.
devicedevicedevice.set_ventilation_mode(ventilation_mode)
137 except (asyncio.exceptions.TimeoutError, ConnectionError, DecodingError)
as exc:
138 raise HomeAssistantError
from exc
144 """Return hvac operation ie. heat, cool mode."""
145 if self.
devicedevicedevice.ventilation_mode == VENTILATION_MODE_STOP:
148 return HVACMode.FAN_ONLY
151 """Set new target hvac mode."""
153 if hvac_mode == HVACMode.OFF:
154 await self.
devicedevicedevice.set_ventilation_mode(VENTILATION_MODE_STOP)
156 await self.
devicedevicedevice.set_ventilation_mode(VENTILATION_MODE_HOME)
157 except (asyncio.exceptions.TimeoutError, ConnectionError, DecodingError)
as exc:
158 raise HomeAssistantError
from exc
None async_set_temperature(self, **Any kwargs)
float target_temperature(self)
None __init__(self, FlexitCoordinator coordinator)
float current_temperature(self)
None async_set_preset_mode(self, str preset_mode)
None async_set_hvac_mode(self, HVACMode hvac_mode)
HVACAction|None hvac_action(self)
FlexitBACnet device(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
IssData update(pyiss.ISS iss)