Fall back to local_epoch if observation_epoch is non-numeric
This fixes a traceback when the weather data is incomplete (possibly due to a PWS being on the fritz).
This commit is contained in:
parent
86634f8f8a
commit
82555cb6a7
@ -239,10 +239,13 @@ class Wunderground(WeatherBackend):
|
||||
return str(data.get(key, default))
|
||||
|
||||
try:
|
||||
observation_time = datetime.fromtimestamp(
|
||||
int(_find('observation_epoch'))
|
||||
observation_epoch = _find('observation_epoch') or _find('local_epoch')
|
||||
observation_time = datetime.fromtimestamp(int(observation_epoch))
|
||||
except (TypeError, ValueError):
|
||||
log.debug(
|
||||
'Observation time \'%s\' is not a UNIX timestamp',
|
||||
observation_epoch
|
||||
)
|
||||
except TypeError:
|
||||
observation_time = datetime.fromtimestamp(0)
|
||||
|
||||
self.data['city'] = _find('city', response['observation_location'])
|
||||
|
Loading…
Reference in New Issue
Block a user