From c081fdad184491896f354ee1d8589b7c536cf4be Mon Sep 17 00:00:00 2001 From: Thomas D <11554546+thomasddn@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:34:08 +0000 Subject: [PATCH] Fix image loading --- custom_components/volvo_cars/image.py | 13 +++++++------ custom_components/volvo_cars/manifest.json | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/custom_components/volvo_cars/image.py b/custom_components/volvo_cars/image.py index b517155..b887e3e 100644 --- a/custom_components/volvo_cars/image.py +++ b/custom_components/volvo_cars/image.py @@ -21,9 +21,9 @@ _LOGGER = logging.getLogger(__name__) _HEADERS = { "Accept-Language": "en-GB", - "Sec-Fetch-User": "?1", - "User-Agent": "home-assistant", "Cache-Control": "no-cache", + "Sec-Fetch-User": "?1", + "User-Agent": "PostmanRuntime/7.43.0", } PARALLEL_UPDATES = 0 @@ -57,7 +57,6 @@ async def _async_image_exists(client: AsyncClient, url: str) -> bool: # pylint: disable=unexpected-keyword-arg IMAGES: tuple[VolvoCarsImageDescription, ...] = ( - # TODO: translation = side passenger VolvoCarsImageDescription( key="exterior", translation_key="exterior", @@ -127,16 +126,18 @@ async def async_setup_entry( ) -> None: """Set up images.""" coordinator = entry.runtime_data.coordinator - # client = async_get_clientsession(hass) client = get_async_client(hass, False) client.headers.update(_HEADERS) images = [ VolvoCarsImage(coordinator, description) for description in IMAGES - if await _async_image_exists( - client, description.image_url_fn(coordinator.vehicle) + if ( + await _async_image_exists( + client, description.image_url_fn(coordinator.vehicle) + ) ) + is True ] async_add_entities(images) diff --git a/custom_components/volvo_cars/manifest.json b/custom_components/volvo_cars/manifest.json index 9ed4076..6e5386c 100644 --- a/custom_components/volvo_cars/manifest.json +++ b/custom_components/volvo_cars/manifest.json @@ -9,5 +9,5 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/thomasddn/ha-volvo-cars/issues", "requirements": [], - "version": "0.2.3" + "version": "0.3.0-b1" } \ No newline at end of file