Skip to content

Commit

Permalink
Fix AttributeError: 'NoneType' object has no attribute 'group' with s…
Browse files Browse the repository at this point in the history
…ytadin component (home-assistant#24652)

* Fix AttributeError: 'NoneType' object has no attribute 'group'

* Update sensor.py
  • Loading branch information
foreign-sub authored and balloob committed Jun 20, 2019
1 parent d8690f4 commit ecfbfb4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions homeassistant/components/sytadin/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,15 @@ def update(self):
data = BeautifulSoup(raw_html, 'html.parser')

values = data.select('.barometre_valeur')
self.traffic_jam = re.search(REGEX, values[0].text).group()
self.mean_velocity = re.search(REGEX, values[1].text).group()
self.congestion = re.search(REGEX, values[2].text).group()
parse_traffic_jam = re.search(REGEX, values[0].text)
if parse_traffic_jam:
self.traffic_jam = parse_traffic_jam.group()
parse_mean_velocity = re.search(REGEX, values[1].text)
if parse_mean_velocity:
self.mean_velocity = parse_mean_velocity.group()
parse_congestion = re.search(REGEX, values[2].text)
if parse_congestion:
self.congestion = parse_congestion.group()
except requests.exceptions.ConnectionError:
_LOGGER.error("Connection error")
self.data = None

0 comments on commit ecfbfb4

Please sign in to comment.