async def async_set_hvac_mode(self, hvac_mode: str) -> None: """Set operation mode.""" if self._device.supports_on_off and hvac_mode == HVAC_MODE_OFF: await self._device.turn_off() else: if self._device.supports_on_off and not self._device.is_on: await self._device.turn_on() if self._device.mode.supports_controller_mode: knx_controller_mode = HVACControllerMode( CONTROLLER_MODES_INV.get(hvac_mode)) await self._device.mode.set_controller_mode(knx_controller_mode ) self.async_write_ha_state()
def __init__( self, xknx: XKNX, name: str, group_address_operation_mode: GroupAddressesType | None = None, group_address_operation_mode_state: GroupAddressesType | None = None, group_address_operation_mode_protection: GroupAddressesType | None = None, group_address_operation_mode_night: GroupAddressesType | None = None, group_address_operation_mode_comfort: GroupAddressesType | None = None, group_address_operation_mode_standby: GroupAddressesType | None = None, group_address_controller_status: GroupAddressesType | None = None, group_address_controller_status_state: GroupAddressesType | None = None, group_address_controller_mode: GroupAddressesType | None = None, group_address_controller_mode_state: GroupAddressesType | None = None, group_address_heat_cool: GroupAddressesType | None = None, group_address_heat_cool_state: GroupAddressesType | None = None, sync_state: bool | int | float | str = True, operation_modes: list[str | HVACOperationMode] | None = None, controller_modes: list[str | HVACControllerMode] | None = None, device_updated_cb: DeviceCallbackType | None = None, ): """Initialize ClimateMode class.""" super().__init__(xknx, name, device_updated_cb) self.remote_value_operation_mode = RemoteValueOperationMode( xknx, group_address=group_address_operation_mode, group_address_state=group_address_operation_mode_state, sync_state=sync_state, device_name=name, feature_name="Operation mode", climate_mode_type=RemoteValueOperationMode.ClimateModeType.HVAC_MODE, after_update_cb=None, ) self.remote_value_controller_mode = RemoteValueControllerMode( xknx, group_address=group_address_controller_mode, group_address_state=group_address_controller_mode_state, sync_state=sync_state, device_name=name, feature_name="Controller mode", after_update_cb=None, ) self.remote_value_controller_status = RemoteValueOperationMode( xknx, group_address=group_address_controller_status, group_address_state=group_address_controller_status_state, sync_state=sync_state, device_name=name, feature_name="Controller status", climate_mode_type=RemoteValueOperationMode.ClimateModeType.CONTROLLER_STATUS, after_update_cb=None, ) self.remote_value_operation_mode_comfort = RemoteValueBinaryOperationMode( xknx, group_address=group_address_operation_mode_comfort, group_address_state=group_address_operation_mode_comfort, sync_state=sync_state, device_name=name, feature_name="Operation mode Comfort", operation_mode=HVACOperationMode.COMFORT, after_update_cb=None, ) self.remote_value_operation_mode_standby = RemoteValueBinaryOperationMode( xknx, group_address=group_address_operation_mode_standby, group_address_state=group_address_operation_mode_standby, sync_state=sync_state, device_name=name, feature_name="Operation mode Standby", operation_mode=HVACOperationMode.STANDBY, after_update_cb=None, ) self.remote_value_operation_mode_night = RemoteValueBinaryOperationMode( xknx, group_address=group_address_operation_mode_night, group_address_state=group_address_operation_mode_night, sync_state=sync_state, device_name=name, feature_name="Operation mode Night", operation_mode=HVACOperationMode.NIGHT, after_update_cb=None, ) self.remote_value_operation_mode_protection = RemoteValueBinaryOperationMode( xknx, group_address=group_address_operation_mode_protection, group_address_state=group_address_operation_mode_protection, sync_state=sync_state, device_name=name, feature_name="Operation mode Protection", operation_mode=HVACOperationMode.FROST_PROTECTION, after_update_cb=None, ) self.remote_value_heat_cool = RemoteValueBinaryHeatCool( xknx, group_address=group_address_heat_cool, group_address_state=group_address_heat_cool_state, sync_state=sync_state, device_name=name, feature_name="Heat/Cool", controller_mode=HVACControllerMode.HEAT, after_update_cb=None, ) self.operation_mode = HVACOperationMode.STANDBY self.controller_mode = HVACControllerMode.HEAT self._operation_modes: list[HVACOperationMode] = [] if operation_modes is None: self._operation_modes = self.gather_operation_modes() else: for op_mode in operation_modes: if isinstance(op_mode, str): self._operation_modes.append(HVACOperationMode(op_mode)) elif isinstance(op_mode, HVACOperationMode): self._operation_modes.append(op_mode) self._controller_modes: list[HVACControllerMode] = [] if controller_modes is None: self._controller_modes = self.gather_controller_modes() else: for ct_mode in controller_modes: if isinstance(ct_mode, str): self._controller_modes.append(HVACControllerMode(ct_mode)) elif isinstance(ct_mode, HVACControllerMode): self._controller_modes.append(ct_mode) self.supports_operation_mode = any( operation_mode.initialized for operation_mode in self._iter_operation_remote_values() ) self.supports_controller_mode = any( controller_mode.initialized for controller_mode in self._iter_controller_remote_values() ) self._use_binary_operation_modes = any( operation_mode.initialized for operation_mode in self._iter_binary_operation_modes() )
def __init__( self, xknx: "XKNX", name: str, group_address_operation_mode: Optional["GroupAddressableType"] = None, group_address_operation_mode_state: Optional[ "GroupAddressableType"] = None, group_address_operation_mode_protection: Optional[ "GroupAddressableType"] = None, group_address_operation_mode_night: Optional[ "GroupAddressableType"] = None, group_address_operation_mode_comfort: Optional[ "GroupAddressableType"] = None, group_address_operation_mode_standby: Optional[ "GroupAddressableType"] = None, group_address_controller_status: Optional[ "GroupAddressableType"] = None, group_address_controller_status_state: Optional[ "GroupAddressableType"] = None, group_address_controller_mode: Optional["GroupAddressableType"] = None, group_address_controller_mode_state: Optional[ "GroupAddressableType"] = None, group_address_heat_cool: Optional["GroupAddressableType"] = None, group_address_heat_cool_state: Optional["GroupAddressableType"] = None, operation_modes: Optional[List[Union[str, HVACOperationMode]]] = None, controller_modes: Optional[List[Union[str, HVACControllerMode]]] = None, device_updated_cb: Optional[DeviceCallbackType] = None, ): """Initialize ClimateMode class.""" # pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-statements super().__init__(xknx, name, device_updated_cb) self.remote_value_operation_mode: RemoteValueClimateMode[ HVACOperationMode] = RemoteValueClimateMode( xknx, group_address=group_address_operation_mode, group_address_state=group_address_operation_mode_state, sync_state=True, device_name=name, feature_name="Operation mode", climate_mode_type=RemoteValueClimateMode.ClimateModeType. HVAC_MODE, after_update_cb=None, ) self.remote_value_controller_mode: RemoteValueClimateMode[ HVACControllerMode] = RemoteValueClimateMode( xknx, group_address=group_address_controller_mode, group_address_state=group_address_controller_mode_state, sync_state=True, device_name=name, feature_name="Controller mode", climate_mode_type=RemoteValueClimateMode.ClimateModeType. HVAC_CONTR_MODE, after_update_cb=None, ) self.remote_value_controller_status: RemoteValueClimateMode[ HVACOperationMode] = RemoteValueClimateMode( xknx, group_address=group_address_controller_status, group_address_state=group_address_controller_status_state, sync_state=True, device_name=name, feature_name="Controller status", climate_mode_type=RemoteValueClimateMode.ClimateModeType. CONTROLLER_STATUS, after_update_cb=None, ) self.remote_value_operation_mode_comfort = RemoteValueBinaryOperationMode( xknx, group_address=group_address_operation_mode_comfort, group_address_state=group_address_operation_mode_comfort, sync_state=True, device_name=name, feature_name="Operation mode Comfort", operation_mode=HVACOperationMode.COMFORT, after_update_cb=None, ) self.remote_value_operation_mode_standby = RemoteValueBinaryOperationMode( xknx, group_address=group_address_operation_mode_standby, group_address_state=group_address_operation_mode_standby, sync_state=True, device_name=name, feature_name="Operation mode Standby", operation_mode=HVACOperationMode.STANDBY, after_update_cb=None, ) self.remote_value_operation_mode_night = RemoteValueBinaryOperationMode( xknx, group_address=group_address_operation_mode_night, group_address_state=group_address_operation_mode_night, sync_state=True, device_name=name, feature_name="Operation mode Night", operation_mode=HVACOperationMode.NIGHT, after_update_cb=None, ) self.remote_value_operation_mode_protection = RemoteValueBinaryOperationMode( xknx, group_address=group_address_operation_mode_protection, group_address_state=group_address_operation_mode_protection, sync_state=True, device_name=name, feature_name="Operation mode Protection", operation_mode=HVACOperationMode.FROST_PROTECTION, after_update_cb=None, ) self.remote_value_heat_cool = RemoteValueBinaryHeatCool( xknx, group_address=group_address_heat_cool, group_address_state=group_address_heat_cool_state, sync_state=True, device_name=name, feature_name="Heat/Cool", controller_mode=HVACControllerMode.HEAT, after_update_cb=None, ) self.operation_mode = HVACOperationMode.STANDBY self.controller_mode = HVACControllerMode.HEAT self._operation_modes: List[HVACOperationMode] = [] if operation_modes is None: self._operation_modes = self.gather_operation_modes() else: for op_mode in operation_modes: if isinstance(op_mode, str): self._operation_modes.append(HVACOperationMode(op_mode)) elif isinstance(op_mode, HVACOperationMode): self._operation_modes.append(op_mode) self._controller_modes: List[HVACControllerMode] = [] if controller_modes is None: self._controller_modes = self.gather_controller_modes() else: for ct_mode in controller_modes: if isinstance(ct_mode, str): self._controller_modes.append(HVACControllerMode(ct_mode)) elif isinstance(ct_mode, HVACControllerMode): self._controller_modes.append(ct_mode) self.supports_operation_mode = any( operation_mode.initialized for operation_mode in self._iter_byte_operation_modes()) or any( operation_mode.initialized for operation_mode in self._iter_binary_operation_modes()) self.supports_controller_mode = any( operation_mode.initialized for operation_mode in self._iter_controller_remote_values()) self._use_binary_operation_modes = any( operation_mode.initialized for operation_mode in self._iter_binary_operation_modes())