manzanotti/geniushub-client

Errors parsing some zone timer schedules

Closed this issue · 2 comments

I get this error for 2 zones in my list whenever I run ghclient:

ERROR: Failed to convert Zone 3, message: list index out of range.
Traceback (most recent call last):
  File "./geniushubclient/__init__.py", line 246, in populate_objects
    entity = obj_by_id[raw_json[key]]
KeyError: 3

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./geniushubclient/__init__.py", line 556, in _convert
    result["schedule"]["timer"] = _timer_schedule(raw_json)
  File "./geniushubclient/__init__.py", line 473, in _timer_schedule
    tm_last = setpoints[idx + 1]["iTm"]
IndexError: list index out of range

Which is actually taking place in _timer_schedule(raw_json) -> Dict, when the last item in objTimer has the same temp value as the "defaultSetpoint"

I stopped it complaining like this (the error was in the setpoints[idx + 1]["iTm"]:

-                elif sp_next != node["defaultSetpoint"]:
+                elif sp_next != node["defaultSetpoint"] and idx != len(setpoints)-1:

Though I'm not quite sure what the comparison to defaultSetPoint is for, only collect times when the temp is different to the default?

The data:

      {
        "fSP": 21,
        "iDay": 6,
        "iTm": -1
      },
      {
        "fSP": 15,
        "iDay": 6,
        "iTm": 0
      },
      {
        "fSP": 21,
        "iDay": 6,
        "iTm": 300
      }

HI, thanks for your contribution.

Schedules (there are two for each Zone) have been problematic - the code was designed to fail gracefully if there are any the usual exceptions - the library should work as normal, but just return an empty schedule.

I've just created a gitter channel - we can chat there.

Please PM me the two files described in this repo's wiki

Resolved by PR #29