watchforstock / evohome-client

Python client to access the Evohome web service
Apache License 2.0
88 stars 52 forks source link

Error: "More than one location available" when only 1 location #43

Closed zxdavb closed 6 years ago

zxdavb commented 6 years ago

I will do a pull request when I can, but to get this documented:

Every time EvohomeClientv2.installation is called (in my case, via _login()), it executes this piece of code:

def installation(self):
    r = requests.get('https://tccna.honeywell.com/WebAPI/emea/api/v1/location/installationInfo?userId=%s&includeTemperatureControlSystems=True' % self.account_info['userId'], headers=self.headers)
    self.installation_info = self._convert(r.text)
    self.system_id = self.installation_info[0]['gateways'][0]['temperatureControlSystems'][0]['systemId']

    for loc_data in self.installation_info:
        self.locations.append(Location(self, loc_data))

    return self.installation_info

Later, _get_single_heating_system checks for a single location and fails if not:

if len(self.locations)==1:
    location = self.locations[0]
else:
    raise Exception("More than one location available")

This fails because every time installation() is called, it increases the array size by one.

Instead, this may be the correct code:

    self.locations = []
    for loc_data in self.installation_info:
        self.locations.append(Location(self, loc_data))
zxdavb commented 6 years ago

This issue is not yet completely resolved. See the 3rd comment in #47. My fault.

watchforstock commented 6 years ago

Has this now been resolved with the merges we've made or is there something still outstanding? Sorry - have slightly lost track!

zxdavb commented 6 years ago

Yes - a lot went on, and I got a little confused myself.

But I think we're OK to close this now.