Skip to content

Commit b13dc38

Browse files
authored
Merge branch 'HASwitchPlate:main' into main
2 parents f25c3d2 + 133f5ea commit b13dc38

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

custom_components/openhasp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ async def async_push_image(
593593
):
594594
"""Update object image."""
595595

596-
image_id = hashlib.md5(image.encode("utf-8")).hexdigest()
596+
image_id = hashlib.md5(image.encode("utf-8") + self._entry.data[CONF_NAME].encode('utf-8')).hexdigest()
597597

598598
rgb_image = await self.hass.async_add_executor_job(
599599
image_to_rgb565, image, (width, height), fitscreen

custom_components/openhasp/image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import struct
55
import tempfile
66

7-
from PIL import Image
7+
from PIL import Image, ImageOps
88
from aiohttp import hdrs, web
99
from homeassistant.components.http.static import CACHE_HEADERS
1010
from homeassistant.components.http.view import HomeAssistantView
@@ -34,7 +34,9 @@ def image_to_rgb565(in_image, size, fitscreen):
3434
height = min(h for h in [height, original_height] if h is not None and h > 0)
3535
im.thumbnail((width, height), Image.LANCZOS)
3636
else:
37-
im = im.resize((width, height), Image.LANCZOS)
37+
im = ImageOps.fit(im, (width, height), method = 3,
38+
bleed = 0.0, centering =(0.5, 0.5))
39+
3840
width, height = im.size # actual size after resize
3941

4042
out_image = tempfile.NamedTemporaryFile(mode="w+b")

0 commit comments

Comments
 (0)