diff --git a/custom_components/mindergas/sensor.py b/custom_components/mindergas/sensor.py index 994c46e..70744c7 100644 --- a/custom_components/mindergas/sensor.py +++ b/custom_components/mindergas/sensor.py @@ -101,15 +101,18 @@ def update(self): n += 1 if URL_RESULT == URL_DASHBOARD: - # Scrape url - raw_html = session_requests.get(URL_DATA, headers=dict(referer=URL_DATA)).text - data = BeautifulSoup(raw_html, 'html.parser') - - # Scrape prognose - div = data.find_all("div", class_="table_cell")[9] - result = round(eval(div.get_text().replace('m3','').replace(',' , '.').rstrip())) - self._attributes['last_update'] = dt.now().isoformat('T') - self._state = result + try: + # Scrape url + raw_html = session_requests.get(URL_DATA, headers=dict(referer=URL_DATA)).text + data = BeautifulSoup(raw_html, 'html.parser') + + # Scrape prognose + div = data.find_all("div", class_="table_cell")[9] + result = round(eval(div.get_text().replace('m3','').replace(',' , '.').rstrip())) + self._attributes['last_update'] = dt.now().isoformat('T') + self._state = result + except: + self._state = 0 else: pass