|
14 | 14 | import orjson |
15 | 15 | from yarl import URL |
16 | 16 |
|
| 17 | +from .const import DEFAULT_REPO |
17 | 18 | from .exceptions import ( |
18 | 19 | WLEDConnectionClosedError, |
19 | 20 | WLEDConnectionError, |
@@ -603,12 +604,18 @@ async def nightlight( |
603 | 604 | nightlight = {k: v for k, v in nightlight.items() if v is not None} |
604 | 605 | await self.request("/json/state", method="POST", data={"nl": nightlight}) |
605 | 606 |
|
606 | | - async def upgrade(self, *, version: str | AwesomeVersion) -> None: # noqa: PLR0912 |
| 607 | + async def upgrade( # noqa: PLR0912 |
| 608 | + self, |
| 609 | + *, |
| 610 | + version: str | AwesomeVersion, |
| 611 | + repo: str = DEFAULT_REPO, |
| 612 | + ) -> None: |
607 | 613 | """Upgrade WLED device to the specified version. |
608 | 614 |
|
609 | 615 | Args: |
610 | 616 | ---- |
611 | 617 | version: The version to upgrade to. |
| 618 | + repo: GitHub repository to download firmware from. |
612 | 619 |
|
613 | 620 | Raises: |
614 | 621 | ------ |
@@ -677,7 +684,7 @@ async def upgrade(self, *, version: str | AwesomeVersion) -> None: # noqa: PLR0 |
677 | 684 | architecture = self._device.info.architecture.upper() |
678 | 685 | update_file = f"WLED_{version}_{architecture}{ethernet}.bin{gzip}" |
679 | 686 | download_url = ( |
680 | | - f"https://github.com/wled/WLED/releases/download/v{version}/{update_file}" |
| 687 | + f"https://github.com/{repo}/releases/download/v{version}/{update_file}" |
681 | 688 | ) |
682 | 689 |
|
683 | 690 | try: |
@@ -793,6 +800,7 @@ def _check_presets_changed( |
793 | 800 | class WLEDReleases: |
794 | 801 | """Get version information for WLED.""" |
795 | 802 |
|
| 803 | + repo: str = DEFAULT_REPO |
796 | 804 | request_timeout: float = 8.0 |
797 | 805 | session: aiohttp.client.ClientSession | None = None |
798 | 806 |
|
@@ -824,7 +832,7 @@ async def releases(self) -> Releases: # noqa: PLR0912 # pylint: disable=too-ma |
824 | 832 | try: |
825 | 833 | async with asyncio.timeout(self.request_timeout): |
826 | 834 | response = await self.session.get( |
827 | | - "https://api.github.com/repos/wled/WLED/releases", |
| 835 | + f"https://api.github.com/repos/{self.repo}/releases", |
828 | 836 | headers={"Accept": "application/json"}, |
829 | 837 | ) |
830 | 838 | except TimeoutError as exception: |
@@ -886,6 +894,7 @@ async def releases(self) -> Releases: # noqa: PLR0912 # pylint: disable=too-ma |
886 | 894 | { |
887 | 895 | "beta": version_beta or "", |
888 | 896 | "nightly": version_nightly or "", |
| 897 | + "repo": self.repo, |
889 | 898 | "stable": version_stable or "", |
890 | 899 | } |
891 | 900 | ) |
|
0 commit comments