Skip to content

Commit

Permalink
Fixed facility id error
Browse files Browse the repository at this point in the history
  • Loading branch information
linsvensson committed May 13, 2024
1 parent 2aebe96 commit 81e3344
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/greenely/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def get_usage(self, startDate, endDate, showHourly):
def get_facility_id(self):
result = requests.get(self._url_facilities_base, headers = self._headers)
if result.status_code == requests.codes.ok:
data = result.json()
data = result.json()['data']
facility = next((f for f in data if f['is_primary'] == True), None)
if facility == None:
_LOGGER.debug('Found no primary facility, using the first one in the list!')
facility = data[0]
self._facility_id = str(data['data']['parameters']['facility_id'])
self._facility_id = str(data[0]['id'])
_LOGGER.debug('Fetched facility id %s', self._facility_id)
else:
_LOGGER.error('Failed to fetch facility id %s', result.reason)
Expand Down

0 comments on commit 81e3344

Please sign in to comment.