From 81e33441327e023bb971bf8ca701632467718ae7 Mon Sep 17 00:00:00 2001 From: linsvensson Date: Mon, 13 May 2024 13:06:30 +0200 Subject: [PATCH] Fixed facility id error --- custom_components/greenely/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/greenely/api.py b/custom_components/greenely/api.py index 5bace4e..1453f3a 100644 --- a/custom_components/greenely/api.py +++ b/custom_components/greenely/api.py @@ -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)