diff --git a/shelly-ble-rpc/.gitignore b/shelly-ble-rpc/.gitignore new file mode 100644 index 0000000..9a5ca19 --- /dev/null +++ b/shelly-ble-rpc/.gitignore @@ -0,0 +1,2 @@ +venv/ +*.log diff --git a/shelly-ble-rpc/shelly-ble-rpc.py b/shelly-ble-rpc/shelly-ble-rpc.py index 99a0770..e5773d0 100755 --- a/shelly-ble-rpc/shelly-ble-rpc.py +++ b/shelly-ble-rpc/shelly-ble-rpc.py @@ -13,7 +13,8 @@ from typing import Any, Dict, Optional, Tuple, List from dataclasses import dataclass -from bleak import BleakClient, BleakError, BleakScanner +from bleak import BleakClient, BleakScanner +from bleak.exc import BleakError from bleak.backends.device import BLEDevice from bleak.backends.scanner import AdvertisementData from colorama import Fore, Style, init as colorama_init @@ -391,7 +392,6 @@ async def call_rpc( async def retrieve_shelly_service(self, client: BleakClient) -> None: """Retrieves the Shelly GATT service from the BLE client.""" try: - await client.get_services() services = client.services self.shelly_service = services.get_service(SHELLY_GATT_SERVICE_UUID) if self.shelly_service is None: @@ -1050,16 +1050,6 @@ async def list_available_methods(device: ShellyDevice) -> None: print_error(f"Failed to list available methods: {e}") -# ============================ -# Utility Exception Classes -# ============================ - - -class RescanWithNewFiltersException(Exception): - """Custom exception to handle rescan with new filters.""" - pass - - # ============================ # Entry Point # ============================ @@ -1085,4 +1075,4 @@ class RescanWithNewFiltersException(Exception): print_error("\nScript interrupted by user.") except Exception as e: log_error(f"Unexpected error in main: {e}") - print_error(f"Unexpected error: {e}") \ No newline at end of file + print_error(f"Unexpected error: {e}")