Skip to content

Commit

Permalink
Fix invalid cache handling for miotcloud schema fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Aug 30, 2023
1 parent 2546b04 commit 8b5d10a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions miio/miot_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ def get_model_schema(self, model: str) -> Dict:
release_info = specs.info_for_model(model)

model_file = self._cache_dir / f"{release_info.model}.json"
spec = self._file_from_cache(model_file)
if spec is not None:
try:
spec = self._file_from_cache(model_file)
return spec
except FileNotFoundError:
_LOGGER.debug(f"Cached schema not found for {model}, going to fetch it")

spec = MiotSpec.get_spec_for_urn(device_urn=release_info.type)
self._write_to_cache(model_file, spec)
Expand Down

0 comments on commit 8b5d10a

Please sign in to comment.