Skip to content

Commit

Permalink
Fix methods dict keyerror (#153)
Browse files Browse the repository at this point in the history
* Improve debug message text

* Handle methods dict keyerror and log info message
  • Loading branch information
allistermaguire authored Mar 25, 2024
1 parent a8e24f8 commit 826cbff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion songpal/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion songpal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 826cbff

Please sign in to comment.