コード例 #1
0
 def __init__(self, xknx: XKNX, config: ConfigType) -> None:
     """Initialize the cover."""
     self._device: XknxCover
     super().__init__(device=XknxCover(
         xknx,
         name=config[CONF_NAME],
         group_address_long=config.get(CoverSchema.CONF_MOVE_LONG_ADDRESS),
         group_address_short=config.get(
             CoverSchema.CONF_MOVE_SHORT_ADDRESS),
         group_address_stop=config.get(CoverSchema.CONF_STOP_ADDRESS),
         group_address_position_state=config.get(
             CoverSchema.CONF_POSITION_STATE_ADDRESS),
         group_address_angle=config.get(CoverSchema.CONF_ANGLE_ADDRESS),
         group_address_angle_state=config.get(
             CoverSchema.CONF_ANGLE_STATE_ADDRESS),
         group_address_position=config.get(
             CoverSchema.CONF_POSITION_ADDRESS),
         travel_time_down=config[CoverSchema.CONF_TRAVELLING_TIME_DOWN],
         travel_time_up=config[CoverSchema.CONF_TRAVELLING_TIME_UP],
         invert_position=config[CoverSchema.CONF_INVERT_POSITION],
         invert_angle=config[CoverSchema.CONF_INVERT_ANGLE],
     ))
     self._device_class: str | None = config.get(CONF_DEVICE_CLASS)
     self._unique_id = (f"{self._device.updown.group_address}_"
                        f"{self._device.position_target.group_address}")
     self._unsubscribe_auto_updater: Callable[[], None] | None = None
コード例 #2
0
ファイル: cover.py プロジェクト: scarface-4711/home-assistant
    def __init__(self, xknx: XKNX, config: ConfigType) -> None:
        """Initialize the cover."""
        super().__init__(
            device=XknxCover(
                xknx,
                name=config[CONF_NAME],
                group_address_long=config.get(CoverSchema.CONF_MOVE_LONG_ADDRESS),
                group_address_short=config.get(CoverSchema.CONF_MOVE_SHORT_ADDRESS),
                group_address_stop=config.get(CoverSchema.CONF_STOP_ADDRESS),
                group_address_position_state=config.get(
                    CoverSchema.CONF_POSITION_STATE_ADDRESS
                ),
                group_address_angle=config.get(CoverSchema.CONF_ANGLE_ADDRESS),
                group_address_angle_state=config.get(
                    CoverSchema.CONF_ANGLE_STATE_ADDRESS
                ),
                group_address_position=config.get(CoverSchema.CONF_POSITION_ADDRESS),
                travel_time_down=config[CoverSchema.CONF_TRAVELLING_TIME_DOWN],
                travel_time_up=config[CoverSchema.CONF_TRAVELLING_TIME_UP],
                invert_position=config[CoverSchema.CONF_INVERT_POSITION],
                invert_angle=config[CoverSchema.CONF_INVERT_ANGLE],
            )
        )
        self._unsubscribe_auto_updater: Callable[[], None] | None = None

        self._attr_entity_category = config.get(CONF_ENTITY_CATEGORY)
        _supports_tilt = False
        self._attr_supported_features = (
            CoverEntityFeature.CLOSE
            | CoverEntityFeature.OPEN
            | CoverEntityFeature.SET_POSITION
        )
        if self._device.step.writable:
            _supports_tilt = True
            self._attr_supported_features |= (
                CoverEntityFeature.CLOSE_TILT
                | CoverEntityFeature.OPEN_TILT
                | CoverEntityFeature.STOP_TILT
            )
        if self._device.supports_angle:
            _supports_tilt = True
            self._attr_supported_features |= CoverEntityFeature.SET_TILT_POSITION
        if self._device.supports_stop:
            self._attr_supported_features |= CoverEntityFeature.STOP
            if _supports_tilt:
                self._attr_supported_features |= CoverEntityFeature.STOP_TILT

        self._attr_device_class = config.get(CONF_DEVICE_CLASS) or (
            CoverDeviceClass.BLIND if _supports_tilt else None
        )
        self._attr_unique_id = (
            f"{self._device.updown.group_address}_"
            f"{self._device.position_target.group_address}"
        )
コード例 #3
0
def async_add_entities_config(hass, config, async_add_entities):
    """Set up cover for KNX platform configured within platform."""
    cover = XknxCover(
        hass.data[DATA_XKNX].xknx,
        name=config[CONF_NAME],
        group_address_long=config.get(CONF_MOVE_LONG_ADDRESS),
        group_address_short=config.get(CONF_MOVE_SHORT_ADDRESS),
        group_address_position_state=config.get(CONF_POSITION_STATE_ADDRESS),
        group_address_angle=config.get(CONF_ANGLE_ADDRESS),
        group_address_angle_state=config.get(CONF_ANGLE_STATE_ADDRESS),
        group_address_position=config.get(CONF_POSITION_ADDRESS),
        travel_time_down=config[CONF_TRAVELLING_TIME_DOWN],
        travel_time_up=config[CONF_TRAVELLING_TIME_UP],
        invert_position=config[CONF_INVERT_POSITION],
        invert_angle=config[CONF_INVERT_ANGLE],
    )

    hass.data[DATA_XKNX].xknx.devices.add(cover)
    async_add_entities([KNXCover(cover)])
コード例 #4
0
def _create_cover(knx_module: XKNX, config: ConfigType) -> XknxCover:
    """Return a KNX Cover device to be used within XKNX."""
    return XknxCover(
        knx_module,
        name=config[CONF_NAME],
        group_address_long=config.get(CoverSchema.CONF_MOVE_LONG_ADDRESS),
        group_address_short=config.get(CoverSchema.CONF_MOVE_SHORT_ADDRESS),
        group_address_stop=config.get(CoverSchema.CONF_STOP_ADDRESS),
        group_address_position_state=config.get(
            CoverSchema.CONF_POSITION_STATE_ADDRESS),
        group_address_angle=config.get(CoverSchema.CONF_ANGLE_ADDRESS),
        group_address_angle_state=config.get(
            CoverSchema.CONF_ANGLE_STATE_ADDRESS),
        group_address_position=config.get(CoverSchema.CONF_POSITION_ADDRESS),
        travel_time_down=config[CoverSchema.CONF_TRAVELLING_TIME_DOWN],
        travel_time_up=config[CoverSchema.CONF_TRAVELLING_TIME_UP],
        invert_position=config[CoverSchema.CONF_INVERT_POSITION],
        invert_angle=config[CoverSchema.CONF_INVERT_ANGLE],
    )