How to use the wled.exceptions.WLEDEmptyResponseError function in wled

To help you get started, we’ve selected a few wled examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frenck / python-wled / wled / wled.py View on Github external
except WLEDError:
                    self._supports_si_request = False

            return self._device

        # Handle legacy state and update in separate requests
        if not self._supports_si_request:
            info = await self._request("info")
            if not info:
                raise WLEDEmptyResponseError(
                    "WLED device returned an empty API response on info update"
                )

            state = await self._request("state")
            if not state:
                raise WLEDEmptyResponseError(
                    "WLED device returned an empty API response on state update"
                )
            self._device.update_from_dict({"info": info, "state": state})
            return self._device

        state_info = await self._request("si")
        if not state_info:
            raise WLEDEmptyResponseError(
                "WLED device returned an empty API response on state & info update"
            )
        self._device.update_from_dict(state_info)
        return self._device
github frenck / python-wled / wled / wled.py View on Github external
        backoff.expo, WLEDEmptyResponseError, max_tries=3, logger=None
    )
    async def update(self, full_update: bool = False) -> Device:
        """Get all information about the device in a single call."""
        if self._device is None or full_update:
            data = await self._request()
            if not data:
                raise WLEDEmptyResponseError(
                    "WLED device returned an empty API response on full update"
                )
            self._device = Device(data)

            # Try to figure out if this version supports
            # a single info and state call
            try:
                version.Version(self._device.info.version)
                self._supports_si_request = version.parse(
github frenck / python-wled / wled / wled.py View on Github external
) >= version.parse("0.10.0")
            except version.InvalidVersion:
                # Could be a manual build one? Lets poll for it
                try:
                    await self._request("si")
                    self._supports_si_request = True
                except WLEDError:
                    self._supports_si_request = False

            return self._device

        # Handle legacy state and update in separate requests
        if not self._supports_si_request:
            info = await self._request("info")
            if not info:
                raise WLEDEmptyResponseError(
                    "WLED device returned an empty API response on info update"
                )

            state = await self._request("state")
            if not state:
                raise WLEDEmptyResponseError(
                    "WLED device returned an empty API response on state update"
                )
            self._device.update_from_dict({"info": info, "state": state})
            return self._device

        state_info = await self._request("si")
        if not state_info:
            raise WLEDEmptyResponseError(
                "WLED device returned an empty API response on state & info update"
            )
github frenck / python-wled / wled / wled.py View on Github external
if not info:
                raise WLEDEmptyResponseError(
                    "WLED device returned an empty API response on info update"
                )

            state = await self._request("state")
            if not state:
                raise WLEDEmptyResponseError(
                    "WLED device returned an empty API response on state update"
                )
            self._device.update_from_dict({"info": info, "state": state})
            return self._device

        state_info = await self._request("si")
        if not state_info:
            raise WLEDEmptyResponseError(
                "WLED device returned an empty API response on state & info update"
            )
        self._device.update_from_dict(state_info)
        return self._device
github frenck / python-wled / wled / wled.py View on Github external
async def update(self, full_update: bool = False) -> Device:
        """Get all information about the device in a single call."""
        if self._device is None or full_update:
            data = await self._request()
            if not data:
                raise WLEDEmptyResponseError(
                    "WLED device returned an empty API response on full update"
                )
            self._device = Device(data)

            # Try to figure out if this version supports
            # a single info and state call
            try:
                version.Version(self._device.info.version)
                self._supports_si_request = version.parse(
                    self._device.info.version
                ) >= version.parse("0.10.0")
            except version.InvalidVersion:
                # Could be a manual build one? Lets poll for it
                try:
                    await self._request("si")
                    self._supports_si_request = True