Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shelly-ble-rpc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
venv/
*.log
16 changes: 3 additions & 13 deletions shelly-ble-rpc/shelly-ble-rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
# ============================
Expand All @@ -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}")
print_error(f"Unexpected error: {e}")