Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud getdevices() bug #381

Closed
jasonacox opened this issue Jul 4, 2023 · 0 comments · Fixed by #382
Closed

Cloud getdevices() bug #381

jasonacox opened this issue Jul 4, 2023 · 0 comments · Fixed by #382

Comments

@jasonacox
Copy link
Owner

jasonacox commented Jul 4, 2023

Running wizard with an older devices.json that is missing some of the newer keys (e.g. model) causes an error:

Traceback (most recent call last):
  File "/Users/jason/miniconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/jason/miniconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/jason/Code/tinytuya/tinytuya/__main__.py", line 76, in <module>
    wizard.wizard(color=color, retries=retries, forcescan=force, quicklist=assume_yes)
  File "/Users/jason/Code/tinytuya/tinytuya/wizard.py", line 174, in wizard
    tuyadevices = cloud.getdevices( False, oldlist=old_devices, include_map=include_map )
  File "/Users/jason/Code/tinytuya/tinytuya/Cloud.py", line 490, in getdevices
    if k in dev and k != 'icon' and k != 'last_ip' and old[k] != dev[k]:
KeyError: 'model'

This is due to the older devices.json not having the model key for some devices. Easy fix for line 490 -

            for k in DEVICEFILE_SAVE_VALUES:
                if k in dev and k != 'icon' and k != 'last_ip' and (k not in old or old[k] != dev[k]):
                    is_same = False
                    break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant