evandcoleman / python-iocare

A Python library for the IOCare API utilized by Coway air purifiers
MIT License
5 stars 3 forks source link

Insufficient protection against KeyError in some cases #3

Open NavreetGill opened 3 years ago

NavreetGill commented 3 years ago

If Purifier's init raises an exception, IOCareApi object's discover_devices fails to properly finish initialize IOCareApi object:

Steps to reproduce:

  1. Plug in 2 air purifiers.
  2. Set up 2 air purifiers with IOCare app
  3. Unplug 1 air purifier
  4. Initialize IOCareAPI object with username and password

Expected:

  1. Atleast 1 device is discovered

Actual: API object cannot be initialized due to the unhandled KeyError.

Guessing this line needs to handle the KeyError https://github.com/evandcoleman/python-iocare/blob/b6baac02f2f879667ccfc3e595dafb6dcccdc3c4/iocare/iocareapi.py#L161

RobertD502 commented 3 years ago

Fixed by #6