Ejemplo n.º 1
0
def create_ac_state_data_frame(self):
    # reset UpdateRequestMask flags
    self._DaikinClimateSettings_Object.UpdateRequestMask = \
        UpdateRequest.reset_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.AC_STATE)
    self._DaikinClimateSettings_Object.UpdateRequestMask = \
        UpdateRequest.reset_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.POWER_STATE)
    self._DaikinClimateSettings_Object.UpdateRequestMask = \
        UpdateRequest.reset_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.TARGET_TEMP)
    self._DaikinClimateSettings_Object.UpdateRequestMask = \
        UpdateRequest.reset_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.FAN_STATE)
    self._DaikinClimateSettings_Object.UpdateRequestMask = \
        UpdateRequest.reset_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.ZONE)

    data = C_DaikinDataAcState

    data[7] = self._DaikinClimateSettings_Object.AcStateModeValue +\
        (self._DaikinClimateSettings_Object.PowerOnState << 3)
    data[8] = self._DaikinClimateSettings_Object.CoolSetTemp
    data[10] = self._DaikinClimateSettings_Object.HeatSetTemp
    data[12] = (self._DaikinClimateSettings_Object.CoolFanState.FanMode.value << 4) + \
               (resolve_fan_speed_for_data_frame(self._DaikinClimateSettings_Object.CoolFanState.FanSpeed) & 0x0F)
    data[13] = (self._DaikinClimateSettings_Object.HeatFanState.FanMode << 4) + \
               (resolve_fan_speed_for_data_frame(self._DaikinClimateSettings_Object.HeatFanState.FanSpeed) & 0x0F)
    data[14] = get_zone_bit_mask_from_zone_state(self)

    return data
Ejemplo n.º 2
0
def set_climate_fan_speed(self, fan_speed):
    # Check FanSpeed is valid
    if isinstance(fan_speed, FanSpeed) and (fan_speed != FanSpeed.NA):
        # Check for current mode (cool/heat). Default (0) is FAN, so no need to check for 'init' value.
        # Check FanMode based on FanSpeed
        if (fan_speed == FanSpeed.LOW) or (fan_speed == FanSpeed.MED) or (
                fan_speed == FanSpeed.HIGH):
            fan_mode = FanMode.FAN
        elif (fan_speed == FanSpeed.AUTO_LOW) or (
                fan_speed == FanSpeed.AUTO_MED) or (fan_speed
                                                    == FanSpeed.AUTO_HIGH):
            fan_mode = FanMode.AUTO
        else:
            fan_mode = FanMode.MULTI_ZONING

        # HEAT
        if get_climate_mode(self) == AcStateMode.MODE_HEAT:
            # Update 'heat' variables
            if self._DaikinClimateSettings_Object.HeatFanState.FanSpeed != fan_speed or \
                    self._DaikinClimateSettings_Object.HeatFanState.FanMode != fan_mode:
                self._DaikinClimateSettings_Object.HeatFanState.FanSpeed = fan_speed
                self._DaikinClimateSettings_Object.HeatFanState.FanMode = fan_mode
                # Set mask that update has occurred and to ignore current update if in progress
                self._DaikinClimateSettings_Object.UpdateRequestMask = \
                    UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask,
                                           UpdateRequest.FAN_STATE)
        # COOL / FAN
        elif get_climate_mode(
                self) == AcStateMode.MODE_COOL or get_climate_mode(
                    self) == AcStateMode.MODE_FAN:
            # Update 'cool' variables
            if self._DaikinClimateSettings_Object.CoolFanState.FanSpeed != fan_speed or \
                    self._DaikinClimateSettings_Object.CoolFanState.FanMode != fan_mode:
                self._DaikinClimateSettings_Object.CoolFanState.FanSpeed = fan_speed
                self._DaikinClimateSettings_Object.CoolFanState.FanMode = fan_mode
                # Set mask that update has occurred and to ignore current update if in progress
                self._DaikinClimateSettings_Object.UpdateRequestMask = \
                    UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask,
                                           UpdateRequest.FAN_STATE)
        # AUTO/FAN
        elif get_climate_mode(self) == AcStateMode.MODE_AUTO:
            # Update both (as per app)
            if self._DaikinClimateSettings_Object.CoolFanState.FanSpeed != fan_speed or \
                    self._DaikinClimateSettings_Object.CoolFanState.FanMode != fan_mode or \
                    self._DaikinClimateSettings_Object.HeatFanState.FanSpeed != fan_speed or \
                    self._DaikinClimateSettings_Object.HeatFanState.FanMode != fan_mode:
                self._DaikinClimateSettings_Object.CoolFanState.FanSpeed = fan_speed
                self._DaikinClimateSettings_Object.CoolFanState.FanMode = fan_mode
                self._DaikinClimateSettings_Object.HeatFanState.FanSpeed = fan_speed
                self._DaikinClimateSettings_Object.HeatFanState.FanMode = fan_mode
                # Set mask that update has occurred and to ignore current update if in progress
                self._DaikinClimateSettings_Object.UpdateRequestMask = \
                    UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask,
                                           UpdateRequest.FAN_STATE)
        # DRY/OFF
        else:
            # Speed/Fan settings ignored.
            pass
Ejemplo n.º 3
0
def create_sensor_set_data_frame(self):
    # Reset UpdateRequestMask flag
    self._DaikinClimateSettings_Object.UpdateRequestMask = \
        UpdateRequest.reset_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.TEMP_SENSOR)

    data = C_DaikinDataSensorSelect
    data[7] = resolve_sensor_name_to_index(
        self, self._DaikinClimateInfo_Object.TempSensorName[
            self._DaikinClimateSettings_Object.SelectedSensor])
    return data
Ejemplo n.º 4
0
def set_climate_temp_sensor(self, sensor_index):
    if isinstance(sensor_index, SensorIndex):
        if self._DaikinClimateSettings_Object.SelectedSensor != sensor_index:
            # limit value to Sensor2, as Outdoor/Refrigerant are not part of frame
            # and only used for internal indexing of temperatures.
            if sensor_index <= SensorIndex.Sensor2:
                self._DaikinClimateSettings_Object.SelectedSensor = sensor_index
                # Set mask that update has occurred and to ignore current update if in progress
                self._DaikinClimateSettings_Object.UpdateRequestMask = \
                    UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask,
                                           UpdateRequest.TEMP_SENSOR)
Ejemplo n.º 5
0
def set_target_climate_temp(self, temp):
    # HEAT
    if get_climate_mode(self) == AcStateMode.MODE_HEAT:
        # check temp is with heating range.
        if is_temp_within_heat_range(self, temp):
            # update 'heat' variables
            if self._DaikinClimateSettings_Object.HeatSetTemp != temp:
                self._DaikinClimateSettings_Object.HeatSetTemp = temp
                # Set mask that update has occurred and to ignore current update if in progress
                self._DaikinClimateSettings_Object.UpdateRequestMask = \
                    UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask,
                                           UpdateRequest.TARGET_TEMP)
    # COOL
    elif get_climate_mode(self) == AcStateMode.MODE_COOL:
        # check temp is within cooling range
        if is_temp_within_cool_range(self, temp):
            # update 'cool' variables
            if self._DaikinClimateSettings_Object.CoolSetTemp != temp:
                self._DaikinClimateSettings_Object.CoolSetTemp = temp
                # Set mask that update has occurred and to ignore current update if in progress
                self._DaikinClimateSettings_Object.UpdateRequestMask = \
                    UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask,
                                           UpdateRequest.TARGET_TEMP)
    # AUTO
    elif get_climate_mode(self) == AcStateMode.MODE_AUTO:
        # check temp is within heat/cool range.
        if is_temp_within_cool_range(self, temp) and is_temp_within_heat_range(
                self, temp):
            # update both
            if self._DaikinClimateSettings_Object.HeatSetTemp != temp or \
                    self._DaikinClimateSettings_Object.CoolSetTemp != temp:
                self._DaikinClimateSettings_Object.HeatSetTemp = temp
                self._DaikinClimateSettings_Object.CoolSetTemp = temp
                # Set mask that update has occurred and to ignore current update if in progress
                self._DaikinClimateSettings_Object.UpdateRequestMask = \
                    UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask,
                                           UpdateRequest.TARGET_TEMP)
    # DRY/FAN/OFF
    else:
        # Temp setting ignored.
        pass
Ejemplo n.º 6
0
def set_climate_mode(self, ac_mode):

    if ac_mode == AcStateMode.MODE_OFF:
        # Turn off unit
        if self._DebugModeLevel >= 1:
            _LOGGER.debug('TurnOff AC')
        update_power_state(self, AcPowerState.OFF)
        # leave AcStateModeValue as previous
    else:
        # turn on unit and set mode
        if self._DaikinClimateSettings_Object.AcStateModeValue != ac_mode or \
                self._DaikinClimateSettings_Object.PowerOnState != AcPowerState.ON:
            self._DaikinClimateSettings_Object.AcStateModeValue = ac_mode
            # Set mask that update has occurred and to ignore current update if in progress
            self._DaikinClimateSettings_Object.UpdateRequestMask = \
                UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.AC_STATE)
            update_power_state(self, AcPowerState.ON)
Ejemplo n.º 7
0
def update_zone_state(self, zone_index, zone_state):
    # Check each bit and set corresponding zone. Check for 'max' zones supported
    if isinstance(zone_state, ZoneState):
        if zone_index < self._DaikinClimateInfo_Object.NumberOfZones:
            if self._DaikinClimateSettings_Object.Zone[
                    zone_index] != zone_state:
                self._DaikinClimateSettings_Object.Zone[
                    zone_index] = zone_state
                # Set mask that update has occurred and to ignore current update if in progress
                self._DaikinClimateSettings_Object.UpdateRequestMask = \
                    UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.ZONE)

    # Check to make sure all zones are not switched off
    any_zone_active = False
    for x in range(0, self._DaikinClimateInfo_Object.NumberOfZones):
        if self._DaikinClimateSettings_Object.Zone[x] == ZoneState.ACTIVE:
            any_zone_active = True

    if not any_zone_active:
        _LOGGER.error(
            'No Zone selected. This may cause permanent damage to your AC system!'
        )
Ejemplo n.º 8
0
def update_power_state(self, ac_power_state):
    if self._DaikinClimateSettings_Object.PowerOnState != ac_power_state:
        self._DaikinClimateSettings_Object.PowerOnState = ac_power_state
        # Set mask that update has occurred and to ignore current update if in progress
        self._DaikinClimateSettings_Object.UpdateRequestMask = \
            UpdateRequest.set_flag(self._DaikinClimateSettings_Object.UpdateRequestMask, UpdateRequest.POWER_STATE)