diff --git a/custom_components/flagdays_dk/flagdays.py b/custom_components/flagdays_dk/flagdays.py index 7078697..8f0c94d 100644 --- a/custom_components/flagdays_dk/flagdays.py +++ b/custom_components/flagdays_dk/flagdays.py @@ -123,7 +123,7 @@ def _getFlagTimes(self, dateStr): # If sunrise is before 08:00 use 08:00 else sunrise flagTimes['flag_up_time'] = '08:00' if int(self._sun.get('sunrise').split(':')[0]) < 8 else self._sun.get('sunrise') flagTimes['flag_down_time'] = self._sun.get('sunset') - + return flagTimes def _getNumOfTag(self, html, tag, parser = 'html.parser'): diff --git a/custom_components/flagdays_dk/manifest.json b/custom_components/flagdays_dk/manifest.json index 919d4e5..c933646 100644 --- a/custom_components/flagdays_dk/manifest.json +++ b/custom_components/flagdays_dk/manifest.json @@ -6,5 +6,5 @@ "codeowners": ["J-Lindvig"], "requirements": ["beautifulsoup4", "html.parser"], "iot_class": "cloud_polling", - "version": "1.0" + "version": "1.1" } \ No newline at end of file diff --git a/custom_components/flagdays_dk/sun_future.py b/custom_components/flagdays_dk/sun_future.py index 2c44f15..3ddef45 100644 --- a/custom_components/flagdays_dk/sun_future.py +++ b/custom_components/flagdays_dk/sun_future.py @@ -19,26 +19,24 @@ def __init__(self): self._data = {} def getFutureSun(self, lat = 55.395903819648304, lon = 10.388097722778282, dateStr = 'today'): - # If the data is empty, fetch some new - if not self._data: - self._session = requests.Session() - payload = { - 'lat': lat, - 'lng': lon, - 'date': dateStr, - 'formatted': 0 - } - r = self._session.get(SUN_URL, params = payload) - - if r.status_code == 200: - r = r.json() - if r['status'].lower() == 'ok': - for key in r['results']: - value = r['results'][key] - if key.lower() != 'day_length': - value = self._getLocalDatetime(value) - self._data[key] = value - self._data['date'] = self._getLocalDatetime(r['results']['sunrise'], '%d-%m-%Y') + self._session = requests.Session() + payload = { + 'lat': lat, + 'lng': lon, + 'date': dateStr, + 'formatted': 0 + } + r = self._session.get(SUN_URL, params = payload) + + if r.status_code == 200: + r = r.json() + if r['status'].lower() == 'ok': + for key in r['results']: + value = r['results'][key] + if key.lower() != 'day_length': + value = self._getLocalDatetime(value) + self._data[key] = value + self._data['date'] = self._getLocalDatetime(r['results']['sunrise'], '%d-%m-%Y') def get(self, key): return self._data[key]