Skip to content

Commit

Permalink
Refactored 'match case' to 'if elif' to support python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Olaf Fricke committed Nov 9, 2023
1 parent 1f4829a commit 5cc8c72
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions custom_components/ble_monitor/ble_parser/get_beacon_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,14 @@ async def get_beacon_key(mac, product_id):
# (use 'python service_explorer.py --address <MAC> --service fe95' to dump the 'Xiaomi Inc.' service)
for service in client.services:
for char in service.characteristics:
match char.description:
case 'token':
HANDLE_AUTH = char.handle
case 'Version':
HANDLE_FIRMWARE_VERSION = char.handle
case 'Authentication':
HANDLE_AUTH_INIT = char.handle
case 'beacon_key':
HANDLE_BEACON_KEY = char.handle
if (char.description == 'token'):
HANDLE_AUTH = char.handle
elif (char.description == 'Version'):
HANDLE_FIRMWARE_VERSION = char.handle
elif (char.description == 'Authentication'):
HANDLE_AUTH_INIT = char.handle
elif (char.description == 'beacon_key'):
HANDLE_BEACON_KEY = char.handle

# An asyncio future object is needed for callback handling
future = asyncio.get_event_loop().create_future()
Expand Down

0 comments on commit 5cc8c72

Please sign in to comment.