Suppress traceback and log error (#16669)

pull/16568/merge
Fabian Affolter 2018-09-18 07:55:13 +02:00 committed by GitHub
parent 27d50d388f
commit a7325ebe1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 5 deletions

View File

@ -114,11 +114,16 @@ class ScrapeSensor(Entity):
raw_data = BeautifulSoup(self.rest.data, 'html.parser')
_LOGGER.debug(raw_data)
try:
if self._attr is not None:
value = raw_data.select(self._select)[0][self._attr]
else:
value = raw_data.select(self._select)[0].text
_LOGGER.debug(value)
except IndexError:
_LOGGER.error("Unable to extract data from HTML")
return
if self._value_template is not None:
self._state = self._value_template.render_with_possible_json_value(