Zestimate - Added check for the existence of data in response (#23310)

pull/23335/head
dreed47 2019-04-23 14:44:13 -04:00 committed by Paulus Schoutsen
parent c040f7abc0
commit b252d8e2cd
1 changed files with 10 additions and 6 deletions

View File

@ -113,10 +113,14 @@ class ZestimateDataSensor(Entity):
return
data = data_dict['response'][NAME]
details = {}
if 'amount' in data and data['amount'] is not None:
details[ATTR_AMOUNT] = data['amount']['#text']
details[ATTR_CURRENCY] = data['amount']['@currency']
if 'last-updated' in data and data['last-updated'] is not None:
details[ATTR_LAST_UPDATED] = data['last-updated']
if 'valueChange' in data and data['valueChange'] is not None:
details[ATTR_CHANGE] = int(data['valueChange']['#text'])
if 'valuationRange' in data and data['valuationRange'] is not None:
details[ATTR_VAL_HI] = int(data['valuationRange']['high']['#text'])
details[ATTR_VAL_LOW] = int(data['valuationRange']['low']['#text'])
self.address = data_dict['response']['address']['street']