From 826cbffe4261eae3b12a767705c4590737b33a1f Mon Sep 17 00:00:00 2001 From: Allister Maguire Date: Tue, 26 Mar 2024 01:04:58 +1300 Subject: [PATCH] Fix methods dict keyerror (#153) * Improve debug message text * Handle methods dict keyerror and log info message --- songpal/device.py | 2 +- songpal/service.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/songpal/device.py b/songpal/device.py index 41486ff..23a91a6 100644 --- a/songpal/device.py +++ b/songpal/device.py @@ -159,7 +159,7 @@ async def get_supported_methods(self, *, default_latest: bool = False): _LOGGER.debug("> %s", api) if api.latest_supported_version is None: _LOGGER.debug( - "No supported version for %s.%s, using %s", + "No supported version specified for %s.%s, using %s", service.name, api.name, api.version, diff --git a/songpal/service.py b/songpal/service.py index 67c634a..0555173 100644 --- a/songpal/service.py +++ b/songpal/service.py @@ -113,7 +113,14 @@ async def from_payload(cls, payload, endpoint, idgen, debug, force_protocol=None # Populate supported versions for method if available for api in payload["apis"]: for v in api["versions"]: - methods[api["name"]].add_supported_version(v["version"]) + if api["name"] in methods: + methods[api["name"]].add_supported_version(v["version"]) + else: + _LOGGER.info( + "No matching method %s for supported version %s.", + api["name"], + v["version"], + ) service.methods = methods