Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions custom_components/opendisplay/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from typing import TYPE_CHECKING, Any

import aiohttp
from epaper_dithering import ColorScheme
from odl_renderer import generate_image
from opendisplay import (
AuthenticationFailedError,
AuthenticationRequiredError,
ColorScheme,
DitherMode,
FitMode,
LedFlashConfig,
Expand Down Expand Up @@ -261,7 +261,9 @@ async def _async_download_image(hass: HomeAssistant, url: str) -> PILImage.Image
)
session = async_get_clientsession(hass)
try:
async with session.get(url) as resp:
async with session.get(
url, timeout=aiohttp.ClientTimeout(total=30)
) as resp:
resp.raise_for_status()
data = await resp.read()
except aiohttp.ClientError as err:
Expand Down Expand Up @@ -590,7 +592,7 @@ async def _drawcustom_for_device(
accent_color=color_scheme.accent_color,
session=async_get_clientsession(hass),
data_provider=HADataProvider(hass),
font_dirs=_font_search_dirs(hass),
font_dirs=await hass.async_add_executor_job(_font_search_dirs, hass),
)

if call.data["dry-run"]:
Expand Down
7 changes: 6 additions & 1 deletion custom_components/opendisplay/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class OpenDisplayFirmwareUpdateEntity(OpenDisplayEntity[UpdateEntityDescription]
"""Firmware update entity for an OpenDisplay device."""

_attr_latest_version: str | None = None
_attr_release_notes: str | None = None
should_poll = True # override coordinator's should_poll=False; GitHub needs regular polling

def __init__(self, coordinator, entry: OpenDisplayConfigEntry) -> None:
Expand Down Expand Up @@ -145,6 +146,7 @@ async def async_update(self) -> None:
async with session.get(
_GITHUB_LATEST.format(repo=self._firmware_repo),
headers=_GITHUB_HEADERS,
timeout=aiohttp.ClientTimeout(total=30),
) as resp:
resp.raise_for_status()
data = await resp.json()
Expand Down Expand Up @@ -258,6 +260,7 @@ async def _download_asset(self, tag: str, asset_name: str) -> bytes:
async with session.get(
_GITHUB_RELEASE.format(repo=self._firmware_repo, tag=tag),
headers=_GITHUB_HEADERS,
timeout=aiohttp.ClientTimeout(total=30),
) as resp:
resp.raise_for_status()
release = await resp.json()
Expand All @@ -276,7 +279,9 @@ async def _download_asset(self, tag: str, asset_name: str) -> bytes:

_LOGGER.debug("Downloading %s from %s", asset_name, download_url)
try:
async with session.get(download_url) as resp:
async with session.get(
download_url, timeout=aiohttp.ClientTimeout(total=120)
) as resp:
resp.raise_for_status()
return await resp.read()
except aiohttp.ClientError as err:
Expand Down
Loading