Fix yr HTTP error handling (#36889)

This commit is contained in:
Phil Bruckner 2020-06-17 15:40:04 -05:00 committed by GitHub
parent ec440dface
commit 2883aacfa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ from homeassistant.const import (
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_PRESSURE,
DEVICE_CLASS_TEMPERATURE,
HTTP_OK,
HTTP_BAD_REQUEST,
PRESSURE_HPA,
SPEED_METERS_PER_SECOND,
TEMP_CELSIUS,
@ -187,7 +187,7 @@ class YrData:
websession = async_get_clientsession(self.hass)
with async_timeout.timeout(10):
resp = await websession.get(self._url, params=self._urlparams)
if resp.status != HTTP_OK:
if resp.status >= HTTP_BAD_REQUEST:
try_again(f"{resp.url} returned {resp.status}")
return
text = await resp.text()