Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
except WLEDError:
self._supports_si_request = False
from yarl import URL
from .__version__ import __version__
from .exceptions import (
WLEDConnectionError,
WLEDConnectionTimeoutError,
WLEDEmptyResponseError,
WLEDError,
)
from .models import Device
class WLED:
"""Main class for handling connections with WLED."""
_device: Optional[Device] = None
_supports_si_request: Optional[bool] = None
def __init__(
self,
host: str,
base_path: str = "/json",
password: str = None,
port: int = 80,
request_timeout: float = 8.0,
session: aiohttp.client.ClientSession = None,
tls: bool = False,
username: str = None,
verify_ssl: bool = True,
user_agent: str = None,
) -> None:
"""Initialize connection with WLED."""