Skip to content

Commit 86feee6

Browse files
committed
Update 1.2.5
1 parent 8bad7d9 commit 86feee6

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

custom_components/gicisky/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async def writeservice(service: ServiceCall) -> None:
142142
await data.last_update()
143143
break
144144

145-
_LOGGER.warning("Write failed to %s (attempt %d/%d)", address, attempt, max_retries)
145+
_LOGGER.warning(f"Write failed to {address} (attempt {attempt}/{max_retries})")
146146
if attempt < max_retries:
147147
await sleep(1)
148148
else:

custom_components/gicisky/gicisky_ble/writer.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from enum import Enum
55
import logging
66
import struct
7-
import traceback
87
from typing import Any, Callable, TypeVar
98
from asyncio import Event, wait_for, sleep
109
from PIL import Image
@@ -31,9 +30,12 @@ async def wrapper(self, *args, **kwargs):
3130
try:
3231
return await func(self, *args, **kwargs)
3332
except (BleakServiceMissing, BleakCharacteristicMissing):
34-
if self.client.is_connected:
35-
await self.client.clear_cache()
36-
await self.client.disconnect()
33+
try:
34+
if self.client.is_connected:
35+
await self.client.clear_cache()
36+
await self.client.disconnect()
37+
except Exception:
38+
pass
3739
raise
3840
return wrapper # type: ignore
3941

@@ -59,11 +61,13 @@ async def update_image(
5961
gicisky = GiciskyClient(client, sorted_uuids, device)
6062
await gicisky.start_notify()
6163
success = await gicisky.write_image(image, threshold, red_threshold)
62-
await gicisky.stop_notify()
64+
try:
65+
await gicisky.stop_notify()
66+
except Exception as e:
67+
_LOGGER.warning(f"{ble_device.address} Already stop notify: {e}")
6368
return success
6469
except Exception as e:
65-
_LOGGER.error(f"Fail update: {e}")
66-
_LOGGER.error(traceback.print_exc())
70+
_LOGGER.error(f"Update failed: {e}")
6771
return False
6872
finally:
6973
if client:
@@ -200,7 +204,7 @@ async def write_image(self, image: Image, threshold: int, red_threshold: int) ->
200204
raise Exception(f"Status Error: {status}")
201205
return True
202206
except Exception as e:
203-
_LOGGER.error("Fail write: %s", e)
207+
_LOGGER.error(f"Write failed: {e}")
204208
return False
205209
finally:
206210
_LOGGER.debug("Finish")

custom_components/gicisky/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"documentation": "https://github.com/eigger/hass-gicisky",
1414
"issue_tracker": "https://github.com/eigger/hass-gicisky/issues",
1515
"iot_class": "local_push",
16-
"version": "1.2.4",
16+
"version": "1.2.5",
1717
"requirements": [
1818
"qrcode[pil]",
1919
"python-barcode"

0 commit comments

Comments
 (0)