Skip to content

Commit

Permalink
Fix image loading
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasddn committed Dec 12, 2024
1 parent dde1fdc commit c081fda
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions custom_components/volvo_cars/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/volvo_cars/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit c081fda

Please sign in to comment.