Ejemplo n.º 1
0
    def __init__(
        self,
        xknx: XKNX,
        name: str,
        group_address_temperature: GroupAddressesType | None = None,
        group_address_target_temperature: GroupAddressesType | None = None,
        group_address_target_temperature_state: GroupAddressesType
        | None = None,
        group_address_setpoint_shift: GroupAddressesType | None = None,
        group_address_setpoint_shift_state: GroupAddressesType | None = None,
        setpoint_shift_mode: SetpointShiftMode | None = None,
        setpoint_shift_max: float = DEFAULT_SETPOINT_SHIFT_MAX,
        setpoint_shift_min: float = DEFAULT_SETPOINT_SHIFT_MIN,
        temperature_step: float = DEFAULT_TEMPERATURE_STEP,
        group_address_on_off: GroupAddressesType | None = None,
        group_address_on_off_state: GroupAddressesType | None = None,
        on_off_invert: bool = False,
        group_address_active_state: GroupAddressesType | None = None,
        group_address_command_value_state: GroupAddressesType | None = None,
        sync_state: bool | int | float | str = True,
        min_temp: float | None = None,
        max_temp: float | None = None,
        mode: ClimateMode | None = None,
        device_updated_cb: DeviceCallbackType | None = None,
    ):
        """Initialize Climate class."""
        super().__init__(xknx, name, device_updated_cb)

        self.min_temp = min_temp
        self.max_temp = max_temp
        self.setpoint_shift_min = setpoint_shift_min
        self.setpoint_shift_max = setpoint_shift_max
        self.temperature_step = temperature_step

        self.temperature = RemoteValueTemp(
            xknx,
            group_address_state=group_address_temperature,
            sync_state=sync_state,
            device_name=self.name,
            feature_name="Current temperature",
            after_update_cb=self.after_update,
        )

        self.target_temperature = RemoteValueTemp(
            xknx,
            group_address_target_temperature,
            group_address_target_temperature_state,
            sync_state=sync_state,
            device_name=self.name,
            feature_name="Target temperature",
            after_update_cb=self.after_update,
        )

        self._setpoint_shift = RemoteValueSetpointShift(
            xknx,
            group_address_setpoint_shift,
            group_address_setpoint_shift_state,
            sync_state=sync_state,
            device_name=self.name,
            after_update_cb=self.after_update,
            setpoint_shift_mode=setpoint_shift_mode,
            setpoint_shift_step=self.temperature_step,
        )

        self.supports_on_off = (group_address_on_off is not None
                                or group_address_on_off_state is not None)

        self.on = RemoteValueSwitch(  # pylint: disable=invalid-name
            xknx,
            group_address_on_off,
            group_address_on_off_state,
            sync_state=sync_state,
            device_name=self.name,
            after_update_cb=self.after_update,
            invert=on_off_invert,
        )

        self.active = RemoteValueSwitch(
            xknx,
            group_address_state=group_address_active_state,
            sync_state=sync_state,
            device_name=self.name,
            feature_name="Active",
            after_update_cb=self.after_update,
        )

        self.command_value = RemoteValueScaling(
            xknx,
            group_address_state=group_address_command_value_state,
            sync_state=sync_state,
            device_name=self.name,
            feature_name="Command value",
            after_update_cb=self.after_update,
        )

        self.mode = mode
Ejemplo n.º 2
0
    def __init__(self,
                 xknx,
                 name,
                 group_address_temperature=None,
                 group_address_target_temperature=None,
                 group_address_target_temperature_state=None,
                 group_address_setpoint_shift=None,
                 group_address_setpoint_shift_state=None,
                 setpoint_shift_mode=DEFAULT_SETPOINT_SHIFT_MODE,
                 setpoint_shift_step=DEFAULT_SETPOINT_SHIFT_STEP,
                 setpoint_shift_max=DEFAULT_SETPOINT_SHIFT_MAX,
                 setpoint_shift_min=DEFAULT_SETPOINT_SHIFT_MIN,
                 group_address_on_off=None,
                 group_address_on_off_state=None,
                 on_off_invert=False,
                 min_temp=None,
                 max_temp=None,
                 mode=None,
                 device_updated_cb=None):
        """Initialize Climate class."""
        # pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-statements
        super().__init__(xknx, name, device_updated_cb)
        if isinstance(group_address_on_off, (str, int)):
            group_address_on_off = GroupAddress(group_address_on_off)
        if isinstance(group_address_on_off_state, (str, int)):
            group_address_on_off_state = GroupAddress(
                group_address_on_off_state)

        self.group_address_on_off = group_address_on_off
        self.group_address_on_off_state = group_address_on_off_state

        self.min_temp = min_temp
        self.max_temp = max_temp
        self.setpoint_shift_step = setpoint_shift_step
        self.setpoint_shift_min = setpoint_shift_min
        self.setpoint_shift_max = setpoint_shift_max

        self.temperature = RemoteValueTemp(
            xknx,
            group_address_state=group_address_temperature,
            device_name=self.name,
            after_update_cb=self.after_update)

        self.target_temperature = RemoteValueTemp(
            xknx,
            group_address_target_temperature,
            group_address_target_temperature_state,
            device_name=self.name,
            after_update_cb=self.after_update)

        if setpoint_shift_mode == SetpointShiftMode.DPT9002:
            self._setpoint_shift = RemoteValueTemp(
                xknx,
                group_address_setpoint_shift,
                group_address_setpoint_shift_state,
                device_name=self.name,
                after_update_cb=self.after_update)
        else:
            self._setpoint_shift = RemoteValueSetpointShift(
                xknx,
                group_address_setpoint_shift,
                group_address_setpoint_shift_state,
                device_name=self.name,
                after_update_cb=self.after_update,
                setpoint_shift_step=setpoint_shift_step)

        self.supports_on_off = \
            group_address_on_off is not None or \
            group_address_on_off_state is not None

        self.on = RemoteValueSwitch(xknx,
                                    group_address_on_off,
                                    group_address_on_off_state,
                                    device_name=self.name,
                                    after_update_cb=self.after_update,
                                    invert=on_off_invert)

        self.mode = mode
Ejemplo n.º 3
0
    def __init__(
        self,
        xknx: "XKNX",
        name: str,
        group_address_temperature: Optional["GroupAddressableType"] = None,
        group_address_target_temperature: Optional["GroupAddressableType"] = None,
        group_address_target_temperature_state: Optional["GroupAddressableType"] = None,
        group_address_setpoint_shift: Optional["GroupAddressableType"] = None,
        group_address_setpoint_shift_state: Optional["GroupAddressableType"] = None,
        setpoint_shift_mode: SetpointShiftMode = DEFAULT_SETPOINT_SHIFT_MODE,
        setpoint_shift_max: float = DEFAULT_SETPOINT_SHIFT_MAX,
        setpoint_shift_min: float = DEFAULT_SETPOINT_SHIFT_MIN,
        temperature_step: float = DEFAULT_TEMPERATURE_STEP,
        group_address_on_off: Optional["GroupAddressableType"] = None,
        group_address_on_off_state: Optional["GroupAddressableType"] = None,
        on_off_invert: bool = False,
        min_temp: Optional[float] = None,
        max_temp: Optional[float] = None,
        mode: Optional[ClimateMode] = None,
        create_temperature_sensors: bool = False,
        device_updated_cb: Optional[DeviceCallbackType] = None,
    ):
        """Initialize Climate class."""
        # pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-statements
        super().__init__(xknx, name, device_updated_cb)

        self.min_temp = min_temp
        self.max_temp = max_temp
        self.setpoint_shift_min = setpoint_shift_min
        self.setpoint_shift_max = setpoint_shift_max
        self.temperature_step = temperature_step

        self.temperature = RemoteValueTemp(
            xknx,
            group_address_state=group_address_temperature,
            device_name=self.name,
            feature_name="Current temperature",
            after_update_cb=self.after_update,
        )

        self.target_temperature = RemoteValueTemp(
            xknx,
            group_address_target_temperature,
            group_address_target_temperature_state,
            device_name=self.name,
            feature_name="Target temperature",
            after_update_cb=self.after_update,
        )

        self._setpoint_shift: Union[RemoteValueTemp, RemoteValueSetpointShift]
        if setpoint_shift_mode == SetpointShiftMode.DPT9002:
            self._setpoint_shift = RemoteValueTemp(
                xknx,
                group_address_setpoint_shift,
                group_address_setpoint_shift_state,
                device_name=self.name,
                after_update_cb=self.after_update,
            )
        else:
            self._setpoint_shift = RemoteValueSetpointShift(
                xknx,
                group_address_setpoint_shift,
                group_address_setpoint_shift_state,
                device_name=self.name,
                after_update_cb=self.after_update,
                setpoint_shift_step=self.temperature_step,
            )

        self.supports_on_off = (
            group_address_on_off is not None or group_address_on_off_state is not None
        )

        self.on = RemoteValueSwitch(
            xknx,
            group_address_on_off,
            group_address_on_off_state,
            device_name=self.name,
            after_update_cb=self.after_update,
            invert=on_off_invert,
        )

        self.mode = mode

        if create_temperature_sensors:
            self.create_temperature_sensors()