mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Fix AttributeError: 'NoneType' object has no attribute 'group' with sytadin component (#24652)
* Fix AttributeError: 'NoneType' object has no attribute 'group' * Update sensor.py
This commit is contained in:
parent
d8690f426c
commit
ecfbfb4527
@ -124,9 +124,15 @@ class SytadinData:
|
|||||||
data = BeautifulSoup(raw_html, 'html.parser')
|
data = BeautifulSoup(raw_html, 'html.parser')
|
||||||
|
|
||||||
values = data.select('.barometre_valeur')
|
values = data.select('.barometre_valeur')
|
||||||
self.traffic_jam = re.search(REGEX, values[0].text).group()
|
parse_traffic_jam = re.search(REGEX, values[0].text)
|
||||||
self.mean_velocity = re.search(REGEX, values[1].text).group()
|
if parse_traffic_jam:
|
||||||
self.congestion = re.search(REGEX, values[2].text).group()
|
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:
|
except requests.exceptions.ConnectionError:
|
||||||
_LOGGER.error("Connection error")
|
_LOGGER.error("Connection error")
|
||||||
self.data = None
|
self.data = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user